added an optional alpha channel for offscreen canvas, and a DeleteOffscreen function
This commit is contained in:
parent
7aeae444a9
commit
57348acc02
2 changed files with 14 additions and 3 deletions
15
canvas.go
15
canvas.go
|
@ -152,13 +152,24 @@ func New(x, y, w, h int) *Canvas {
|
|||
|
||||
// NewOffscreen creates a new canvas with the given size. It
|
||||
// does not render directly to the screen but renders to a
|
||||
// texture instead
|
||||
func NewOffscreen(w, h int) *Canvas {
|
||||
// texture instead. If alpha is set to true, the offscreen
|
||||
// canvas will have an alpha channel
|
||||
func NewOffscreen(w, h int, alpha bool) *Canvas {
|
||||
cv := New(0, 0, w, h)
|
||||
cv.offscreen = true
|
||||
cv.offscrBuf.alpha = alpha
|
||||
return cv
|
||||
}
|
||||
|
||||
func DeleteOffscreen(cv *Canvas) {
|
||||
if !cv.offscreen {
|
||||
return
|
||||
}
|
||||
gli.DeleteTextures(1, &cv.offscrBuf.tex)
|
||||
gli.DeleteFramebuffers(1, &cv.offscrBuf.frameBuf)
|
||||
gli.DeleteRenderbuffers(1, &cv.offscrBuf.renderStencilBuf)
|
||||
}
|
||||
|
||||
// SetBounds updates the bounds of the canvas. This would
|
||||
// usually be called for example when the window is resized
|
||||
func (cv *Canvas) SetBounds(x, y, w, h int) {
|
||||
|
|
|
@ -22,7 +22,7 @@ func run(t *testing.T, fn func(cv *canvas.Canvas)) {
|
|||
}
|
||||
defer wnd.Destroy()
|
||||
|
||||
cv := canvas.NewOffscreen(100, 100)
|
||||
cv := canvas.NewOffscreen(100, 100, false)
|
||||
|
||||
gl.Disable(gl.MULTISAMPLE)
|
||||
|
||||
|
|
Loading…
Reference in a new issue