document pixelgl.Frame
This commit is contained in:
parent
d905c04479
commit
192c455b16
|
@ -8,12 +8,14 @@ import (
|
||||||
"github.com/go-gl/gl/v3.3-core/gl"
|
"github.com/go-gl/gl/v3.3-core/gl"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Frame is a fixed resolution texture that you can draw on.
|
||||||
type Frame struct {
|
type Frame struct {
|
||||||
fb binder
|
fb binder
|
||||||
tex *Texture
|
tex *Texture
|
||||||
width, height int
|
width, height int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewFrame creates a new fully transparent Frame with given dimensions.
|
||||||
func NewFrame(width, height int, smooth bool) *Frame {
|
func NewFrame(width, height int, smooth bool) *Frame {
|
||||||
f := &Frame{
|
f := &Frame{
|
||||||
fb: binder{
|
fb: binder{
|
||||||
|
@ -46,22 +48,29 @@ func (f *Frame) delete() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Width returns the width of the Frame in pixels.
|
||||||
func (f *Frame) Width() int {
|
func (f *Frame) Width() int {
|
||||||
return f.width
|
return f.width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Height returns the height of the Frame in pixels.
|
||||||
func (f *Frame) Height() int {
|
func (f *Frame) Height() int {
|
||||||
return f.height
|
return f.height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Begin binds the Frame. All draw operations will target this Frame until End is called.
|
||||||
func (f *Frame) Begin() {
|
func (f *Frame) Begin() {
|
||||||
f.fb.bind()
|
f.fb.bind()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// End unbinds the Frame. All draw operations will go to whatever was bound before this Frame.
|
||||||
func (f *Frame) End() {
|
func (f *Frame) End() {
|
||||||
f.fb.restore()
|
f.fb.restore()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Texture returns the Texture that this Frame draws to. The Texture changes as you use the Frame.
|
||||||
|
//
|
||||||
|
// The Texture pointer returned from this method is always the same.
|
||||||
func (f *Frame) Texture() *Texture {
|
func (f *Frame) Texture() *Texture {
|
||||||
return f.tex
|
return f.tex
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue