opengl

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2018 License: BSD-3-Clause, BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEPTH_BUFFER_BIT   uint32 = 0x00000100
	STENCIL_BUFFER_BIT        = 0x00000400
	COLOR_BUFFER_BIT          = 0x00004000
)

Buffer Bits

View Source
const (
	POINTS         uint32 = 0x0000
	LINES                 = 0x0001
	LINE_LOOP             = 0x0002
	LINE_STRIP            = 0x0003
	TRIANGLES             = 0x0004
	TRIANGLE_STRIP        = 0x0005
	TRIANGLE_FAN          = 0x0006
)

Draw Types

View Source
const (
	FRAGMENT_SHADER uint32 = 0x8B30
	VERTEX_SHADER          = 0x8B31
)

Shader Types

View Source
const (
	COMPILE_STATUS uint32 = 0x8B81
	LINK_STATUS           = 0x8B82
)

Status Values

View Source
const (
	STREAM_DRAW  uint32 = 0x88E0
	STATIC_DRAW         = 0x88E4
	DYNAMIC_DRAW        = 0x88E8
)

Draw Types

View Source
const (
	BLEND      uint32 = 0x0BE2
	DEPTH_TEST        = 0x0B71
)

Features

View Source
const (
	SRC_ALPHA           uint32 = 0x0302
	ONE_MINUS_SRC_ALPHA        = 0x0303
	ONE_MINUS_SRC_COLOR        = 0x0301
)

Alpha constants

View Source
const (
	BYTE           uint32 = 0x1400
	UNSIGNED_BYTE         = 0x1401
	SHORT                 = 0x1402
	UNSIGNED_SHORT        = 0x1403
	INT                   = 0x1404
	UNSIGNED_INT          = 0x1405
	FLOAT                 = 0x1406
)

Data Types

View Source
const (
	TEXTURE_2D uint32 = 0x0DE1

	TEXTURE0 = 0x84C0

	NEAREST            = 0x2600
	TEXTURE_MAG_FILTER = 0x2800
	TEXTURE_MIN_FILTER = 0x2801
)

Texture Constants

View Source
const (
	NO_ERROR                      uint32 = 0
	INVALID_ENUM                         = 0x0500
	INVALID_VALUE                        = 0x0501
	INVALID_OPERATION                    = 0x0502
	STACK_OVERFLOW                       = 0x0503
	STACK_UNDERFLOW                      = 0x0504
	OUT_OF_MEMORY                        = 0x0505
	INVALID_FRAMEBUFFER_OPERATION        = 0x0506
)

Errors

View Source
const (
	ALPHA uint32 = 0x1906
	RGBA         = 0x1908
	RED          = 0x1903
	R8           = 0x8229
)

Color Types

View Source
const (
	ARRAY_BUFFER uint32 = 0x8892
)

Buffer Types

Variables

This section is empty.

Functions

func CompileNewShader

func CompileNewShader(gl OpenGl, shaderType uint32, source string) (shader uint32, err error)

CompileNewShader creates a shader of given type and compiles the provided source.

func ErrorString

func ErrorString(errorCode uint32) string

ErrorString returns a readable version of the provided error code. If the code is unknown, the textual representation of the hexadecimal value is returned.

func LinkNewProgram

func LinkNewProgram(gl OpenGl, shaders ...uint32) (program uint32, err error)

LinkNewProgram creates a new shader program based on the provided shaders.

func LinkNewStandardProgram added in v0.4.2

func LinkNewStandardProgram(gl OpenGl, vertexShaderSource, fragmentShaderSource string) (program uint32, err error)

LinkNewStandardProgram creates a new shader based on two shader sources.

Types

type AttributeSetter added in v0.4.0

type AttributeSetter func(OpenGl)

AttributeSetter is a callback function for a VertexArrayObject.

type DebugBuilder

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

DebugBuilder is a builder for an OpenGl implementation for debugging.

func NewDebugBuilder

func NewDebugBuilder(wrapped OpenGl) *DebugBuilder

NewDebugBuilder wraps the provided OpenGl instance and returns a new builder instance.

func (*DebugBuilder) Build

func (builder *DebugBuilder) Build() OpenGl

Build creates a new instance of the debugging OpenGl implementation. The builder can be resused to create another instance with different parameters.

func (*DebugBuilder) OnEntry

func (builder *DebugBuilder) OnEntry(callback DebuggingEntryFunc) *DebugBuilder

OnEntry registers a callback function to be called before an OpenGL function is called.

func (*DebugBuilder) OnError

func (builder *DebugBuilder) OnError(callback DebuggingErrorFunc) *DebugBuilder

OnError registers a callback function to be called when an OpenGL function set an error state.

func (*DebugBuilder) OnExit

func (builder *DebugBuilder) OnExit(callback DebuggingExitFunc) *DebugBuilder

OnExit registers a callback function to be called after an OpenGL function returned.

type DebuggingEntryFunc

type DebuggingEntryFunc func(name string, param ...interface{})

DebuggingEntryFunc is a function to be called on function entry of

type DebuggingErrorFunc

type DebuggingErrorFunc func(name string, errorCodes []uint32)

DebuggingErrorFunc is a function which is called if a previous OpenGL call caused an error state.

type DebuggingExitFunc

type DebuggingExitFunc func(name string, result ...interface{})

DebuggingExitFunc is a function to be called after an OpenGL function has returned. result may be several parameters for functions with multiple return values.

type Matrix4Uniform added in v0.4.0

type Matrix4Uniform UniformLocation

Matrix4Uniform represents one uniform parameter for a 4x4 matrix.

func (Matrix4Uniform) Set added in v0.4.0

func (location Matrix4Uniform) Set(gl OpenGl, matrix *mgl.Mat4)

Set stores the provided matrix as the current uniform value.

type OpenGl

type OpenGl interface {
	ActiveTexture(texture uint32)
	AttachShader(program uint32, shader uint32)

	BindAttribLocation(program uint32, index uint32, name string)
	BindBuffer(target uint32, buffer uint32)
	BindTexture(target uint32, texture uint32)
	BindVertexArray(array uint32)
	BlendFunc(sfactor uint32, dfactor uint32)
	BufferData(target uint32, size int, data interface{}, usage uint32)

	Clear(mask uint32)
	ClearColor(red float32, green float32, blue float32, alpha float32)

	CompileShader(shader uint32)

	CreateProgram() uint32
	CreateShader(shaderType uint32) uint32

	DeleteBuffers(buffers []uint32)
	DeleteProgram(program uint32)
	DeleteShader(shader uint32)
	DeleteTextures(textures []uint32)
	DeleteVertexArrays(arrays []uint32)
	Disable(cap uint32)

	DrawArrays(mode uint32, first int32, count int32)

	Enable(cap uint32)
	EnableVertexAttribArray(index uint32)

	GenerateMipmap(target uint32)
	GenBuffers(n int32) []uint32
	GenTextures(n int32) []uint32
	GenVertexArrays(n int32) []uint32

	GetAttribLocation(program uint32, name string) int32
	GetError() uint32
	GetShaderInfoLog(shader uint32) string
	GetShaderParameter(shader uint32, param uint32) int32
	GetProgramInfoLog(program uint32) string
	GetProgramParameter(program uint32, param uint32) int32
	GetUniformLocation(program uint32, name string) int32

	LinkProgram(program uint32)

	ReadPixels(x int32, y int32, width int32, height int32, format uint32, pixelType uint32, pixels interface{})

	ShaderSource(shader uint32, source string)

	TexImage2D(target uint32, level int32, internalFormat uint32, width int32, height int32,
		border int32, format uint32, xtype uint32, pixels interface{})
	TexParameteri(target uint32, pname uint32, param int32)

	Uniform1i(location int32, value int32)
	Uniform4fv(location int32, value *[4]float32)
	UniformMatrix4fv(location int32, transpose bool, value *[16]float32)
	UseProgram(program uint32)

	VertexAttribOffset(index uint32, size int32, attribType uint32, normalized bool, stride int32, offset int)
	Viewport(x int32, y int32, width int32, height int32)
}

OpenGl describes an Open GL interface usable for all environments of this application. It is the common subset of WebGL (= OpenGL ES 2) and an equivalent API on the desktop.

type UniformLocation added in v0.4.0

type UniformLocation int32

UniformLocation represents a uniform parameter for a shader program

type Vector4Uniform added in v0.4.0

type Vector4Uniform UniformLocation

Vector4Uniform represents one uniform parameter for a 4-dimensional vector.

func (Vector4Uniform) Set added in v0.4.0

func (location Vector4Uniform) Set(gl OpenGl, value *[4]float32)

Set stores the provided 4-dimensional vector as the current uniform value.

type VertexArrayObject added in v0.4.0

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

VertexArrayObject registers common vertex properties which are pre-set before regular rendering loops. Depending on the supported level of the Open GL API, these settings are either buffered (using a VAO - vertex array object), or replayed for every render call.

func NewVertexArrayObject added in v0.4.0

func NewVertexArrayObject(gl OpenGl, program uint32) *VertexArrayObject

NewVertexArrayObject returns a new instance.

func (*VertexArrayObject) Dispose added in v0.4.0

func (vao *VertexArrayObject) Dispose()

Dispose drops any associated resources.

func (*VertexArrayObject) OnShader added in v0.4.0

func (vao *VertexArrayObject) OnShader(task func())

OnShader executes the provided task with an activated shader program and the vertex array object initialized.

func (*VertexArrayObject) WithSetter added in v0.4.0

func (vao *VertexArrayObject) WithSetter(setter AttributeSetter)

WithSetter registers the setter function for this object. Depending on the support of the OpenGL API, this setter may be called once immediately, or for each render call.

Jump to

Keyboard shortcuts

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