Documentation
¶
Overview ¶
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.
Index ¶
- Variables
- type Renderer
- func (c Renderer) Bounds() image.Rectangle
- func (r *Renderer) Clear(rect image.Rectangle, bg gfx.Color)
- func (r *Renderer) ClearDepth(rect image.Rectangle, depth float64)
- func (r *Renderer) ClearStencil(rect image.Rectangle, stencil int)
- func (r *Renderer) Clock() *clock.Clock
- func (r *Renderer) Download(rect image.Rectangle, complete chan image.Image)
- func (r *Renderer) Draw(rect image.Rectangle, o *gfx.Object, c *gfx.Camera)
- func (r *Renderer) GPUInfo() gfx.GPUInfo
- func (r *Renderer) LoadMesh(m *gfx.Mesh, done chan *gfx.Mesh)
- func (r *Renderer) LoadShader(s *gfx.Shader, done chan *gfx.Shader)
- func (r *Renderer) LoadTexture(t *gfx.Texture, done chan *gfx.Texture)
- func (c Renderer) MSAA() bool
- func (c Renderer) Precision() gfx.Precision
- func (r *Renderer) QueryWait()
- func (r *Renderer) Render()
- func (r *Renderer) RenderToTexture(cfg gfx.RTTConfig) gfx.Canvas
- func (r *Renderer) SetDebugOutput(w io.Writer)
- func (c Renderer) SetMSAA(msaa bool)
- func (r *Renderer) UpdateBounds(bounds image.Rectangle)
Constants ¶
This section is empty.
Variables ¶
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.
Functions ¶
This section is empty.
Types ¶
type Renderer ¶
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 ¶
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) ClearDepth ¶
Implements gfx.Canvas interface.
func (*Renderer) ClearStencil ¶
Implements gfx.Canvas interface.
func (*Renderer) GPUInfo ¶
func (r *Renderer) GPUInfo() gfx.GPUInfo
Implements gfx.Renderer interface.
func (*Renderer) LoadMesh ¶
func (r *Renderer) LoadMesh(m *gfx.Mesh, done chan *gfx.Mesh)
Implements gfx.Renderer interface.
func (*Renderer) LoadShader ¶
func (r *Renderer) LoadShader(s *gfx.Shader, done chan *gfx.Shader)
Implements gfx.Renderer interface.
func (*Renderer) LoadTexture ¶
func (r *Renderer) LoadTexture(t *gfx.Texture, done chan *gfx.Texture)
Implements gfx.Renderer interface.
func (Renderer) Precision ¶
func (c Renderer) Precision() gfx.Precision
Implements gfx.Canvas interface.
func (*Renderer) RenderToTexture ¶
func (r *Renderer) RenderToTexture(cfg gfx.RTTConfig) gfx.Canvas
Implements gfx.Renderer interface.
func (*Renderer) SetDebugOutput ¶
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) UpdateBounds ¶
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).
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
internal
|
|
gl
Package gl implements Go bindings to OpenGL.
|
Package gl implements Go bindings to OpenGL. |
procaddr
Package procaddr defines platform-specific mechanisms for loading OpenGL function addresses.
|
Package procaddr defines platform-specific mechanisms for loading OpenGL function addresses. |
procaddr/auto
Package auto automatically selects an appropriate GetProcAddressFunc based on the build environment.
|
Package auto automatically selects an appropriate GetProcAddressFunc based on the build environment. |