gl2.v2: Index | Files | Directories

package gl2

import ""

Package gl2 provides an OpenGL 2 based graphics renderer.

The behavior of the renderer is defined fully in the gfx package (as such this package only makes mention of strictly OpenGL related caveats like initialization, etc).

When performing render-to-texture (RTT), feedback loops are explicitly prohibited. This means that the renderer will panic if you attempt to draw an object to an RTT canvas when the object uses the literal RTT texture in itself. Through OpenGL the result of this is at best a corrupt image -- and at worst driver-level memory corruption (hence it is not allowed).

A texture can turn on and off mipmapped by setting it's minification filter to a mipmapped or non-mipmapped filter after the texture has been loaded, but mipmapped can only be turned on with a loaded texture if when it loaded it had a mipmapped minification filter set on it.


Package Files

baseCanvas.go doc.go draw.go gl2.go loadmesh.go loadshader.go loadtexture.go rtt.go state.go


var ErrInvalidVersion = errors.New("invalid OpenGL version; must be at least OpenGL 2.0")

Used when attempting to create an OpenGL 2.0 renderer in a lesser OpenGL context.

type Renderer Uses

type Renderer struct {

    // Render and loader execution channels.
    RenderExec chan func() bool
    LoaderExec chan func()
    // contains filtered or unexported fields

Renderer is an OpenGL 2 based graphics renderer, it runs independant of the window management library being used (GLFW, SDL, Chippy, QML, etc).

The renderer primarily uses two independant OpenGL contexts, one is used for rendering and one is used for managing resources like meshes, textures, and shaders which allows for asynchronous loading (although it is also possible to use only a single OpenGL context for windowing libraries that do not support multiple, but this will inheritly disable asynchronous loading).

func New Uses

func New(keepState bool) (*Renderer, error)

New returns a new OpenGL 2 based graphics renderer. If any error is returned then a nil renderer is also returned. This function must be called only when an OpenGL 2 context is active.

keepState specifies whether or not the existing graphics state should be maintained between frames. If set to true then before rendering a frame the graphics state will be saved, the frame rendered, and the old graphics state restored again. This is particularly useful when the renderer must cooperate with another renderer (e.g. QT5). Do not turn it on needlessly though as it does come with a performance cost.

func (Renderer) Bounds Uses

func (c Renderer) Bounds() image.Rectangle

Implements the gfx.Canvas interface.

func (*Renderer) Clear Uses

func (r *Renderer) Clear(rect image.Rectangle, bg gfx.Color)

Implements gfx.Canvas interface.

func (*Renderer) ClearDepth Uses

func (r *Renderer) ClearDepth(rect image.Rectangle, depth float64)

Implements gfx.Canvas interface.

func (*Renderer) ClearStencil Uses

func (r *Renderer) ClearStencil(rect image.Rectangle, stencil int)

Implements gfx.Canvas interface.

func (*Renderer) Clock Uses

func (r *Renderer) Clock() *clock.Clock

Implements gfx.Renderer interface.

func (*Renderer) Download Uses

func (r *Renderer) Download(rect image.Rectangle, complete chan image.Image)

Implements gfx.Downloadable interface.

func (*Renderer) Draw Uses

func (r *Renderer) Draw(rect image.Rectangle, o *gfx.Object, c *gfx.Camera)

Implements gfx.Canvas interface.

func (*Renderer) GPUInfo Uses

func (r *Renderer) GPUInfo() gfx.GPUInfo

Implements gfx.Renderer interface.

func (*Renderer) LoadMesh Uses

func (r *Renderer) LoadMesh(m *gfx.Mesh, done chan *gfx.Mesh)

Implements gfx.Renderer interface.

func (*Renderer) LoadShader Uses

func (r *Renderer) LoadShader(s *gfx.Shader, done chan *gfx.Shader)

Implements gfx.Renderer interface.

func (*Renderer) LoadTexture Uses

func (r *Renderer) LoadTexture(t *gfx.Texture, done chan *gfx.Texture)

Implements gfx.Renderer interface.

func (Renderer) MSAA Uses

func (c Renderer) MSAA() bool

Implements gfx.Canvas interface.

func (Renderer) Precision Uses

func (c Renderer) Precision() gfx.Precision

Implements gfx.Canvas interface.

func (*Renderer) QueryWait Uses

func (r *Renderer) QueryWait()

Implements gfx.Canvas interface.

func (*Renderer) Render Uses

func (r *Renderer) Render()

Implements gfx.Canvas interface.

func (*Renderer) RenderToTexture Uses

func (r *Renderer) RenderToTexture(cfg gfx.RTTConfig) gfx.Canvas

Implements gfx.Renderer interface.

func (*Renderer) SetDebugOutput Uses

func (r *Renderer) SetDebugOutput(w io.Writer)

SetDebugOutput sets the writer, w, to write debug output to. It will mostly contain just shader debug information, but other information may be written in the future as well.

func (Renderer) SetMSAA Uses

func (c Renderer) SetMSAA(msaa bool)

Implements gfx.Canvas interface.

func (*Renderer) UpdateBounds Uses

func (r *Renderer) UpdateBounds(bounds image.Rectangle)

UpdateBounds updates the effective bounding rectangle of this renderer. It must be called whenever the OpenGL canvas size should change (e.g. on window resize).


internal/glPackage gl implements Go bindings to OpenGL.
internal/procaddrPackage procaddr defines platform-specific mechanisms for loading OpenGL function addresses.
internal/procaddr/autoPackage auto automatically selects an appropriate GetProcAddressFunc based on the build environment.

Package gl2 imports 17 packages (graph) and is imported by 2 packages. Updated 2016-07-20. Refresh now. Tools for package owners.