Categorygithub.com/goxjs/gl
modulepackage
0.0.0-20230705020350-37525f4d9d35
Repository: https://github.com/goxjs/gl.git
Documentation: pkg.go.dev

# README

gl

Go Reference

Package gl is a Go cross-platform binding for OpenGL, with an OpenGL ES 2-like API.

It supports:

  • macOS, Linux and Windows via OpenGL 2.1 backend,

  • iOS and Android via OpenGL ES 2.0 backend,

  • Modern Browsers (desktop and mobile) via WebGL 1.0 backend.

This is a fork of golang.org/x/mobile/gl package with CL 8793 merged in and Windows support added. This package is fully functional, but may eventually become superceded by the new x/mobile/gl plan. It will exist and be fully supported until it can be safely replaced by a better package.

Installation

go get github.com/goxjs/gl

Usage

This OpenGL binding has a ContextWatcher, which implements glfw.ContextWatcher interface. Recommended usage is with github.com/goxjs/glfw package, which accepts a ContextWatcher in its Init, and takes on the responsibility of notifying it when context is made current or detached.

if err := glfw.Init(gl.ContextWatcher); err != nil {
	// Handle error.
}
defer glfw.Terminate()

If you're not using a ContextWatcher-aware glfw library, you must call methods of gl.ContextWatcher yourself whenever you make a context current or detached.

window.MakeContextCurrent()
gl.ContextWatcher.OnMakeCurrent(nil)

glfw.DetachCurrentContext()
gl.ContextWatcher.OnDetach()

Directories

PathSynopsis
glutilPackage glutil implements OpenGL utility functions.
testPackage test contains tests for goxjs/gl.

License

# Packages

Package glutil implements OpenGL utility functions.
Package test contains tests for goxjs/gl.

# Functions

ActiveTexture sets the active texture unit.
AttachShader attaches a shader to a program.
BindAttribLocation binds a vertex attribute index with a named variable.
BindBuffer binds a buffer.
BindFramebuffer binds a framebuffer.
BindRenderbuffer binds a render buffer.
BindTexture binds a texture.
BlendColor sets the blend color.
BlendEquation sets both RGB and alpha blend equations.
BlendEquationSeparate sets RGB and alpha blend equations separately.
BlendFunc sets the pixel blending factors.
BlendFunc sets the pixel RGB and alpha blending factors separately.
BufferData creates a new data store for the bound buffer object.
BufferInit creates a new unitialized data store for the bound buffer object.
BufferSubData sets some of data in the bound buffer object.
CheckFramebufferStatus reports the completeness status of the active framebuffer.
Clear clears the window.
ClearColor specifies the RGBA values used to clear color buffers.
ClearDepthf sets the depth value used to clear the depth buffer.
ClearStencil sets the index used to clear the stencil buffer.
ColorMask specifies whether color components in the framebuffer can be written.
CompileShader compiles the source code of s.
CompressedTexImage2D writes a compressed 2D texture.
CompressedTexSubImage2D writes a subregion of a compressed 2D texture.
CopyTexImage2D writes a 2D texture from the current framebuffer.
CopyTexSubImage2D writes a 2D texture subregion from the current framebuffer.
CreateBuffer creates a buffer object.
CreateFramebuffer creates a framebuffer object.
CreateProgram creates a new empty program object.
CreateRenderbuffer create a renderbuffer object.
CreateShader creates a new empty shader object.
CreateTexture creates a texture object.
CullFace specifies which polygons are candidates for culling.
DeleteBuffer deletes the given buffer object.
DeleteFramebuffer deletes the given framebuffer object.
DeleteProgram deletes the given program object.
DeleteRenderbuffer deletes the given render buffer object.
DeleteShader deletes shader s.
DeleteTexture deletes the given texture object.
DepthFunc sets the function used for depth buffer comparisons.
DepthMask sets the depth buffer enabled for writing.
DepthRangef sets the mapping from normalized device coordinates to window coordinates.
DetachShader detaches the shader s from the program p.
Disable disables various GL capabilities.
DisableVertexAttribArray disables a vertex attribute array.
DrawArrays renders geometric primitives from the bound data.
DrawElements renders primitives from a bound buffer.
Enable enables various GL capabilities.
EnableVertexAttribArray enables a vertex attribute array.
Finish blocks until the effects of all previously called GL commands are complete.
Flush empties all buffers.
FramebufferRenderbuffer attaches rb to the current frame buffer.
FramebufferTexture2D attaches the t to the current frame buffer.
FrontFace defines which polygons are front-facing.
GenerateMipmap generates mipmaps for the current texture.
GetActiveAttrib returns details about an active attribute variable.
GetActiveUniform returns details about an active uniform variable.
GetAttachedShaders returns the shader objects attached to program p.
GetAttribLocation returns the location of an attribute variable.
GetBooleanv returns the boolean values of parameter pname.
GetBoundFramebuffer returns the currently bound framebuffer.
GetBufferParameteri returns a parameter for the active buffer.
GetError returns the next error.
GetFloatv returns the float values of parameter pname.
GetFramebufferAttachmentParameteri returns attachment parameters for the active framebuffer object.
GetInteger returns the int value of parameter pname.
GetIntegerv returns the int values of parameter pname.
GetProgrami returns a parameter value for a program.
GetProgramInfoLog returns the information log for a program.
GetRenderbufferParameteri returns a parameter value for a render buffer.
GetRenderbufferParameteri returns a parameter value for a shader.
GetShaderInfoLog returns the information log for a shader.
GetShaderPrecisionFormat returns range and precision limits for shader types.
GetShaderSource returns source code of shader s.
GetString reports current GL state.
GetTexParameterfv returns the float values of a texture parameter.
GetTexParameteriv returns the int values of a texture parameter.
GetUniformfv returns the float values of a uniform variable.
GetUniformiv returns the float values of a uniform variable.
GetUniformLocation returns the location of a uniform variable.
GetVertexAttribf reads the float value of a vertex attribute.
GetVertexAttribfv reads float values of a vertex attribute.
GetVertexAttribi reads the int value of a vertex attribute.
GetVertexAttribiv reads int values of a vertex attribute.
Hint sets implementation-specific modes.
IsBuffer reports if b is a valid buffer.
IsEnabled reports if cap is an enabled capability.
IsFramebuffer reports if fb is a valid frame buffer.
IsProgram reports if p is a valid program object.
IsRenderbuffer reports if rb is a valid render buffer.
IsShader reports if s is valid shader.
IsTexture reports if t is a valid texture.
LineWidth specifies the width of lines.
LinkProgram links the specified program.
PixelStorei sets pixel storage parameters.
PolygonOffset sets the scaling factors for depth offsets.
ReadPixels returns pixel data from a buffer.
ReleaseShaderCompiler frees resources allocated by the shader compiler.
RenderbufferStorage establishes the data storage, format, and dimensions of a renderbuffer object's image.
SampleCoverage sets multisample coverage parameters.
Scissor defines the scissor box rectangle, in window coordinates.
ShaderSource sets the source code of s to the given source code.
StencilFunc sets the front and back stencil test reference value.
StencilFunc sets the front or back stencil test reference value.
StencilMask controls the writing of bits in the stencil planes.
StencilMaskSeparate controls the writing of bits in the stencil planes.
StencilOp sets front and back stencil test actions.
StencilOpSeparate sets front or back stencil tests.
TexImage2D writes a 2D texture image.
TexParameterf sets a float texture parameter.
TexParameterfv sets a float texture parameter array.
TexParameteri sets an integer texture parameter.
TexParameteriv sets an integer texture parameter array.
TexSubImage2D writes a subregion of a 2D texture image.
Uniform1f writes a float uniform variable.
Uniform1fv writes a [len(src)]float uniform array.
Uniform1i writes an int uniform variable.
Uniform1iv writes a int uniform array of len(src) elements.
Uniform2f writes a vec2 uniform variable.
Uniform2fv writes a vec2 uniform array of len(src)/2 elements.
Uniform2i writes an ivec2 uniform variable.
Uniform2iv writes an ivec2 uniform array of len(src)/2 elements.
Uniform3f writes a vec3 uniform variable.
Uniform3fv writes a vec3 uniform array of len(src)/3 elements.
Uniform3i writes an ivec3 uniform variable.
Uniform3iv writes an ivec3 uniform array of len(src)/3 elements.
Uniform4f writes a vec4 uniform variable.
Uniform4fv writes a vec4 uniform array of len(src)/4 elements.
Uniform4i writes an ivec4 uniform variable.
Uniform4i writes an ivec4 uniform array of len(src)/4 elements.
UniformMatrix2fv writes 2x2 matrices.
UniformMatrix3fv writes 3x3 matrices.
UniformMatrix4fv writes 4x4 matrices.
UseProgram sets the active program.
ValidateProgram checks to see whether the executables contained in program can execute given the current OpenGL state.
VertexAttrib1f writes a float vertex attribute.
VertexAttrib1fv writes a float vertex attribute.
VertexAttrib2f writes a vec2 vertex attribute.
VertexAttrib2fv writes a vec2 vertex attribute.
VertexAttrib3f writes a vec3 vertex attribute.
VertexAttrib3fv writes a vec3 vertex attribute.
VertexAttrib4f writes a vec4 vertex attribute.
VertexAttrib4fv writes a vec4 vertex attribute.
VertexAttribPointer uses a bound buffer to define vertex attribute data.
Viewport sets the viewport, an affine transformation that normalizes device coordinates to window coordinates.

# Constants

# Variables

ContextWatcher is this library's context watcher, satisfying glfw.ContextWatcher interface.

# Structs

Attrib identifies the location of a specific attribute variable.
Buffer identifies a GL buffer object.
Framebuffer identifies a GL framebuffer.
Program identifies a compiled shader program.
A Renderbuffer is a GL object that holds an image in an internal format.
Shader identifies a GLSL shader.
A Texture identifies a GL texture unit.
Uniform identifies the location of a specific uniform variable.

# Type aliases

Enum is equivalent to GLenum, and is normally used with one of the constants defined in this package.