gl

package
v0.0.0-...-597c9ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2015 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const HistorySize = 100

Variables

View Source
var COLOR_FS_SOURCE = `
  uniform vec4 Color;
  void main() {
    gl_FragColor = Color;
    gl_FragColor *= gl_FragColor.a; // PMA
  }
`
View Source
var COLOR_VS_SOURCE = `` /* 159-byte string literal not displayed */
View Source
var COPY_FS_SOURCE = `` /* 126-byte string literal not displayed */
View Source
var COPY_VS_SOURCE = `` /* 230-byte string literal not displayed */
View Source
var FONT_FS_SOURCE = `` /* 291-byte string literal not displayed */
View Source
var FONT_VS_SOURCE = `` /* 496-byte string literal not displayed */

Functions

func CheckError

func CheckError()

func StartDriver

func StartDriver(appThread AppThread)

Types

type AppThread

type AppThread func(driver gxui.Driver)

type Blitter

type Blitter struct {
	// contains filtered or unexported fields
}

func CreateBlitter

func CreateBlitter(ctx *Context, stats *Stats) *Blitter

func (*Blitter) Blit

func (b *Blitter) Blit(ctx *Context, ss SamplerSource, srcRect, dstRect math.Rect, ds *DrawState)

func (*Blitter) BlitGlyph

func (b *Blitter) BlitGlyph(ctx *Context, ss SamplerSource, c gxui.Color, srcRect, dstRect math.Rect, ds *DrawState)

func (*Blitter) BlitRect

func (b *Blitter) BlitRect(ctx *Context, dstRect math.Rect, color gxui.Color, ds *DrawState)

func (*Blitter) BlitShape

func (b *Blitter) BlitShape(ctx *Context, shape Shape, color gxui.Color, ds *DrawState)

func (*Blitter) Commit

func (b *Blitter) Commit(ctx *Context)

func (*Blitter) CommitGlyphs

func (b *Blitter) CommitGlyphs(ctx *Context)

func (*Blitter) Destroy

func (b *Blitter) Destroy(ctx *Context)

type Canvas

type Canvas struct {
	// contains filtered or unexported fields
}

func CreateCanvas

func CreateCanvas(sizeDips math.Size) *Canvas

func (*Canvas) AddClip

func (c *Canvas) AddClip(r math.Rect)

func (*Canvas) AddRef

func (r *Canvas) AddRef()

func (*Canvas) Alive

func (r *Canvas) Alive() bool

func (*Canvas) AssertAlive

func (r *Canvas) AssertAlive(funcName string)

func (*Canvas) Clear

func (c *Canvas) Clear(color gxui.Color)

func (*Canvas) Complete

func (c *Canvas) Complete()

func (*Canvas) DrawCanvas

func (c *Canvas) DrawCanvas(canvas gxui.Canvas, offsetDips math.Point)

func (*Canvas) DrawLines

func (c *Canvas) DrawLines(lines gxui.Polygon, pen gxui.Pen)

func (*Canvas) DrawPolygon

func (c *Canvas) DrawPolygon(poly gxui.Polygon, pen gxui.Pen, brush gxui.Brush)

func (*Canvas) DrawRect

func (c *Canvas) DrawRect(r math.Rect, brush gxui.Brush)

func (*Canvas) DrawRoundedRect

func (c *Canvas) DrawRoundedRect(r math.Rect, tl, tr, bl, br float32, pen gxui.Pen, brush gxui.Brush)

func (*Canvas) DrawRunes

func (c *Canvas) DrawRunes(f gxui.Font, r []rune, col gxui.Color, p []math.Point, o math.Point)

func (*Canvas) DrawText

func (*Canvas) DrawTexture

func (c *Canvas) DrawTexture(t gxui.Texture, r math.Rect)

func (*Canvas) Pop

func (c *Canvas) Pop()

func (*Canvas) Push

func (c *Canvas) Push()

func (*Canvas) Release

func (c *Canvas) Release()

func (*Canvas) Size

func (c *Canvas) Size() math.Size

gxui.Canvas compliance

type CanvasOp

type CanvasOp func(ctx *Context, dss *DrawStateStack)

type Context

type Context struct {
	Blitter *Blitter
	// contains filtered or unexported fields
}

func CreateContext

func CreateContext() *Context

func (*Context) Apply

func (c *Context) Apply(ds *DrawState)

func (*Context) BeginDraw

func (c *Context) BeginDraw(sizeDips, sizePixels math.Size)

func (*Context) Destroy

func (c *Context) Destroy()

func (*Context) DipsToPixels

func (c *Context) DipsToPixels() float32

func (*Context) EndDraw

func (c *Context) EndDraw()

func (*Context) GetOrCreateIndexBufferContext

func (c *Context) GetOrCreateIndexBufferContext(ib *IndexBuffer) IndexBufferContext

func (*Context) GetOrCreateTextureContext

func (c *Context) GetOrCreateTextureContext(t *Texture) TextureContext

func (*Context) GetOrCreateVertexStreamContext

func (c *Context) GetOrCreateVertexStreamContext(vs *VertexStream) VertexStreamContext

func (*Context) LastStats

func (c *Context) LastStats() Stats

func (*Context) PointDipsToPixels

func (c *Context) PointDipsToPixels(dips math.Point) math.Point

func (*Context) RectDipsToPixels

func (c *Context) RectDipsToPixels(dips math.Rect) math.Rect

func (*Context) RenderTargetSizePixels

func (c *Context) RenderTargetSizePixels() math.Size

func (*Context) Resolution

func (c *Context) Resolution() Resolution

func (*Context) SizeDipsToPixels

func (c *Context) SizeDipsToPixels(dips math.Size) math.Size

func (*Context) SizePixelsToDips

func (c *Context) SizePixelsToDips(dips math.Size) math.Size

func (*Context) Stats

func (c *Context) Stats() *Stats

type DrawMode

type DrawMode int
const (
	POINTS         DrawMode = gl.POINTS
	LINE_STRIP     DrawMode = gl.LINE_STRIP
	LINE_LOOP      DrawMode = gl.LINE_LOOP
	LINES          DrawMode = gl.LINES
	TRIANGLE_STRIP DrawMode = gl.TRIANGLE_STRIP
	TRIANGLE_FAN   DrawMode = gl.TRIANGLE_FAN
	TRIANGLES      DrawMode = gl.TRIANGLES
)

func (DrawMode) PrimitiveCount

func (d DrawMode) PrimitiveCount(vertexCount int) int

type DrawState

type DrawState struct {
	// The below are all in window coordinates
	ClipPixels   math.Rect
	OriginPixels math.Point
}

type DrawStateStack

type DrawStateStack []DrawState

func (*DrawStateStack) Head

func (s *DrawStateStack) Head() *DrawState

func (*DrawStateStack) Pop

func (s *DrawStateStack) Pop()

func (*DrawStateStack) Push

func (s *DrawStateStack) Push(ds DrawState)

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

func (*Driver) CreateCanvas

func (d *Driver) CreateCanvas(s math.Size) gxui.Canvas

func (*Driver) CreateFont

func (d *Driver) CreateFont(data []byte, size int) (gxui.Font, error)

func (*Driver) CreateTexture

func (d *Driver) CreateTexture(img image.Image, pixelsPerDip float32) gxui.Texture

func (*Driver) CreateViewport

func (d *Driver) CreateViewport(width, height int, name string) gxui.Viewport

func (*Driver) EnableDebug

func (d *Driver) EnableDebug(enabled bool)

func (*Driver) Events

func (d *Driver) Events() chan func()

gxui.Driver compliance

func (*Driver) GetClipboard

func (d *Driver) GetClipboard() (str string, err error)

func (*Driver) SetClipboard

func (d *Driver) SetClipboard(str string)

func (*Driver) Terminate

func (d *Driver) Terminate()

type Font

type Font struct {
	// contains filtered or unexported fields
}

func (*Font) Draw

func (f *Font) Draw(ctx *Context, str string, col gxui.Color, alignRectDips math.Rect, h gxui.HorizontalAlignment, v gxui.VerticalAlignment, ds *DrawState)

func (*Font) DrawRunes

func (f *Font) DrawRunes(ctx *Context, runes []rune, col gxui.Color, points []math.Point, origin math.Point, ds *DrawState)

func (*Font) GlyphMaxSize

func (f *Font) GlyphMaxSize() math.Size

func (*Font) LayoutRunes

func (f *Font) LayoutRunes(points []math.Point, runes []rune, alignRectDips math.Rect, h gxui.HorizontalAlignment, v gxui.VerticalAlignment)

func (*Font) LoadGlyphs

func (f *Font) LoadGlyphs(first, last rune)

func (*Font) Measure

func (f *Font) Measure(s string) math.Size

func (*Font) MeasureRunes

func (f *Font) MeasureRunes(runes []rune) math.Size

func (*Font) Size

func (f *Font) Size() int

type Framebuffer

type Framebuffer struct {
	// contains filtered or unexported fields
}

func CreateFramebuffer

func CreateFramebuffer(dimensions math.Size) *Framebuffer

func (Framebuffer) Delete

func (f Framebuffer) Delete()

func (Framebuffer) SizeBytes

func (f Framebuffer) SizeBytes() int

type FramebufferPool

type FramebufferPool struct {
	// contains filtered or unexported fields
}

func CreateFramebufferPool

func CreateFramebufferPool(targetBytesAllocated int, stats *Stats) *FramebufferPool

func (*FramebufferPool) Acquire

func (p *FramebufferPool) Acquire(dimensions math.Size) *Framebuffer

func (*FramebufferPool) Release

func (p *FramebufferPool) Release(framebuffer *Framebuffer)

type GlobalStats

type GlobalStats struct {
	CanvasCount       int
	ShapeCount        int
	VertexBufferCount int
	VertexStreamCount int
	IndexBufferCount  int
}

func (GlobalStats) String

func (s GlobalStats) String() string

type GlyphBatch

type GlyphBatch struct {
	DstRects  []float32
	SrcRects  []float32
	Colors    []float32
	ClipRects []float32
	Indices   []uint32
	GlyphPage SamplerSource
}

type IndexBuffer

type IndexBuffer struct {
	// contains filtered or unexported fields
}

func CreateIndexBuffer

func CreateIndexBuffer(ty PrimitiveType, data interface{}) *IndexBuffer

func (*IndexBuffer) AddRef

func (r *IndexBuffer) AddRef()

func (*IndexBuffer) Alive

func (r *IndexBuffer) Alive() bool

func (*IndexBuffer) AssertAlive

func (r *IndexBuffer) AssertAlive(funcName string)

func (IndexBuffer) CreateContext

func (b IndexBuffer) CreateContext() IndexBufferContext

func (*IndexBuffer) Release

func (b *IndexBuffer) Release()

type IndexBufferContext

type IndexBufferContext struct {
	// contains filtered or unexported fields
}

func (*IndexBufferContext) Destroy

func (c *IndexBufferContext) Destroy()

func (IndexBufferContext) Render

func (c IndexBufferContext) Render(drawMode DrawMode)

type PrimitiveType

type PrimitiveType int

func (PrimitiveType) IsArrayOfType

func (p PrimitiveType) IsArrayOfType(array interface{}) bool

func (PrimitiveType) SizeInBytes

func (p PrimitiveType) SizeInBytes() int

type Quad

type Quad struct {
	Texture          *Texture
	SrcRect, DstRect math.Rect
}

type RefCounted

type RefCounted interface {
	AddRef()
	Release()
}

type Resolution

type Resolution uint32

16:16 fixed point ratio of DIPs to pixels

func (Resolution) IntDipsToPixels

func (r Resolution) IntDipsToPixels(s int) int

func (Resolution) PointDipsToPixels

func (r Resolution) PointDipsToPixels(s math.Point) math.Point

func (Resolution) RectDipsToPixels

func (r Resolution) RectDipsToPixels(s math.Rect) math.Rect

func (Resolution) SizeDipsToPixels

func (r Resolution) SizeDipsToPixels(s math.Size) math.Size

type SamplerSource

type SamplerSource interface {
	Texture() uint32
	SizePixels() math.Size
	FlipY() bool
	PremultipliedAlpha() bool
}

type ShaderDataType

type ShaderDataType int

func (ShaderDataType) SizeInBytes

func (s ShaderDataType) SizeInBytes() int

func (ShaderDataType) String

func (s ShaderDataType) String() string

func (ShaderDataType) VectorElementCount

func (s ShaderDataType) VectorElementCount() int

func (ShaderDataType) VectorElementType

func (s ShaderDataType) VectorElementType() PrimitiveType

type ShaderProgram

type ShaderProgram struct {
	Program    uint32
	Uniforms   []shaderUniform
	Attributes []shaderAttribute
}

func CreateShaderProgram

func CreateShaderProgram(ctx *Context, vsSource, fsSource string) *ShaderProgram

func (*ShaderProgram) Bind

func (s *ShaderProgram) Bind(ctx *Context, vb *VertexBuffer, uniforms UniformBindings)

func (*ShaderProgram) Destroy

func (s *ShaderProgram) Destroy(ctx *Context)

func (*ShaderProgram) Unbind

func (s *ShaderProgram) Unbind(ctx *Context)

type Shape

type Shape struct {
	// contains filtered or unexported fields
}

func CreateQuadShape

func CreateQuadShape() *Shape

func CreateShape

func CreateShape(vb *VertexBuffer, ib *IndexBuffer, drawMode DrawMode) *Shape

func (*Shape) AddRef

func (r *Shape) AddRef()

func (*Shape) Alive

func (r *Shape) Alive() bool

func (*Shape) AssertAlive

func (r *Shape) AssertAlive(funcName string)

func (Shape) Draw

func (s Shape) Draw(ctx *Context, shader *ShaderProgram, ub UniformBindings)

func (*Shape) Release

func (s *Shape) Release()

type Stats

type Stats struct {
	TextureCount              int
	FramebufferUsedCount      int
	FramebufferFreeCount      int
	FramebufferBytesAllocated int
	VertexStreamCount         int
	IndexBufferCount          int
	ShaderProgramCount        int
	FrameCount                int
	DrawCallCount             int
	Timers                    []Timer
}

func (Stats) String

func (s Stats) String() string

func (*Stats) Timer

func (s *Stats) Timer(name string) *Timer

type Texture

type Texture struct {
	// contains filtered or unexported fields
}

func CreateTexture

func CreateTexture(img image.Image, pixelsPerDip float32) *Texture

func (*Texture) AddRef

func (r *Texture) AddRef()

func (*Texture) Alive

func (r *Texture) Alive() bool

func (*Texture) AssertAlive

func (r *Texture) AssertAlive(funcName string)

func (*Texture) CreateContext

func (t *Texture) CreateContext() TextureContext

func (*Texture) FlipY

func (t *Texture) FlipY() bool

func (*Texture) Image

func (t *Texture) Image() image.Image

gxui.Texture compliance

func (*Texture) Release

func (r *Texture) Release()

func (*Texture) SetFlipY

func (t *Texture) SetFlipY(flipY bool)

func (*Texture) Size

func (t *Texture) Size() math.Size

func (*Texture) SizePixels

func (t *Texture) SizePixels() math.Size

type TextureContext

type TextureContext struct {
	// contains filtered or unexported fields
}

func (*TextureContext) Destroy

func (c *TextureContext) Destroy()

func (TextureContext) FlipY

func (c TextureContext) FlipY() bool

func (TextureContext) PremultipliedAlpha

func (c TextureContext) PremultipliedAlpha() bool

func (TextureContext) SizePixels

func (c TextureContext) SizePixels() math.Size

func (TextureContext) Texture

func (c TextureContext) Texture() uint32

type Timer

type Timer struct {
	Name     string
	Duration time.Duration
	// contains filtered or unexported fields
}

func (Timer) Format

func (t Timer) Format(f fmt.State, c rune)

func (*Timer) Start

func (t *Timer) Start()

func (*Timer) Stop

func (t *Timer) Stop()

type UniformBindings

type UniformBindings map[string]interface{}

type VertexBuffer

type VertexBuffer struct {
	Streams     map[string]*VertexStream
	VertexCount int
	// contains filtered or unexported fields
}

func CreateVertexBuffer

func CreateVertexBuffer(streams ...*VertexStream) *VertexBuffer

func (*VertexBuffer) AddRef

func (r *VertexBuffer) AddRef()

func (*VertexBuffer) Alive

func (r *VertexBuffer) Alive() bool

func (*VertexBuffer) AssertAlive

func (r *VertexBuffer) AssertAlive(funcName string)

func (*VertexBuffer) Release

func (vb *VertexBuffer) Release()

type VertexStream

type VertexStream struct {
	// contains filtered or unexported fields
}

func CreateVertexStream

func CreateVertexStream(name string, ty ShaderDataType, data interface{}) *VertexStream

func (*VertexStream) AddRef

func (r *VertexStream) AddRef()

func (*VertexStream) Alive

func (r *VertexStream) Alive() bool

func (*VertexStream) AssertAlive

func (r *VertexStream) AssertAlive(funcName string)

func (VertexStream) CreateContext

func (s VertexStream) CreateContext() VertexStreamContext

func (VertexStream) Name

func (s VertexStream) Name() string

func (*VertexStream) Release

func (s *VertexStream) Release()

func (VertexStream) Type

func (s VertexStream) Type() ShaderDataType

func (VertexStream) VertexCount

func (s VertexStream) VertexCount() int

type VertexStreamContext

type VertexStreamContext struct {
	// contains filtered or unexported fields
}

func (VertexStreamContext) Bind

func (c VertexStreamContext) Bind()

func (*VertexStreamContext) Destroy

func (c *VertexStreamContext) Destroy()

type Viewport

type Viewport struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func CreateViewport

func CreateViewport(driver *Driver, width, height int, title string) *Viewport

func (*Viewport) Close

func (v *Viewport) Close()

func (*Viewport) Destroy

func (v *Viewport) Destroy()

func (*Viewport) Hide

func (v *Viewport) Hide()

func (*Viewport) OnClose

func (v *Viewport) OnClose(f func()) gxui.EventSubscription

func (*Viewport) OnKeyDown

func (v *Viewport) OnKeyDown(f func(gxui.KeyboardEvent)) gxui.EventSubscription

func (*Viewport) OnKeyRepeat

func (v *Viewport) OnKeyRepeat(f func(gxui.KeyboardEvent)) gxui.EventSubscription

func (*Viewport) OnKeyStroke

func (v *Viewport) OnKeyStroke(f func(gxui.KeyStrokeEvent)) gxui.EventSubscription

func (*Viewport) OnKeyUp

func (v *Viewport) OnKeyUp(f func(gxui.KeyboardEvent)) gxui.EventSubscription

func (*Viewport) OnMouseDown

func (v *Viewport) OnMouseDown(f func(gxui.MouseEvent)) gxui.EventSubscription

func (*Viewport) OnMouseEnter

func (v *Viewport) OnMouseEnter(f func(gxui.MouseEvent)) gxui.EventSubscription

func (*Viewport) OnMouseExit

func (v *Viewport) OnMouseExit(f func(gxui.MouseEvent)) gxui.EventSubscription

func (*Viewport) OnMouseMove

func (v *Viewport) OnMouseMove(f func(gxui.MouseEvent)) gxui.EventSubscription

func (*Viewport) OnMouseScroll

func (v *Viewport) OnMouseScroll(f func(gxui.MouseEvent)) gxui.EventSubscription

func (*Viewport) OnMouseUp

func (v *Viewport) OnMouseUp(f func(gxui.MouseEvent)) gxui.EventSubscription

func (*Viewport) OnResize

func (v *Viewport) OnResize(f func()) gxui.EventSubscription

func (*Viewport) SetCanvas

func (v *Viewport) SetCanvas(canvas gxui.Canvas)

gxui.Viewport compliance These methods are all called on the application routine

func (*Viewport) SetTitle

func (v *Viewport) SetTitle(title string)

func (*Viewport) Show

func (v *Viewport) Show()

func (*Viewport) SizeDips

func (v *Viewport) SizeDips() math.Size

func (*Viewport) SizePixels

func (v *Viewport) SizePixels() math.Size

func (*Viewport) Stats

func (v *Viewport) Stats() string

func (*Viewport) Title

func (v *Viewport) Title() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL