From 738c06c28d8e377a4d7e7a1d84fc1e09392ed854 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 11 Jan 2014 11:18:55 +0900 Subject: [PATCH] Add gl.go --- graphics/opengl/context.go | 13 ++++--------- graphics/opengl/gl.go | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 graphics/opengl/gl.go diff --git a/graphics/opengl/context.go b/graphics/opengl/context.go index fa1e8a65b..277528d0f 100644 --- a/graphics/opengl/context.go +++ b/graphics/opengl/context.go @@ -1,10 +1,5 @@ package opengl -// #cgo LDFLAGS: -framework OpenGL -// -// #include -// #include -import "C" import ( "github.com/hajimehoshi/go-ebiten/graphics" "github.com/hajimehoshi/go-ebiten/graphics/matrix" @@ -38,6 +33,8 @@ func newContext(ids *ids, screenWidth, screenHeight, screenScale int) *Context { context.ResetOffscreen() context.Clear() + enableAlphaBlending() + return context } @@ -47,9 +44,6 @@ func (context *Context) Dispose() { } func (context *Context) update(draw func(graphics.Context)) { - C.glEnable(C.GL_TEXTURE_2D) - C.glEnable(C.GL_BLEND) - context.ResetOffscreen() context.Clear() @@ -63,7 +57,8 @@ func (context *Context) update(draw func(graphics.Context)) { geometryMatrix.Scale(scale, scale) context.DrawRenderTarget(context.screenId, geometryMatrix, matrix.IdentityColor()) - C.glFlush() + + flush() } func (context *Context) Clear() { diff --git a/graphics/opengl/gl.go b/graphics/opengl/gl.go new file mode 100644 index 000000000..12b745eb4 --- /dev/null +++ b/graphics/opengl/gl.go @@ -0,0 +1,16 @@ +package opengl + +// #cgo LDFLAGS: -framework OpenGL +// +// #include +// #include +import "C" + +func enableAlphaBlending() { + C.glEnable(C.GL_TEXTURE_2D) + C.glEnable(C.GL_BLEND) +} + +func flush() { + C.glFlush() +}