added an activate function and an exported TextureID so that other GL code can also use the canvas
This commit is contained in:
parent
c98bc6c23d
commit
04b3418c3b
3 changed files with 21 additions and 0 deletions
|
@ -257,6 +257,8 @@ func New(x, y, w, h int, ctx *GLContext) (*GoGLBackend, error) {
|
||||||
type GoGLBackendOffscreen struct {
|
type GoGLBackendOffscreen struct {
|
||||||
GoGLBackend
|
GoGLBackend
|
||||||
|
|
||||||
|
TextureID uint32
|
||||||
|
|
||||||
offscrBuf offscreenBuffer
|
offscrBuf offscreenBuffer
|
||||||
offscrImg Image
|
offscrImg Image
|
||||||
}
|
}
|
||||||
|
@ -281,6 +283,7 @@ func NewOffscreen(w, h int, alpha bool, ctx *GLContext) (*GoGLBackendOffscreen,
|
||||||
bo.offscrImg.w = bo.offscrBuf.w
|
bo.offscrImg.w = bo.offscrBuf.w
|
||||||
bo.offscrImg.h = bo.offscrBuf.h
|
bo.offscrImg.h = bo.offscrBuf.h
|
||||||
bo.offscrImg.tex = bo.offscrBuf.tex
|
bo.offscrImg.tex = bo.offscrBuf.tex
|
||||||
|
bo.TextureID = bo.offscrBuf.tex
|
||||||
}
|
}
|
||||||
b.disableTextureRenderTarget = func() {
|
b.disableTextureRenderTarget = func() {
|
||||||
b.enableTextureRenderTarget(&bo.offscrBuf)
|
b.enableTextureRenderTarget(&bo.offscrBuf)
|
||||||
|
@ -326,6 +329,13 @@ func glError() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Activate only needs to be called if there is other
|
||||||
|
// code also using the GL state
|
||||||
|
func (b *GoGLBackend) Activate() {
|
||||||
|
activeContext = nil
|
||||||
|
b.activate()
|
||||||
|
}
|
||||||
|
|
||||||
var activeContext *GoGLBackend
|
var activeContext *GoGLBackend
|
||||||
|
|
||||||
func (b *GoGLBackend) activate() {
|
func (b *GoGLBackend) activate() {
|
||||||
|
|
|
@ -258,6 +258,7 @@ func rewriteMain(src string) string {
|
||||||
"type XMobileBackend struct {\n", 1)
|
"type XMobileBackend struct {\n", 1)
|
||||||
src = strings.Replace(src, "func NewGLContext() (*GLContext, error) {",
|
src = strings.Replace(src, "func NewGLContext() (*GLContext, error) {",
|
||||||
"func NewGLContext(glctx gl.Context) (*GLContext, error) {", 1)
|
"func NewGLContext(glctx gl.Context) (*GLContext, error) {", 1)
|
||||||
|
src = strings.Replace(src, "TextureID uint32", "TextureID gl.Texture", 1)
|
||||||
|
|
||||||
src = strings.Replace(src,
|
src = strings.Replace(src,
|
||||||
` err := gl.Init()
|
` err := gl.Init()
|
||||||
|
|
|
@ -252,6 +252,8 @@ func New(x, y, w, h int, ctx *GLContext) (*XMobileBackend, error) {
|
||||||
type XMobileBackendOffscreen struct {
|
type XMobileBackendOffscreen struct {
|
||||||
XMobileBackend
|
XMobileBackend
|
||||||
|
|
||||||
|
TextureID gl.Texture
|
||||||
|
|
||||||
offscrBuf offscreenBuffer
|
offscrBuf offscreenBuffer
|
||||||
offscrImg Image
|
offscrImg Image
|
||||||
}
|
}
|
||||||
|
@ -274,6 +276,7 @@ func NewOffscreen(w, h int, alpha bool, ctx *GLContext) (*XMobileBackendOffscree
|
||||||
bo.offscrImg.w = bo.offscrBuf.w
|
bo.offscrImg.w = bo.offscrBuf.w
|
||||||
bo.offscrImg.h = bo.offscrBuf.h
|
bo.offscrImg.h = bo.offscrBuf.h
|
||||||
bo.offscrImg.tex = bo.offscrBuf.tex
|
bo.offscrImg.tex = bo.offscrBuf.tex
|
||||||
|
bo.TextureID = bo.offscrBuf.tex
|
||||||
}
|
}
|
||||||
b.disableTextureRenderTarget = func() {
|
b.disableTextureRenderTarget = func() {
|
||||||
b.enableTextureRenderTarget(&bo.offscrBuf)
|
b.enableTextureRenderTarget(&bo.offscrBuf)
|
||||||
|
@ -319,6 +322,13 @@ func glError(b *XMobileBackend) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Activate only needs to be called if there is other
|
||||||
|
// code also using the GL state
|
||||||
|
func (b *XMobileBackend) Activate() {
|
||||||
|
activeContext = nil
|
||||||
|
b.activate()
|
||||||
|
}
|
||||||
|
|
||||||
var activeContext *XMobileBackend
|
var activeContext *XMobileBackend
|
||||||
|
|
||||||
func (b *XMobileBackend) activate() {
|
func (b *XMobileBackend) activate() {
|
||||||
|
|
Loading…
Reference in a new issue