From d97b7a2999402ffa14a0b70e0c185eece043369d Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 27 Oct 2013 23:11:26 +0900 Subject: [PATCH] Refactoring --- graphics/opengl/context.go | 4 +++- graphics/opengl/device.go | 14 ++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/graphics/opengl/context.go b/graphics/opengl/context.go index 5ef699075..6b9e6f3b2 100644 --- a/graphics/opengl/context.go +++ b/graphics/opengl/context.go @@ -38,6 +38,9 @@ func newContext(screenWidth, screenHeight, screenScale int) *Context { } func (context *Context) Init() { + C.glEnable(C.GL_TEXTURE_2D) + C.glEnable(C.GL_BLEND) + // The main framebuffer should be created sooner than any other // framebuffers! mainFramebuffer := C.GLint(0) @@ -119,7 +122,6 @@ func (context *Context) setOffscreen(rt *grendertarget.RenderTarget) { panic(fmt.Sprintf("glBindFramebuffer failed: %d", err)) } - C.glEnable(C.GL_BLEND) C.glBlendFuncSeparate(C.GL_SRC_ALPHA, C.GL_ONE_MINUS_SRC_ALPHA, C.GL_ZERO, C.GL_ONE) diff --git a/graphics/opengl/device.go b/graphics/opengl/device.go index 5f2ce35e2..55af25295 100644 --- a/graphics/opengl/device.go +++ b/graphics/opengl/device.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" @@ -31,7 +26,6 @@ func (device *Device) Init() { func (device *Device) Update(draw func(graphics.Context)) { context := device.context - C.glEnable(C.GL_TEXTURE_2D) context.ResetOffscreen() context.Clear() @@ -42,12 +36,8 @@ func (device *Device) Update(draw func(graphics.Context)) { context.Clear() scale := float64(context.screenScale) - geometryMatrix := matrix.Geometry{ - [2][3]float64{ - {scale, 0, 0}, - {0, scale, 0}, - }, - } + geometryMatrix := matrix.IdentityGeometry() + geometryMatrix.Scale(scale, scale) context.DrawTexture(context.ToTexture(context.screenId), geometryMatrix, matrix.IdentityColor()) context.flush()