Documentation ¶
Overview ¶
Package framebuffer provides a convenient way of working with OpenGL framebuffers. The Sequence type conceptualises a sequence of textures all of which may be attached to the framebuffer object for a drawing operation.
The key to the Sequence type is the texture index. This is not to be confused with the texture ID. The number of textures (and therefore texture indices) is defined at Seqeunce creation, with NewSequence().
For example, to create a framebuffer sequence with two textures:
seq := NewSequence(2)
The Setup() function must be called at least once after NewSequence() and called as often as necessary to ensure the dimensions (width and height) are correct.
hasChanged := seq.Setup(800, 600)
Setup() returns true if the texture data has been recreated in accordance with the new dimensions.
The Process() function is used to assign the framebuffer object and for convenience, runs the supplied the draw() function. The texture ID is returned and can be used for presentation of as the input for the next call to Process() (via the draw() function).
texture := seq.Process(0, func() { // 1. set up shader // 2. OpenGL draw (eg. gl.DrawElements() })
Note that much of the work of chaning a sequence of shaders must be performed by the user of the package. The package does however, hide a lot of detail behind the Process() and Setup() functions.
Index ¶
- type Sequence
- func (seq *Sequence) Clear(idxTexture int) uint32
- func (seq *Sequence) Destroy()
- func (seq *Sequence) Len() int
- func (seq *Sequence) Process(idxTexture int, draw func()) uint32
- func (seq *Sequence) SaveJPEG(idxTexture int, path string, logTag string)
- func (seq *Sequence) Setup(width int32, height int32) bool
- func (seq *Sequence) Texture(idxTexture int) uint32
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sequence ¶
type Sequence struct {
// contains filtered or unexported fields
}
Sequence represents the sequence of textures that can be assigned to a framebuffer.
func NewSequence ¶
NewSequence is the preferred method of initialisation of the Sequence type.
func (*Sequence) Process ¶
Process assigns the texture related to idxTexture to the framebuffer and runs the supplied draw() function.
Returns the texture ID (not the index) that has been assigned to the framebuffer.
Changes the state of the frame buffer.
func (*Sequence) SaveJPEG ¶
SavesJPEG writes the texture to the specified path. Does not return any errors but will log using logTag if logTag is not empty.