webgl

package module
v0.0.0-...-ae8bbd7 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2018 License: BSD-2-Clause Imports: 2 Imported by: 0

README

webgl

GoDoc Go Report Card

GopherJS bindings for WebGL 1.0 context.

Example

Screenshot

webgl_example.go:

package main

import (
	"github.com/gopherjs/gopherjs/js"
	"github.com/gopherjs/webgl"
)

func main() {
	document := js.Global.Get("document")
	canvas := document.Call("createElement", "canvas")
	document.Get("body").Call("appendChild", canvas)

	attrs := webgl.DefaultAttributes()
	attrs.Alpha = false

	gl, err := webgl.NewContext(canvas, attrs)
	if err != nil {
		js.Global.Call("alert", "Error: "+err.Error())
	}

	gl.ClearColor(0.8, 0.3, 0.01, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
}

webgl_example.html:

<html><body><script src="webgl_example.js"></script></body></html>

To produce webgl_example.js file, run gopherjs build webgl_example.go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	*js.Object
	ARRAY_BUFFER                                 int `js:"ARRAY_BUFFER"`
	ARRAY_BUFFER_BINDING                         int `js:"ARRAY_BUFFER_BINDING"`
	ATTACHED_SHADERS                             int `js:"ATTACHED_SHADERS"`
	BACK                                         int `js:"BACK"`
	BLEND                                        int `js:"BLEND"`
	BLEND_COLOR                                  int `js:"BLEND_COLOR"`
	BLEND_DST_ALPHA                              int `js:"BLEND_DST_ALPHA"`
	BLEND_DST_RGB                                int `js:"BLEND_DST_RGB"`
	BLEND_EQUATION                               int `js:"BLEND_EQUATION"`
	BLEND_EQUATION_ALPHA                         int `js:"BLEND_EQUATION_ALPHA"`
	BLEND_EQUATION_RGB                           int `js:"BLEND_EQUATION_RGB"`
	BLEND_SRC_ALPHA                              int `js:"BLEND_SRC_ALPHA"`
	BLEND_SRC_RGB                                int `js:"BLEND_SRC_RGB"`
	BLUE_BITS                                    int `js:"BLUE_BITS"`
	BOOL                                         int `js:"BOOL"`
	BOOL_VEC2                                    int `js:"BOOL_VEC2"`
	BOOL_VEC3                                    int `js:"BOOL_VEC3"`
	BOOL_VEC4                                    int `js:"BOOL_VEC4"`
	BROWSER_DEFAULT_WEBGL                        int `js:"BROWSER_DEFAULT_WEBGL"`
	BUFFER_SIZE                                  int `js:"BUFFER_SIZE"`
	BUFFER_USAGE                                 int `js:"BUFFER_USAGE"`
	BYTE                                         int `js:"BYTE"`
	CCW                                          int `js:"CCW"`
	CLAMP_TO_EDGE                                int `js:"CLAMP_TO_EDGE"`
	COLOR_ATTACHMENT0                            int `js:"COLOR_ATTACHMENT0"`
	COLOR_BUFFER_BIT                             int `js:"COLOR_BUFFER_BIT"`
	COLOR_CLEAR_VALUE                            int `js:"COLOR_CLEAR_VALUE"`
	COLOR_WRITEMASK                              int `js:"COLOR_WRITEMASK"`
	COMPILE_STATUS                               int `js:"COMPILE_STATUS"`
	COMPRESSED_TEXTURE_FORMATS                   int `js:"COMPRESSED_TEXTURE_FORMATS"`
	CONSTANT_ALPHA                               int `js:"CONSTANT_ALPHA"`
	CONSTANT_COLOR                               int `js:"CONSTANT_COLOR"`
	CONTEXT_LOST_WEBGL                           int `js:"CONTEXT_LOST_WEBGL"`
	CULL_FACE                                    int `js:"CULL_FACE"`
	CULL_FACE_MODE                               int `js:"CULL_FACE_MODE"`
	CURRENT_PROGRAM                              int `js:"CURRENT_PROGRAM"`
	CURRENT_VERTEX_ATTRIB                        int `js:"CURRENT_VERTEX_ATTRIB"`
	CW                                           int `js:"CW"`
	DECR                                         int `js:"DECR"`
	DECR_WRAP                                    int `js:"DECR_WRAP"`
	DELETE_STATUS                                int `js:"DELETE_STATUS"`
	DEPTH_ATTACHMENT                             int `js:"DEPTH_ATTACHMENT"`
	DEPTH_BITS                                   int `js:"DEPTH_BITS"`
	DEPTH_BUFFER_BIT                             int `js:"DEPTH_BUFFER_BIT"`
	DEPTH_CLEAR_VALUE                            int `js:"DEPTH_CLEAR_VALUE"`
	DEPTH_COMPONENT                              int `js:"DEPTH_COMPONENT"`
	DEPTH_COMPONENT16                            int `js:"DEPTH_COMPONENT16"`
	DEPTH_FUNC                                   int `js:"DEPTH_FUNC"`
	DEPTH_RANGE                                  int `js:"DEPTH_RANGE"`
	DEPTH_STENCIL                                int `js:"DEPTH_STENCIL"`
	DEPTH_STENCIL_ATTACHMENT                     int `js:"DEPTH_STENCIL_ATTACHMENT"`
	DEPTH_TEST                                   int `js:"DEPTH_TEST"`
	DEPTH_WRITEMASK                              int `js:"DEPTH_WRITEMASK"`
	DITHER                                       int `js:"DITHER"`
	DONT_CARE                                    int `js:"DONT_CARE"`
	DRAW_FRAMEBUFFER                             int `js:"DRAW_FRAMEBUFFER"`
	DST_ALPHA                                    int `js:"DST_ALPHA"`
	DST_COLOR                                    int `js:"DST_COLOR"`
	DYNAMIC_DRAW                                 int `js:"DYNAMIC_DRAW"`
	ELEMENT_ARRAY_BUFFER                         int `js:"ELEMENT_ARRAY_BUFFER"`
	ELEMENT_ARRAY_BUFFER_BINDING                 int `js:"ELEMENT_ARRAY_BUFFER_BINDING"`
	EQUAL                                        int `js:"EQUAL"`
	FASTEST                                      int `js:"FASTEST"`
	FLOAT                                        int `js:"FLOAT"`
	FLOAT_MAT2                                   int `js:"FLOAT_MAT2"`
	FLOAT_MAT3                                   int `js:"FLOAT_MAT3"`
	FLOAT_MAT4                                   int `js:"FLOAT_MAT4"`
	FLOAT_VEC2                                   int `js:"FLOAT_VEC2"`
	FLOAT_VEC3                                   int `js:"FLOAT_VEC3"`
	FLOAT_VEC4                                   int `js:"FLOAT_VEC4"`
	FRAGMENT_SHADER                              int `js:"FRAGMENT_SHADER"`
	FRAMEBUFFER                                  int `js:"FRAMEBUFFER"`
	FRAMEBUFFER_ATTACHMENT_OBJECT_NAME           int `js:"FRAMEBUFFER_ATTACHMENT_OBJECT_NAME"`
	FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE           int `js:"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE"`
	FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE int `js:"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE"`
	FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL         int `js:"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL"`
	FRAMEBUFFER_BINDING                          int `js:"FRAMEBUFFER_BINDING"`
	FRAMEBUFFER_COMPLETE                         int `js:"FRAMEBUFFER_COMPLETE"`
	FRAMEBUFFER_INCOMPLETE_ATTACHMENT            int `js:"FRAMEBUFFER_INCOMPLETE_ATTACHMENT"`
	FRAMEBUFFER_INCOMPLETE_DIMENSIONS            int `js:"FRAMEBUFFER_INCOMPLETE_DIMENSIONS"`
	FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT    int `js:"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"`
	FRAMEBUFFER_UNSUPPORTED                      int `js:"FRAMEBUFFER_UNSUPPORTED"`
	FRONT                                        int `js:"FRONT"`
	FRONT_AND_BACK                               int `js:"FRONT_AND_BACK"`
	FRONT_FACE                                   int `js:"FRONT_FACE"`
	FUNC_ADD                                     int `js:"FUNC_ADD"`
	FUNC_REVERSE_SUBTRACT                        int `js:"FUNC_REVERSE_SUBTRACT"`
	FUNC_SUBTRACT                                int `js:"FUNC_SUBTRACT"`
	GENERATE_MIPMAP_HINT                         int `js:"GENERATE_MIPMAP_HINT"`
	GEQUAL                                       int `js:"GEQUAL"`
	GREATER                                      int `js:"GREATER"`
	GREEN_BITS                                   int `js:"GREEN_BITS"`
	HIGH_FLOAT                                   int `js:"HIGH_FLOAT"`
	HIGH_INT                                     int `js:"HIGH_INT"`
	INCR                                         int `js:"INCR"`
	INCR_WRAP                                    int `js:"INCR_WRAP"`
	INFO_LOG_LENGTH                              int `js:"INFO_LOG_LENGTH"`
	INT                                          int `js:"INT"`
	INT_VEC2                                     int `js:"INT_VEC2"`
	INT_VEC3                                     int `js:"INT_VEC3"`
	INT_VEC4                                     int `js:"INT_VEC4"`
	INVALID_ENUM                                 int `js:"INVALID_ENUM"`
	INVALID_FRAMEBUFFER_OPERATION                int `js:"INVALID_FRAMEBUFFER_OPERATION"`
	INVALID_OPERATION                            int `js:"INVALID_OPERATION"`
	INVALID_VALUE                                int `js:"INVALID_VALUE"`
	INVERT                                       int `js:"INVERT"`
	KEEP                                         int `js:"KEEP"`
	LEQUAL                                       int `js:"LEQUAL"`
	LESS                                         int `js:"LESS"`
	LINEAR                                       int `js:"LINEAR"`
	LINEAR_MIPMAP_LINEAR                         int `js:"LINEAR_MIPMAP_LINEAR"`
	LINEAR_MIPMAP_NEAREST                        int `js:"LINEAR_MIPMAP_NEAREST"`
	LINES                                        int `js:"LINES"`
	LINE_LOOP                                    int `js:"LINE_LOOP"`
	LINE_STRIP                                   int `js:"LINE_STRIP"`
	LINE_WIDTH                                   int `js:"LINE_WIDTH"`
	LINK_STATUS                                  int `js:"LINK_STATUS"`
	LOW_FLOAT                                    int `js:"LOW_FLOAT"`
	LOW_INT                                      int `js:"LOW_INT"`
	LUMINANCE                                    int `js:"LUMINANCE"`
	LUMINANCE_ALPHA                              int `js:"LUMINANCE_ALPHA"`
	MAX_COMBINED_TEXTURE_IMAGE_UNITS             int `js:"MAX_COMBINED_TEXTURE_IMAGE_UNITS"`
	MAX_CUBE_MAP_TEXTURE_SIZE                    int `js:"MAX_CUBE_MAP_TEXTURE_SIZE"`
	MAX_FRAGMENT_UNIFORM_VECTORS                 int `js:"MAX_FRAGMENT_UNIFORM_VECTORS"`
	MAX_RENDERBUFFER_SIZE                        int `js:"MAX_RENDERBUFFER_SIZE"`
	MAX_TEXTURE_IMAGE_UNITS                      int `js:"MAX_TEXTURE_IMAGE_UNITS"`
	MAX_TEXTURE_SIZE                             int `js:"MAX_TEXTURE_SIZE"`
	MAX_VARYING_VECTORS                          int `js:"MAX_VARYING_VECTORS"`
	MAX_VERTEX_ATTRIBS                           int `js:"MAX_VERTEX_ATTRIBS"`
	MAX_VERTEX_TEXTURE_IMAGE_UNITS               int `js:"MAX_VERTEX_TEXTURE_IMAGE_UNITS"`
	MAX_VERTEX_UNIFORM_VECTORS                   int `js:"MAX_VERTEX_UNIFORM_VECTORS"`
	MAX_VIEWPORT_DIMS                            int `js:"MAX_VIEWPORT_DIMS"`
	MEDIUM_FLOAT                                 int `js:"MEDIUM_FLOAT"`
	MEDIUM_INT                                   int `js:"MEDIUM_INT"`
	MIRRORED_REPEAT                              int `js:"MIRRORED_REPEAT"`
	NEAREST                                      int `js:"NEAREST"`
	NEAREST_MIPMAP_LINEAR                        int `js:"NEAREST_MIPMAP_LINEAR"`
	NEAREST_MIPMAP_NEAREST                       int `js:"NEAREST_MIPMAP_NEAREST"`
	NEVER                                        int `js:"NEVER"`
	NICEST                                       int `js:"NICEST"`
	NONE                                         int `js:"NONE"`
	NOTEQUAL                                     int `js:"NOTEQUAL"`
	NO_ERROR                                     int `js:"NO_ERROR"`
	NUM_COMPRESSED_TEXTURE_FORMATS               int `js:"NUM_COMPRESSED_TEXTURE_FORMATS"`
	ONE                                          int `js:"ONE"`
	ONE_MINUS_CONSTANT_ALPHA                     int `js:"ONE_MINUS_CONSTANT_ALPHA"`
	ONE_MINUS_CONSTANT_COLOR                     int `js:"ONE_MINUS_CONSTANT_COLOR"`
	ONE_MINUS_DST_ALPHA                          int `js:"ONE_MINUS_DST_ALPHA"`
	ONE_MINUS_DST_COLOR                          int `js:"ONE_MINUS_DST_COLOR"`
	ONE_MINUS_SRC_ALPHA                          int `js:"ONE_MINUS_SRC_ALPHA"`
	ONE_MINUS_SRC_COLOR                          int `js:"ONE_MINUS_SRC_COLOR"`
	OUT_OF_MEMORY                                int `js:"OUT_OF_MEMORY"`
	PACK_ALIGNMENT                               int `js:"PACK_ALIGNMENT"`
	POINTS                                       int `js:"POINTS"`
	POLYGON_OFFSET_FACTOR                        int `js:"POLYGON_OFFSET_FACTOR"`
	POLYGON_OFFSET_FILL                          int `js:"POLYGON_OFFSET_FILL"`
	POLYGON_OFFSET_UNITS                         int `js:"POLYGON_OFFSET_UNITS"`
	READ_FRAMEBUFFER                             int `js:"READ_FRAMEBUFFER"`
	RED_BITS                                     int `js:"RED_BITS"`
	RENDERBUFFER                                 int `js:"RENDERBUFFER"`
	RENDERBUFFER_ALPHA_SIZE                      int `js:"RENDERBUFFER_ALPHA_SIZE"`
	RENDERBUFFER_BINDING                         int `js:"RENDERBUFFER_BINDING"`
	RENDERBUFFER_BLUE_SIZE                       int `js:"RENDERBUFFER_BLUE_SIZE"`
	RENDERBUFFER_DEPTH_SIZE                      int `js:"RENDERBUFFER_DEPTH_SIZE"`
	RENDERBUFFER_GREEN_SIZE                      int `js:"RENDERBUFFER_GREEN_SIZE"`
	RENDERBUFFER_HEIGHT                          int `js:"RENDERBUFFER_HEIGHT"`
	RENDERBUFFER_INTERNAL_FORMAT                 int `js:"RENDERBUFFER_INTERNAL_FORMAT"`
	RENDERBUFFER_RED_SIZE                        int `js:"RENDERBUFFER_RED_SIZE"`
	RENDERBUFFER_STENCIL_SIZE                    int `js:"RENDERBUFFER_STENCIL_SIZE"`
	RENDERBUFFER_WIDTH                           int `js:"RENDERBUFFER_WIDTH"`
	RENDERER                                     int `js:"RENDERER"`
	REPEAT                                       int `js:"REPEAT"`
	REPLACE                                      int `js:"REPLACE"`
	RGB                                          int `js:"RGB"`
	RGB5_A1                                      int `js:"RGB5_A1"`
	RGB565                                       int `js:"RGB565"`
	RGBA                                         int `js:"RGBA"`
	RGBA4                                        int `js:"RGBA4"`
	SAMPLER_2D                                   int `js:"SAMPLER_2D"`
	SAMPLER_CUBE                                 int `js:"SAMPLER_CUBE"`
	SAMPLES                                      int `js:"SAMPLES"`
	SAMPLE_ALPHA_TO_COVERAGE                     int `js:"SAMPLE_ALPHA_TO_COVERAGE"`
	SAMPLE_BUFFERS                               int `js:"SAMPLE_BUFFERS"`
	SAMPLE_COVERAGE                              int `js:"SAMPLE_COVERAGE"`
	SAMPLE_COVERAGE_INVERT                       int `js:"SAMPLE_COVERAGE_INVERT"`
	SAMPLE_COVERAGE_VALUE                        int `js:"SAMPLE_COVERAGE_VALUE"`
	SCISSOR_BOX                                  int `js:"SCISSOR_BOX"`
	SCISSOR_TEST                                 int `js:"SCISSOR_TEST"`
	SHADER_COMPILER                              int `js:"SHADER_COMPILER"`
	SHADER_SOURCE_LENGTH                         int `js:"SHADER_SOURCE_LENGTH"`
	SHADER_TYPE                                  int `js:"SHADER_TYPE"`
	SHADING_LANGUAGE_VERSION                     int `js:"SHADING_LANGUAGE_VERSION"`
	SHORT                                        int `js:"SHORT"`
	SRC_ALPHA                                    int `js:"SRC_ALPHA"`
	SRC_ALPHA_SATURATE                           int `js:"SRC_ALPHA_SATURATE"`
	SRC_COLOR                                    int `js:"SRC_COLOR"`
	STATIC_DRAW                                  int `js:"STATIC_DRAW"`
	STENCIL_ATTACHMENT                           int `js:"STENCIL_ATTACHMENT"`
	STENCIL_BACK_FAIL                            int `js:"STENCIL_BACK_FAIL"`
	STENCIL_BACK_FUNC                            int `js:"STENCIL_BACK_FUNC"`
	STENCIL_BACK_PASS_DEPTH_FAIL                 int `js:"STENCIL_BACK_PASS_DEPTH_FAIL"`
	STENCIL_BACK_PASS_DEPTH_PASS                 int `js:"STENCIL_BACK_PASS_DEPTH_PASS"`
	STENCIL_BACK_REF                             int `js:"STENCIL_BACK_REF"`
	STENCIL_BACK_VALUE_MASK                      int `js:"STENCIL_BACK_VALUE_MASK"`
	STENCIL_BACK_WRITEMASK                       int `js:"STENCIL_BACK_WRITEMASK"`
	STENCIL_BITS                                 int `js:"STENCIL_BITS"`
	STENCIL_BUFFER_BIT                           int `js:"STENCIL_BUFFER_BIT"`
	STENCIL_CLEAR_VALUE                          int `js:"STENCIL_CLEAR_VALUE"`
	STENCIL_FAIL                                 int `js:"STENCIL_FAIL"`
	STENCIL_FUNC                                 int `js:"STENCIL_FUNC"`
	STENCIL_INDEX                                int `js:"STENCIL_INDEX"`
	STENCIL_INDEX8                               int `js:"STENCIL_INDEX8"`
	STENCIL_PASS_DEPTH_FAIL                      int `js:"STENCIL_PASS_DEPTH_FAIL"`
	STENCIL_PASS_DEPTH_PASS                      int `js:"STENCIL_PASS_DEPTH_PASS"`
	STENCIL_REF                                  int `js:"STENCIL_REF"`
	STENCIL_TEST                                 int `js:"STENCIL_TEST"`
	STENCIL_VALUE_MASK                           int `js:"STENCIL_VALUE_MASK"`
	STENCIL_WRITEMASK                            int `js:"STENCIL_WRITEMASK"`
	STREAM_DRAW                                  int `js:"STREAM_DRAW"`
	SUBPIXEL_BITS                                int `js:"SUBPIXEL_BITS"`
	TEXTURE                                      int `js:"TEXTURE"`
	TEXTURE0                                     int `js:"TEXTURE0"`
	TEXTURE1                                     int `js:"TEXTURE1"`
	TEXTURE2                                     int `js:"TEXTURE2"`
	TEXTURE3                                     int `js:"TEXTURE3"`
	TEXTURE4                                     int `js:"TEXTURE4"`
	TEXTURE5                                     int `js:"TEXTURE5"`
	TEXTURE6                                     int `js:"TEXTURE6"`
	TEXTURE7                                     int `js:"TEXTURE7"`
	TEXTURE8                                     int `js:"TEXTURE8"`
	TEXTURE9                                     int `js:"TEXTURE9"`
	TEXTURE10                                    int `js:"TEXTURE10"`
	TEXTURE11                                    int `js:"TEXTURE11"`
	TEXTURE12                                    int `js:"TEXTURE12"`
	TEXTURE13                                    int `js:"TEXTURE13"`
	TEXTURE14                                    int `js:"TEXTURE14"`
	TEXTURE15                                    int `js:"TEXTURE15"`
	TEXTURE16                                    int `js:"TEXTURE16"`
	TEXTURE17                                    int `js:"TEXTURE17"`
	TEXTURE18                                    int `js:"TEXTURE18"`
	TEXTURE19                                    int `js:"TEXTURE19"`
	TEXTURE20                                    int `js:"TEXTURE20"`
	TEXTURE21                                    int `js:"TEXTURE21"`
	TEXTURE22                                    int `js:"TEXTURE22"`
	TEXTURE23                                    int `js:"TEXTURE23"`
	TEXTURE24                                    int `js:"TEXTURE24"`
	TEXTURE25                                    int `js:"TEXTURE25"`
	TEXTURE26                                    int `js:"TEXTURE26"`
	TEXTURE27                                    int `js:"TEXTURE27"`
	TEXTURE28                                    int `js:"TEXTURE28"`
	TEXTURE29                                    int `js:"TEXTURE29"`
	TEXTURE30                                    int `js:"TEXTURE30"`
	TEXTURE31                                    int `js:"TEXTURE31"`
	TEXTURE_2D                                   int `js:"TEXTURE_2D"`
	TEXTURE_BINDING_2D                           int `js:"TEXTURE_BINDING_2D"`
	TEXTURE_BINDING_CUBE_MAP                     int `js:"TEXTURE_BINDING_CUBE_MAP"`
	TEXTURE_CUBE_MAP                             int `js:"TEXTURE_CUBE_MAP"`
	TEXTURE_CUBE_MAP_NEGATIVE_X                  int `js:"TEXTURE_CUBE_MAP_NEGATIVE_X"`
	TEXTURE_CUBE_MAP_NEGATIVE_Y                  int `js:"TEXTURE_CUBE_MAP_NEGATIVE_Y"`
	TEXTURE_CUBE_MAP_NEGATIVE_Z                  int `js:"TEXTURE_CUBE_MAP_NEGATIVE_Z"`
	TEXTURE_CUBE_MAP_POSITIVE_X                  int `js:"TEXTURE_CUBE_MAP_POSITIVE_X"`
	TEXTURE_CUBE_MAP_POSITIVE_Y                  int `js:"TEXTURE_CUBE_MAP_POSITIVE_Y"`
	TEXTURE_CUBE_MAP_POSITIVE_Z                  int `js:"TEXTURE_CUBE_MAP_POSITIVE_Z"`
	TEXTURE_MAG_FILTER                           int `js:"TEXTURE_MAG_FILTER"`
	TEXTURE_MIN_FILTER                           int `js:"TEXTURE_MIN_FILTER"`
	TEXTURE_WRAP_S                               int `js:"TEXTURE_WRAP_S"`
	TEXTURE_WRAP_T                               int `js:"TEXTURE_WRAP_T"`
	TRIANGLES                                    int `js:"TRIANGLES"`
	TRIANGLE_FAN                                 int `js:"TRIANGLE_FAN"`
	TRIANGLE_STRIP                               int `js:"TRIANGLE_STRIP"`
	UNPACK_ALIGNMENT                             int `js:"UNPACK_ALIGNMENT"`
	UNPACK_COLORSPACE_CONVERSION_WEBGL           int `js:"UNPACK_COLORSPACE_CONVERSION_WEBGL"`
	UNPACK_FLIP_Y_WEBGL                          int `js:"UNPACK_FLIP_Y_WEBGL"`
	UNPACK_PREMULTIPLY_ALPHA_WEBGL               int `js:"UNPACK_PREMULTIPLY_ALPHA_WEBGL"`
	UNSIGNED_BYTE                                int `js:"UNSIGNED_BYTE"`
	UNSIGNED_INT                                 int `js:"UNSIGNED_INT"`
	UNSIGNED_SHORT                               int `js:"UNSIGNED_SHORT"`
	UNSIGNED_SHORT_4_4_4_4                       int `js:"UNSIGNED_SHORT_4_4_4_4"`
	UNSIGNED_SHORT_5_5_5_1                       int `js:"UNSIGNED_SHORT_5_5_5_1"`
	UNSIGNED_SHORT_5_6_5                         int `js:"UNSIGNED_SHORT_5_6_5"`
	VALIDATE_STATUS                              int `js:"VALIDATE_STATUS"`
	VENDOR                                       int `js:"VENDOR"`
	VERSION                                      int `js:"VERSION"`
	VERTEX_ATTRIB_ARRAY_BUFFER_BINDING           int `js:"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING"`
	VERTEX_ATTRIB_ARRAY_ENABLED                  int `js:"VERTEX_ATTRIB_ARRAY_ENABLED"`
	VERTEX_ATTRIB_ARRAY_NORMALIZED               int `js:"VERTEX_ATTRIB_ARRAY_NORMALIZED"`
	VERTEX_ATTRIB_ARRAY_POINTER                  int `js:"VERTEX_ATTRIB_ARRAY_POINTER"`
	VERTEX_ATTRIB_ARRAY_SIZE                     int `js:"VERTEX_ATTRIB_ARRAY_SIZE"`
	VERTEX_ATTRIB_ARRAY_STRIDE                   int `js:"VERTEX_ATTRIB_ARRAY_STRIDE"`
	VERTEX_ATTRIB_ARRAY_TYPE                     int `js:"VERTEX_ATTRIB_ARRAY_TYPE"`
	VERTEX_SHADER                                int `js:"VERTEX_SHADER"`
	VIEWPORT                                     int `js:"VIEWPORT"`
	ZERO                                         int `js:"ZERO"`
	FALSE                                        int
	TRUE                                         int
}

func NewContext

func NewContext(canvas *js.Object, ca *ContextAttributes) (*Context, error)

NewContext takes an HTML5 canvas object and optional context attributes. If an error is returned it means you won't have access to WebGL functionality.

func (*Context) ActiveTexture

func (c *Context) ActiveTexture(texture int)

Specifies the active texture unit.

func (*Context) AttachShader

func (c *Context) AttachShader(program *js.Object, shader *js.Object)

Attaches a WebGLShader object to a WebGLProgram object.

func (*Context) BindAttribLocation

func (c *Context) BindAttribLocation(program *js.Object, index int, name string)

Binds a generic vertex index to a user-defined attribute variable.

func (*Context) BindBuffer

func (c *Context) BindBuffer(target int, buffer *js.Object)

Associates a buffer with a buffer target.

func (*Context) BindFramebuffer

func (c *Context) BindFramebuffer(target int, framebuffer *js.Object)

Associates a WebGLFramebuffer object with the FRAMEBUFFER bind target.

func (*Context) BindRenderbuffer

func (c *Context) BindRenderbuffer(target int, renderbuffer *js.Object)

Binds a WebGLRenderbuffer object to be used for rendering.

func (*Context) BindTexture

func (c *Context) BindTexture(target int, texture *js.Object)

Binds a named texture object to a target.

func (*Context) BindVertexArray

func (c *Context) BindVertexArray(vertexArray *js.Object)

func (*Context) BlendColor

func (c *Context) BlendColor(r, g, b, a float64)

The GL_BLEND_COLOR may be used to calculate the source and destination blending factors.

func (*Context) BlendEquation

func (c *Context) BlendEquation(mode int)

Sets the equation used to blend RGB and Alpha values of an incoming source fragment with a destination values as stored in the fragment's frame buffer.

func (*Context) BlendEquationSeparate

func (c *Context) BlendEquationSeparate(modeRGB, modeAlpha int)

Controls the blending of an incoming source fragment's R, G, B, and A values with a destination R, G, B, and A values as stored in the fragment's WebGLFramebuffer.

func (*Context) BlendFunc

func (c *Context) BlendFunc(sfactor, dfactor int)

Sets the blending factors used to combine source and destination pixels.

func (*Context) BlendFuncSeparate

func (c *Context) BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha int)

Sets the weighting factors that are used by blendEquationSeparate.

func (*Context) BlitFramebuffer

func (c *Context) BlitFramebuffer(rcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter int)

func (*Context) BufferData

func (c *Context) BufferData(target, size int, data interface{}, usage int)

Creates a buffer in memory and initializes it with array data. If no array is provided, the contents of the buffer is initialized to size.

func (*Context) BufferSubData

func (c *Context) BufferSubData(target int, offset int, data interface{})

Used to modify or update some or all of a data store for a bound buffer object.

func (*Context) CheckFramebufferStatus

func (c *Context) CheckFramebufferStatus(target int) int

Returns whether the currently bound WebGLFramebuffer is complete. If not complete, returns the reason why.

func (*Context) Clear

func (c *Context) Clear(flags int)

Sets all pixels in a specific buffer to the same value.

func (*Context) ClearColor

func (c *Context) ClearColor(r, g, b, a float32)

Specifies color values to use by the clear method to clear the color buffer.

func (*Context) ClearDepth

func (c *Context) ClearDepth(depth float64)

Clears the depth buffer to a specific value.

func (*Context) ClearStencil

func (c *Context) ClearStencil(s int)

func (*Context) ColorMask

func (c *Context) ColorMask(r, g, b, a bool)

Lets you set whether individual colors can be written when drawing or rendering to a framebuffer.

func (*Context) CompileShader

func (c *Context) CompileShader(shader *js.Object)

Compiles the GLSL shader source into binary data used by the WebGLProgram object.

func (*Context) CopyBufferSubData

func (c *Context) CopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size int)

func (*Context) CopyTexImage2D

func (c *Context) CopyTexImage2D(target, level, internal, x, y, w, h, border int)

Copies a rectangle of pixels from the current WebGLFramebuffer into a texture image.

func (*Context) CopyTexSubImage2D

func (c *Context) CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, w, h int)

Replaces a portion of an existing 2D texture image with data from the current framebuffer.

func (*Context) CreateBuffer

func (c *Context) CreateBuffer() *js.Object

Creates and initializes a WebGLBuffer.

func (*Context) CreateFramebuffer

func (c *Context) CreateFramebuffer() *js.Object

Returns a WebGLFramebuffer object.

func (*Context) CreateProgram

func (c *Context) CreateProgram() *js.Object

Creates an empty WebGLProgram object to which vector and fragment WebGLShader objects can be bound.

func (*Context) CreateRenderbuffer

func (c *Context) CreateRenderbuffer() *js.Object

Creates and returns a WebGLRenderbuffer object.

func (*Context) CreateShader

func (c *Context) CreateShader(typ int) *js.Object

Returns an empty vertex or fragment shader object based on the type specified.

func (*Context) CreateTexture

func (c *Context) CreateTexture() *js.Object

Used to generate a WebGLTexture object to which images can be bound.

func (*Context) CreateVertexArray

func (c *Context) CreateVertexArray() *js.Object

func (*Context) CullFace

func (c *Context) CullFace(mode int)

Sets whether or not front, back, or both facing facets are able to be culled.

func (*Context) DeleteBuffer

func (c *Context) DeleteBuffer(buffer *js.Object)

Delete a specific buffer.

func (*Context) DeleteFramebuffer

func (c *Context) DeleteFramebuffer(framebuffer *js.Object)

Deletes a specific WebGLFramebuffer object. If you delete the currently bound framebuffer, the default framebuffer will be bound. Deleting a framebuffer detaches all of its attachments.

func (*Context) DeleteProgram

func (c *Context) DeleteProgram(program *js.Object)

Flags a specific WebGLProgram object for deletion if currently active. It will be deleted when it is no longer being used. Any shader objects associated with the program will be detached. They will be deleted if they were already flagged for deletion.

func (*Context) DeleteRenderbuffer

func (c *Context) DeleteRenderbuffer(renderbuffer *js.Object)

Deletes the specified renderbuffer object. If the renderbuffer is currently bound, it will become unbound. If the renderbuffer is attached to the currently bound framebuffer, it is detached.

func (*Context) DeleteShader

func (c *Context) DeleteShader(shader *js.Object)

Deletes a specific shader object.

func (*Context) DeleteTexture

func (c *Context) DeleteTexture(texture *js.Object)

Deletes a specific texture object.

func (*Context) DeleteVertexArray

func (c *Context) DeleteVertexArray(vertexArray *js.Object)

func (*Context) DepthFunc

func (c *Context) DepthFunc(fun int)

Sets a function to use to compare incoming pixel depth to the current depth buffer value.

func (*Context) DepthMask

func (c *Context) DepthMask(flag bool)

Sets whether or not you can write to the depth buffer.

func (*Context) DepthRange

func (c *Context) DepthRange(zNear, zFar float64)

Sets the depth range for normalized coordinates to canvas or viewport depth coordinates.

func (*Context) DetachShader

func (c *Context) DetachShader(program, shader *js.Object)

Detach a shader object from a program object.

func (*Context) Disable

func (c *Context) Disable(cap int)

Turns off specific WebGL capabilities for this context.

func (*Context) DisableVertexAttribArray

func (c *Context) DisableVertexAttribArray(index int)

Turns off a vertex attribute array at a specific index position.

func (*Context) DrawArrays

func (c *Context) DrawArrays(mode, first, count int)

Render geometric primitives from bound and enabled vertex data.

func (*Context) DrawBuffers

func (c *Context) DrawBuffers(buffers []int)

func (*Context) DrawElements

func (c *Context) DrawElements(mode, count, typ, offset int)

Renders geometric primitives indexed by element array data.

func (*Context) DrawElementsInstanced

func (c *Context) DrawElementsInstanced(mode, count, typ, offset, instanceCount int)

Renders multiple instances of the same buffer indexed by element array data

func (*Context) Enable

func (c *Context) Enable(cap int)

Turns on specific WebGL capabilities for this context.

func (*Context) EnableVertexAttribArray

func (c *Context) EnableVertexAttribArray(index int)

Turns on a vertex attribute at a specific index position in a vertex attribute array.

func (*Context) Finish

func (c *Context) Finish()

func (*Context) Flush

func (c *Context) Flush()

func (*Context) FramebufferRenderbuffer

func (c *Context) FramebufferRenderbuffer(target, attachment, renderbufferTarget int, renderbuffer *js.Object)

Attaches a WebGLRenderbuffer object as a logical buffer to the currently bound WebGLFramebuffer object.

func (*Context) FramebufferTexture2D

func (c *Context) FramebufferTexture2D(target, attachment, textarget int, texture *js.Object, level int)

Attaches a texture to a WebGLFramebuffer object.

func (*Context) FrontFace

func (c *Context) FrontFace(mode int)

Sets whether or not polygons are considered front-facing based on their winding direction.

func (*Context) GenerateMipmap

func (c *Context) GenerateMipmap(target int)

Creates a set of textures for a WebGLTexture object with image dimensions from the original size of the image down to a 1x1 image.

func (*Context) GetActiveAttrib

func (c *Context) GetActiveAttrib(program *js.Object, index int) *js.Object

Returns an WebGLActiveInfo object containing the size, type, and name of a vertex attribute at a specific index position in a program object.

func (*Context) GetActiveUniform

func (c *Context) GetActiveUniform(program *js.Object, index int) *js.Object

Returns an WebGLActiveInfo object containing the size, type, and name of a uniform attribute at a specific index position in a program object.

func (*Context) GetAttachedShaders

func (c *Context) GetAttachedShaders(program *js.Object) []*js.Object

Returns a slice of WebGLShaders bound to a WebGLProgram.

func (*Context) GetAttribLocation

func (c *Context) GetAttribLocation(program *js.Object, name string) int

Returns an index to the location in a program of a named attribute variable.

func (*Context) GetBufferParameter

func (c *Context) GetBufferParameter(target, pname int) *js.Object

TODO: Create type specific variations. Returns the type of a parameter for a given buffer.

func (*Context) GetContextAttributes

func (c *Context) GetContextAttributes() ContextAttributes

Returns the context attributes active on the context. These values might be different than what was requested on context creation if the browser's implementation doesn't support a feature.

func (*Context) GetError

func (c *Context) GetError() int

Returns a value for the WebGL error flag and clears the flag.

func (*Context) GetExtension

func (c *Context) GetExtension(name string) *js.Object

TODO: Create type specific variations. Enables a passed extension, otherwise returns null.

func (*Context) GetFramebufferAttachmentParameter

func (c *Context) GetFramebufferAttachmentParameter(target, attachment, pname int) *js.Object

TODO: Create type specific variations. Gets a parameter value for a given target and attachment.

func (*Context) GetIntegerv

func (c *Context) GetIntegerv(pname int) []int

Returns the integer array value for a constant parameter

func (*Context) GetParameter

func (c *Context) GetParameter(pname int) *js.Object

TODO: Create type specific variations. Returns the natural type value for a constant parameter.

func (*Context) GetProgramInfoLog

func (c *Context) GetProgramInfoLog(program *js.Object) string

Returns information about the last error that occurred during the failed linking or validation of a WebGL program object.

func (*Context) GetProgramParameter

func (c *Context) GetProgramParameter(program *js.Object, pname int) *js.Object

func (*Context) GetProgramb

func (c *Context) GetProgramb(program *js.Object, pname int) bool

Returns the value of the program parameter that corresponds to a supplied pname which is interpreted as a bool.

func (*Context) GetProgrami

func (c *Context) GetProgrami(program *js.Object, pname int) int

Returns the value of the program parameter that corresponds to a supplied pname which is interpreted as an int.

func (*Context) GetProgramiv

func (c *Context) GetProgramiv(program *js.Object, pname int) []int

Returns the value of the program parameter that corresponds to a supplied pname which is interpreted as an int.

func (*Context) GetRenderbufferParameter

func (c *Context) GetRenderbufferParameter(target, pname int) *js.Object

TODO: Create type specific variations. Returns a renderbuffer parameter from the currently bound WebGLRenderbuffer object.

func (*Context) GetShaderInfoLog

func (c *Context) GetShaderInfoLog(shader *js.Object) string

Returns errors which occur when compiling a shader.

func (*Context) GetShaderParameter

func (c *Context) GetShaderParameter(shader *js.Object, pname int) *js.Object

TODO: Create type specific variations. Returns the value of the parameter associated with pname for a shader object.

func (*Context) GetShaderSource

func (c *Context) GetShaderSource(shader *js.Object) string

Returns source code string associated with a shader object.

func (*Context) GetShaderb

func (c *Context) GetShaderb(shader *js.Object, pname int) bool

Returns the value of the parameter associated with pname for a shader object.

func (*Context) GetShaderiv

func (c *Context) GetShaderiv(shader *js.Object, pname int) []int

func (*Context) GetString

func (c *Context) GetString(pname int) string

Returns the string value for a constant parameter

func (*Context) GetSupportedExtensions

func (c *Context) GetSupportedExtensions() []string

Returns a slice of supported extension strings.

func (*Context) GetTexParameter

func (c *Context) GetTexParameter(target, pname int) *js.Object

TODO: Create type specific variations. Returns the value for a parameter on an active texture unit.

func (*Context) GetUniform

func (c *Context) GetUniform(program, location *js.Object) *js.Object

TODO: Create type specific variations. Gets the uniform value for a specific location in a program.

func (*Context) GetUniformLocation

func (c *Context) GetUniformLocation(program *js.Object, name string) *js.Object

Returns a WebGLUniformLocation object for the location of a uniform variable within a WebGLProgram object.

func (*Context) GetVersioni

func (c *Context) GetVersioni() int

func (*Context) GetVertexAttrib

func (c *Context) GetVertexAttrib(index, pname int) *js.Object

TODO: Create type specific variations. Returns data for a particular characteristic of a vertex attribute at an index in a vertex attribute array.

func (*Context) GetVertexAttribOffset

func (c *Context) GetVertexAttribOffset(index, pname int) int

Returns the address of a specified vertex attribute.

func (*Context) IsBuffer

func (c *Context) IsBuffer(buffer *js.Object) bool

Returns true if buffer is valid, false otherwise.

func (*Context) IsContextLost

func (c *Context) IsContextLost() bool

Returns whether the WebGL context has been lost.

func (*Context) IsEnabled

func (c *Context) IsEnabled(capability int) bool

Returns whether or not a WebGL capability is enabled for this context.

func (*Context) IsFramebuffer

func (c *Context) IsFramebuffer(framebuffer *js.Object) bool

Returns true if buffer is valid, false otherwise.

func (*Context) IsProgram

func (c *Context) IsProgram(program *js.Object) bool

Returns true if program object is valid, false otherwise.

func (*Context) IsRenderbuffer

func (c *Context) IsRenderbuffer(renderbuffer *js.Object) bool

Returns true if buffer is valid, false otherwise.

func (*Context) IsShader

func (c *Context) IsShader(shader *js.Object) bool

Returns true if shader is valid, false otherwise.

func (*Context) IsTexture

func (c *Context) IsTexture(texture *js.Object) bool

Returns true if texture is valid, false otherwise.

func (*Context) LineWidth

func (c *Context) LineWidth(width float64)

Sets the width of lines in WebGL.

func (*Context) LinkProgram

func (c *Context) LinkProgram(program *js.Object)

Links an attached vertex shader and an attached fragment shader to a program so it can be used by the graphics processing unit (GPU).

func (*Context) PixelStorei

func (c *Context) PixelStorei(pname, param int)

Sets pixel storage modes for readPixels and unpacking of textures with texImage2D and texSubImage2D.

func (*Context) PolygonOffset

func (c *Context) PolygonOffset(factor, units float64)

Sets the implementation-specific units and scale factor used to calculate fragment depth values.

func (*Context) PtrOffset

func (c *Context) PtrOffset(offset int) int

A function for compatibility with go-gl

func (*Context) ReadBuffer

func (c *Context) ReadBuffer(src int)

func (*Context) ReadPixels

func (c *Context) ReadPixels(x, y, width, height, format, typ int, pixels *js.Object)

TODO: Figure out if pixels should be a slice. Reads pixel data into an ArrayBufferView object from a rectangular area in the color buffer of the active frame buffer.

func (*Context) RenderbufferStorage

func (c *Context) RenderbufferStorage(target, internalFormat, width, height int)

Creates or replaces the data store for the currently bound WebGLRenderbuffer object.

func (*Context) Scissor

func (c *Context) Scissor(x, y, width, height int)

Sets the dimensions of the scissor box.

func (*Context) ShaderSource

func (c *Context) ShaderSource(shader *js.Object, source string)

Sets and replaces shader source code in a shader object.

func (*Context) TexImage2D

func (c *Context) TexImage2D(target, level, internalFormat, width, height, border, format, kind int, pixels *js.Object)

Loads the supplied pixel data into a texture.

func (*Context) TexParameteri

func (c *Context) TexParameteri(target int, pname int, param int)

Sets texture parameters for the current texture unit.

func (*Context) TexSubImage2D

func (c *Context) TexSubImage2D(target, level, xoffset, yoffset, format, typ int, image *js.Object)

Replaces a portion of an existing 2D texture image with all of another image.

func (*Context) Uniform1f

func (c *Context) Uniform1f(location *js.Object, x float32)

Assigns a floating point value to a uniform variable for the current program object.

func (*Context) Uniform1i

func (c *Context) Uniform1i(location *js.Object, x int)

Assigns a integer value to a uniform variable for the current program object.

func (*Context) Uniform2f

func (c *Context) Uniform2f(location *js.Object, x, y float32)

Assigns 2 floating point values to a uniform variable for the current program object.

func (*Context) Uniform2i

func (c *Context) Uniform2i(location *js.Object, x, y int)

Assigns 2 integer values to a uniform variable for the current program object.

func (*Context) Uniform3f

func (c *Context) Uniform3f(location *js.Object, x, y, z float32)

Assigns 3 floating point values to a uniform variable for the current program object.

func (*Context) Uniform3i

func (c *Context) Uniform3i(location *js.Object, x, y, z int)

Assigns 3 integer values to a uniform variable for the current program object.

func (*Context) Uniform4f

func (c *Context) Uniform4f(location *js.Object, x, y, z, w float32)

Assigns 4 floating point values to a uniform variable for the current program object.

func (*Context) Uniform4i

func (c *Context) Uniform4i(location *js.Object, x, y, z, w int)

Assigns 4 integer values to a uniform variable for the current program object.

func (*Context) UniformMatrix2fv

func (c *Context) UniformMatrix2fv(location *js.Object, transpose bool, value []float32)

Sets values for a 2x2 floating point vector matrix into a uniform location as a matrix or a matrix array.

func (*Context) UniformMatrix3fv

func (c *Context) UniformMatrix3fv(location *js.Object, transpose bool, value []float32)

Sets values for a 3x3 floating point vector matrix into a uniform location as a matrix or a matrix array.

func (*Context) UniformMatrix4fv

func (c *Context) UniformMatrix4fv(location *js.Object, transpose bool, value []float32)

Sets values for a 4x4 floating point vector matrix into a uniform location as a matrix or a matrix array.

func (*Context) UseProgram

func (c *Context) UseProgram(program *js.Object)

Set the program object to use for rendering.

func (*Context) ValidateProgram

func (c *Context) ValidateProgram(program *js.Object)

Returns whether a given program can run in the current WebGL state.

func (*Context) VertexAttribDivisor

func (c *Context) VertexAttribDivisor(index, divisor int)

func (*Context) VertexAttribPointer

func (c *Context) VertexAttribPointer(index, size, typ int, normal bool, stride int, offset int)

func (*Context) Viewport

func (c *Context) Viewport(x, y, width, height int)

Represents a rectangular viewable area that contains the rendering results of the drawing buffer.

type ContextAttributes

type ContextAttributes struct {
	// If Alpha is true, the drawing buffer has an alpha channel for
	// the purposes of performing OpenGL destination alpha operations
	// and compositing with the page.
	Alpha bool

	// If Depth is true, the drawing buffer has a depth buffer of at least 16 bits.
	Depth bool

	// If Stencil is true, the drawing buffer has a stencil buffer of at least 8 bits.
	Stencil bool

	// If Antialias is true and the implementation supports antialiasing
	// the drawing buffer will perform antialiasing using its choice of
	// technique (multisample/supersample) and quality.
	Antialias bool

	// If PremultipliedAlpha is true the page compositor will assume the
	// drawing buffer contains colors with premultiplied alpha.
	// This flag is ignored if the alpha flag is false.
	PremultipliedAlpha bool

	// If the value is true the buffers will not be cleared and will preserve
	// their values until cleared or overwritten by the author.
	PreserveDrawingBuffer bool
}

func DefaultAttributes

func DefaultAttributes() *ContextAttributes

Returns a copy of the default WebGL context attributes.

Jump to

Keyboard shortcuts

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