Documentation ¶
Index ¶
- Variables
- func New(canvas *js.Object, ca *ContextAttributes) (gfx.Context, error)
- func Wrap(o *js.Object) gfx.Context
- type Buffer
- func (b *Buffer) DataFloat32(data []float32, usage gfx.BufferUsage)
- func (b *Buffer) DataFloat64(data []float64, usage gfx.BufferUsage)
- func (b *Buffer) DataInt16(data []int16, usage gfx.BufferUsage)
- func (b *Buffer) DataInt32(data []int32, usage gfx.BufferUsage)
- func (b *Buffer) DataInt8(data []int8, usage gfx.BufferUsage)
- func (b *Buffer) DataSize(size int, usage gfx.BufferUsage)
- func (b *Buffer) DataUint16(data []uint16, usage gfx.BufferUsage)
- func (b *Buffer) DataUint32(data []uint32, usage gfx.BufferUsage)
- func (b *Buffer) DataUint8(data []uint8, usage gfx.BufferUsage)
- func (b *Buffer) Delete()
- func (b *Buffer) Draw(p gfx.Primitive, first, count int)
- func (b *Buffer) Object() interface{}
- func (b *Buffer) SubDataFloat32(offset int, data []float32)
- func (b *Buffer) SubDataFloat64(offset int, data []float64)
- func (b *Buffer) SubDataInt16(offset int, data []int16)
- func (b *Buffer) SubDataInt32(offset int, data []int32)
- func (b *Buffer) SubDataInt8(offset int, data []int8)
- func (b *Buffer) SubDataUint16(offset int, data []uint16)
- func (b *Buffer) SubDataUint32(offset int, data []uint32)
- func (b *Buffer) SubDataUint8(offset int, data []uint8)
- func (b *Buffer) VertexAttribPointer(l gfx.AttribLocation, size int, normalized bool, stride, offset int)
- type Context
- func (c *Context) BlendColor(r, g, b, a float32) gfx.ContextStateValue
- func (c *Context) BlendEquation(eq gfx.BlendEquation) gfx.ContextStateValue
- func (c *Context) Check()
- func (c *Context) ColorMask(r, g, b, a bool) gfx.ContextStateValue
- func (c *Context) CullFace(f gfx.Facet) gfx.ContextStateValue
- func (c *Context) DepthMask(m bool) gfx.ContextStateValue
- func (c *Context) Disable(f gfx.Feature) gfx.ContextStateValue
- func (c *Context) Enable(f gfx.Feature) gfx.ContextStateValue
- func (c *Context) EnableVertexAttribArray(l gfx.AttribLocation) gfx.ContextStateValue
- func (c *Context) Finish()
- func (c *Context) Flush()
- func (c *Context) Framebuffer() gfx.Framebuffer
- func (c *Context) FrontFace(o gfx.Orientation) gfx.ContextStateValue
- func (c *Context) LineWidth(w float32) gfx.ContextStateValue
- func (c *Context) NewBuffer(t gfx.BufferType) gfx.Buffer
- func (c *Context) NewFramebuffer() gfx.Framebuffer
- func (c *Context) NewProgram() gfx.Program
- func (c *Context) NewRenderbuffer() gfx.Renderbuffer
- func (c *Context) NewShader(t gfx.ShaderType) gfx.Shader
- func (c *Context) NewTexture(t gfx.TextureType) gfx.Texture
- func (c *Context) Scissor(x, y, width, height int) gfx.ContextStateValue
- func (c *Context) UseProgram(p gfx.Program) gfx.ContextStateValue
- func (c *Context) Viewport(x, y, width, height int) gfx.ContextStateValue
- type ContextAttributes
- type Framebuffer
- func (f *Framebuffer) Clear(m gfx.ClearMask)
- func (f *Framebuffer) ClearColor(r, g, b, a float32) gfx.FramebufferStateValue
- func (f *Framebuffer) ClearDepth(depth float64) gfx.FramebufferStateValue
- func (f *Framebuffer) ClearStencil(stencil int) gfx.FramebufferStateValue
- func (f *Framebuffer) Delete()
- func (f *Framebuffer) Object() interface{}
- func (f *Framebuffer) ReadPixelsUint8(x, y, width, height int, dst []uint8)
- func (f *Framebuffer) Renderbuffer(attachment gfx.FramebufferAttachment, buf gfx.Renderbuffer)
- func (f *Framebuffer) Status() error
- func (f *Framebuffer) Texture2D(attachment gfx.FramebufferAttachment, target gfx.TextureTarget, ...)
- type Program
- func (p *Program) AttribLocation(name string) gfx.AttribLocation
- func (p *Program) Delete()
- func (p *Program) InfoLog() string
- func (p *Program) Link(vert, frag gfx.Shader) bool
- func (p *Program) Object() interface{}
- func (p *Program) Uniform1fv(l gfx.UniformLocation, data []float32)
- func (p *Program) Uniform1iv(l gfx.UniformLocation, data []int32)
- func (p *Program) Uniform2fv(l gfx.UniformLocation, data []float32)
- func (p *Program) Uniform2iv(l gfx.UniformLocation, data []int32)
- func (p *Program) Uniform3fv(l gfx.UniformLocation, data []float32)
- func (p *Program) Uniform3iv(l gfx.UniformLocation, data []int32)
- func (p *Program) Uniform4fv(l gfx.UniformLocation, data []float32)
- func (p *Program) Uniform4iv(l gfx.UniformLocation, data []int32)
- func (p *Program) UniformLocation(name string) gfx.UniformLocation
- func (p *Program) UniformMatrix2fv(l gfx.UniformLocation, transpose bool, data []float32)
- func (p *Program) UniformMatrix3fv(l gfx.UniformLocation, transpose bool, data []float32)
- func (p *Program) UniformMatrix4fv(l gfx.UniformLocation, transpose bool, data []float32)
- type Renderbuffer
- type Shader
- type Texture
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoWebGLSupport = errors.New("browser does not support WebGL")
)
Functions ¶
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer implements the gfx.Buffer interface by wrapping a WebGLBuffer JavaScript object.
func (*Buffer) DataFloat32 ¶
func (b *Buffer) DataFloat32(data []float32, usage gfx.BufferUsage)
DataFloat32 implements the gfx.Buffer interface.
func (*Buffer) DataFloat64 ¶
func (b *Buffer) DataFloat64(data []float64, usage gfx.BufferUsage)
DataFloat64 implements the gfx.Buffer interface.
func (*Buffer) DataInt16 ¶
func (b *Buffer) DataInt16(data []int16, usage gfx.BufferUsage)
DataInt16 implements the gfx.Buffer interface.
func (*Buffer) DataInt32 ¶
func (b *Buffer) DataInt32(data []int32, usage gfx.BufferUsage)
DataInt32 implements the gfx.Buffer interface.
func (*Buffer) DataInt8 ¶
func (b *Buffer) DataInt8(data []int8, usage gfx.BufferUsage)
DataInt8 implements the gfx.Buffer interface.
func (*Buffer) DataSize ¶
func (b *Buffer) DataSize(size int, usage gfx.BufferUsage)
DataSize implements the gfx.Buffer interface.
func (*Buffer) DataUint16 ¶
func (b *Buffer) DataUint16(data []uint16, usage gfx.BufferUsage)
DataUint16 implements the gfx.Buffer interface.
func (*Buffer) DataUint32 ¶
func (b *Buffer) DataUint32(data []uint32, usage gfx.BufferUsage)
DataUint32 implements the gfx.Buffer interface.
func (*Buffer) DataUint8 ¶
func (b *Buffer) DataUint8(data []uint8, usage gfx.BufferUsage)
DataUint8 implements the gfx.Buffer interface.
func (*Buffer) Object ¶
func (b *Buffer) Object() interface{}
Object implements the gfx.Object interface.
func (*Buffer) SubDataFloat32 ¶
SubDataFloat32 implements the gfx.Buffer interface.
func (*Buffer) SubDataFloat64 ¶
SubDataFloat64 implements the gfx.Buffer interface.
func (*Buffer) SubDataInt16 ¶
SubDataInt16 implements the gfx.Buffer interface.
func (*Buffer) SubDataInt32 ¶
SubDataInt32 implements the gfx.Buffer interface.
func (*Buffer) SubDataInt8 ¶
SubDataInt8 implements the gfx.Buffer interface.
func (*Buffer) SubDataUint16 ¶
SubDataUint16 implements the gfx.Buffer interface.
func (*Buffer) SubDataUint32 ¶
SubDataUint32 implements the gfx.Buffer interface.
func (*Buffer) SubDataUint8 ¶
SubDataUint8 implements the gfx.Buffer interface.
func (*Buffer) VertexAttribPointer ¶
func (b *Buffer) VertexAttribPointer(l gfx.AttribLocation, size int, normalized bool, stride, offset int)
VertexAttribPointer implements the gfx.Buffer interface.
type Context ¶
type Context struct { // O is literally the WebGLRenderingContext JavaScript object. O *js.Object state.Context // Enums maps a gfx enumeration to it's cooresponding OpenGL one. Enums [gfx.EnumMax]int LastBindFramebuffer *js.Object LastBindRenderbuffer *js.Object LastBindBuffer *js.Object LastUseProgram *js.Object // WebGL error codes (see the Check method). NO_ERROR int `js:"NO_ERROR"` OUT_OF_MEMORY int `js:"OUT_OF_MEMORY"` INVALID_ENUM int `js:"INVALID_ENUM"` INVALID_OPERATION int `js:"INVALID_OPERATION"` INVALID_FRAMEBUFFER_OPERATION int `js:"INVALID_FRAMEBUFFER_OPERATION"` INVALID_VALUE int `js:"INVALID_VALUE"` CONTEXT_LOST_WEBGL int `js:"CONTEXT_LOST_WEBGL"` FRAMEBUFFER int `js:"FRAMEBUFFER"` RENDERBUFFER int `js:"RENDERBUFFER"` UNSIGNED_BYTE int `js:"UNSIGNED_BYTE"` RGBA int `js:"RGBA"` DEPTH_BUFFER_BIT int `js:"DEPTH_BUFFER_BIT"` STENCIL_BUFFER_BIT int `js:"STENCIL_BUFFER_BIT"` COLOR_BUFFER_BIT int `js:"COLOR_BUFFER_BIT"` COMPILE_STATUS int `js:"COMPILE_STATUS"` LINK_STATUS int `js:"LINK_STATUS"` UNSIGNED_SHORT int `js:"UNSIGNED_SHORT"` FLOAT int `js:"FLOAT"` // Framebuffer status codes (see the Framebuffer.Status method). FRAMEBUFFER_COMPLETE int `js:"FRAMEBUFFER_COMPLETE"` FRAMEBUFFER_INCOMPLETE_ATTACHMENT int `js:"FRAMEBUFFER_INCOMPLETE_ATTACHMENT"` FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT int `js:"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"` FRAMEBUFFER_INCOMPLETE_DIMENSIONS int `js:"FRAMEBUFFER_INCOMPLETE_DIMENSIONS"` FRAMEBUFFER_UNSUPPORTED int `js:"FRAMEBUFFER_UNSUPPORTED"` // contains filtered or unexported fields }
Context implements the gfx.Context interface.
func (*Context) BlendColor ¶
func (c *Context) BlendColor(r, g, b, a float32) gfx.ContextStateValue
BlendColor implements the gfx.ContextStateProvider interface.
func (*Context) BlendEquation ¶
func (c *Context) BlendEquation(eq gfx.BlendEquation) gfx.ContextStateValue
BlendEquation implements the gfx.ContextStateProvider interface.
func (*Context) ColorMask ¶
func (c *Context) ColorMask(r, g, b, a bool) gfx.ContextStateValue
ColorMask implements the gfx.ContextStateProvider interface.
func (*Context) CullFace ¶
func (c *Context) CullFace(f gfx.Facet) gfx.ContextStateValue
CullFace implements the gfx.ContextStateProvider interface.
func (*Context) DepthMask ¶
func (c *Context) DepthMask(m bool) gfx.ContextStateValue
DepthMask implements the gfx.ContextStateProvider interface.
func (*Context) Disable ¶
func (c *Context) Disable(f gfx.Feature) gfx.ContextStateValue
Disable implements the gfx.ContextStateProvider interface.
func (*Context) Enable ¶
func (c *Context) Enable(f gfx.Feature) gfx.ContextStateValue
Enable implements the gfx.ContextStateProvider interface.
func (*Context) EnableVertexAttribArray ¶
func (c *Context) EnableVertexAttribArray(l gfx.AttribLocation) gfx.ContextStateValue
EnableVertexAttribArray implements the gfx.ContextStateProvider interface.
func (*Context) Framebuffer ¶
func (c *Context) Framebuffer() gfx.Framebuffer
Framebuffer implements the gfx.Context interface.
func (*Context) FrontFace ¶
func (c *Context) FrontFace(o gfx.Orientation) gfx.ContextStateValue
FrontFace implements the gfx.ContextStateProvider interface.
func (*Context) LineWidth ¶
func (c *Context) LineWidth(w float32) gfx.ContextStateValue
LineWidth implements the gfx.ContextStateProvider interface.
func (*Context) NewBuffer ¶
func (c *Context) NewBuffer(t gfx.BufferType) gfx.Buffer
NewBuffer implements the gfx.Buffer interface.
func (*Context) NewFramebuffer ¶
func (c *Context) NewFramebuffer() gfx.Framebuffer
NewFramebuffer implements the gfx.Context interface.
func (*Context) NewProgram ¶
NewProgram implements the gfx.Context interface.
func (*Context) NewRenderbuffer ¶
func (c *Context) NewRenderbuffer() gfx.Renderbuffer
NewRenderbuffer implements the gfx.Context interface.
func (*Context) NewShader ¶
func (c *Context) NewShader(t gfx.ShaderType) gfx.Shader
NewShader implements the gfx.Context interface.
func (*Context) NewTexture ¶
func (c *Context) NewTexture(t gfx.TextureType) gfx.Texture
NewTexture implements the gfx.Context interface.
func (*Context) Scissor ¶
func (c *Context) Scissor(x, y, width, height int) gfx.ContextStateValue
Scissor implements the gfx.ContextStateProvider interface.
func (*Context) UseProgram ¶
func (c *Context) UseProgram(p gfx.Program) gfx.ContextStateValue
UseProgram implements the gfx.ContextStateProvider interface.
type ContextAttributes ¶
type ContextAttributes struct { // If the value is true, the drawing buffer has an alpha channel for the // purposes of performing OpenGL destination alpha operations and // compositing with the page. If the value is false, no alpha buffer is // available. Alpha bool // If the value is true, the drawing buffer has a depth buffer of at least // 16 bits. If the value is false, no depth buffer is available. Depth bool // If the value is true, the drawing buffer has a stencil buffer of at // least 8 bits. If the value is false, no stencil buffer is available. Stencil bool // If the value is true and the implementation supports antialiasing the // drawing buffer will perform antialiasing using its choice of technique // (multisample/supersample) and quality. If the value is false or the // implementation does not support antialiasing, no antialiasing is // performed. Antialias bool // If the value is true the page compositor will assume the drawing buffer // contains colors with premultiplied alpha. If the value is false the page // compositor will assume that colors in the drawing buffer are not // premultiplied. This flag is ignored if the alpha flag is false. PremultipliedAlpha bool // If false, once the drawing buffer is presented as described in the // "Drawing Buffer" section, the contents of the drawing buffer are cleared // to their default values. All elements of the drawing buffer (color, // depth and stencil) are cleared. If the value is true the buffers will // not be cleared and will preserve their values until cleared or // overwritten by the author. // // On some hardware setting the preserveDrawingBuffer flag to true can have // significant performance implications. PreserveDrawingBuffer bool // Provides a hint to the implementation suggesting that, if possible, it // creates a context that optimizes for power consumption over performance. // For example, on hardware that has more than one GPU, it may be the case // that one of them is less powerful but also uses less power. An // implementation may choose to, and may have to, ignore this hint. PreferLowPowerToHighPerformance bool // If the value is true, context creation will fail if the implementation // determines that the performance of the created WebGL context would be // dramatically lower than that of a native application making equivalent // OpenGL calls. This could happen for a number of reasons, including: // // An implementation might switch to a software rasterizer if the user's // GPU driver is known to be unstable. // // An implementation might require reading back the framebuffer from GPU // memory to system memory before compositing it with the rest of the page, // significantly reducing performance. // // Applications that don't require high performance should leave this // parameter at its default value of false. Applications that require high // performance may set this parameter to true, and if context creation // fails then the application may prefer to use a fallback rendering path // such as a 2D canvas context. Alternatively the application can retry // WebGL context creation with this parameter set to false, with the // knowledge that a reduced-fidelity rendering mode should be used to // improve performance. FailIfMajorPerformanceCaveat bool }
ContextAttributes is a set of drawing surface attributes passed to New.
func DefaultAttributes ¶
func DefaultAttributes() *ContextAttributes
DefaultAttributes returns a copy of the default context attributes.
type Framebuffer ¶
type Framebuffer struct { s.Framebuffer // contains filtered or unexported fields }
Framebuffer implements the gfx.Framebuffer interface by wrapping a WebGLFramebuffer JavaScript object.
func (*Framebuffer) Clear ¶
func (f *Framebuffer) Clear(m gfx.ClearMask)
Clear implements the gfx.Framebuffer interface.
func (*Framebuffer) ClearColor ¶
func (f *Framebuffer) ClearColor(r, g, b, a float32) gfx.FramebufferStateValue
ClearColor implements the gfx.ContextStateProvider interface.
func (*Framebuffer) ClearDepth ¶
func (f *Framebuffer) ClearDepth(depth float64) gfx.FramebufferStateValue
ClearDepth implements the gfx.ContextStateProvider interface.
func (*Framebuffer) ClearStencil ¶
func (f *Framebuffer) ClearStencil(stencil int) gfx.FramebufferStateValue
ClearStencil implements the gfx.ContextStateProvider interface.
func (*Framebuffer) Delete ¶
func (f *Framebuffer) Delete()
Delete implements the gfx.Object interface.
func (*Framebuffer) Object ¶
func (f *Framebuffer) Object() interface{}
Object implements the gfx.Object interface.
func (*Framebuffer) ReadPixelsUint8 ¶
func (f *Framebuffer) ReadPixelsUint8(x, y, width, height int, dst []uint8)
ReadPixelsUint8 implements the gfx.Framebuffer interface.
func (*Framebuffer) Renderbuffer ¶
func (f *Framebuffer) Renderbuffer(attachment gfx.FramebufferAttachment, buf gfx.Renderbuffer)
Renderbuffer implements the gfx.Framebuffer interface.
func (*Framebuffer) Status ¶
func (f *Framebuffer) Status() error
Status implements the gfx.Framebuffer interface.
func (*Framebuffer) Texture2D ¶
func (f *Framebuffer) Texture2D(attachment gfx.FramebufferAttachment, target gfx.TextureTarget, tex gfx.Texture)
Texture2D implements the gfx.Framebuffer interface.
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program implements the gfx.Program interface by wrapping a WebGLProgram JavaScript object.
func (*Program) AttribLocation ¶
func (p *Program) AttribLocation(name string) gfx.AttribLocation
AttribLocation implements the gfx.Program interface.
func (*Program) Object ¶
func (p *Program) Object() interface{}
Object implements the gfx.Object interface.
func (*Program) Uniform1fv ¶
func (p *Program) Uniform1fv(l gfx.UniformLocation, data []float32)
Uniform1fv implements the gfx.Program interface.
func (*Program) Uniform1iv ¶
func (p *Program) Uniform1iv(l gfx.UniformLocation, data []int32)
Uniform1iv implements the gfx.Program interface.
func (*Program) Uniform2fv ¶
func (p *Program) Uniform2fv(l gfx.UniformLocation, data []float32)
Uniform2fv implements the gfx.Program interface.
func (*Program) Uniform2iv ¶
func (p *Program) Uniform2iv(l gfx.UniformLocation, data []int32)
Uniform2iv implements the gfx.Program interface.
func (*Program) Uniform3fv ¶
func (p *Program) Uniform3fv(l gfx.UniformLocation, data []float32)
Uniform3fv implements the gfx.Program interface.
func (*Program) Uniform3iv ¶
func (p *Program) Uniform3iv(l gfx.UniformLocation, data []int32)
Uniform3iv implements the gfx.Program interface.
func (*Program) Uniform4fv ¶
func (p *Program) Uniform4fv(l gfx.UniformLocation, data []float32)
Uniform4fv implements the gfx.Program interface.
func (*Program) Uniform4iv ¶
func (p *Program) Uniform4iv(l gfx.UniformLocation, data []int32)
Uniform4iv implements the gfx.Program interface.
func (*Program) UniformLocation ¶
func (p *Program) UniformLocation(name string) gfx.UniformLocation
UniformLocation implements the gfx.Program interface.
func (*Program) UniformMatrix2fv ¶
func (p *Program) UniformMatrix2fv(l gfx.UniformLocation, transpose bool, data []float32)
UniformMatrix2fv implements the gfx.Program interface.
func (*Program) UniformMatrix3fv ¶
func (p *Program) UniformMatrix3fv(l gfx.UniformLocation, transpose bool, data []float32)
UniformMatrix3fv implements the gfx.Program interface.
func (*Program) UniformMatrix4fv ¶
func (p *Program) UniformMatrix4fv(l gfx.UniformLocation, transpose bool, data []float32)
UniformMatrix4fv implements the gfx.Program interface.
type Renderbuffer ¶
type Renderbuffer struct {
// contains filtered or unexported fields
}
Renderbuffer implements the gfx.Renderbuffer interface by wrapping a WebGLRenderbuffer JavaScript object.
func (*Renderbuffer) Delete ¶
func (r *Renderbuffer) Delete()
Delete implements the gfx.Object interface.
func (*Renderbuffer) Object ¶
func (r *Renderbuffer) Object() interface{}
Object implements the gfx.Object interface.
func (*Renderbuffer) Storage ¶
func (r *Renderbuffer) Storage(internalFormat gfx.RenderbufferFormat, width, height int)
Storage implements the gfx.Renderbuffer interface.
type Shader ¶
type Shader struct {
// contains filtered or unexported fields
}
Shader implements the gfx.Shader interface by wrapping a WebGLShader JavaScript object.
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
Texture implements the gfx.Texture interface by wrapping a WebGLTexture JavaScript object.
func (*Texture) Object ¶
func (t *Texture) Object() interface{}
Object implements the gfx.Object interface.
func (*Texture) Type ¶
func (t *Texture) Type() gfx.TextureType
Type implements the gfx.Texture interface.