From 5fbfb3a3a380c24fe1c01ed25ad1152d57292a8f Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 29 Nov 2013 03:21:53 +0900 Subject: [PATCH] Refactoring --- graphics/opengl/context.go | 1 + graphics/opengl/offscreen/offscreen.go | 2 -- graphics/opengl/rendertarget/render_target.go | 2 +- graphics/texture/texture.go | 3 +-- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/graphics/opengl/context.go b/graphics/opengl/context.go index 66f60e59f..18c53f5fc 100644 --- a/graphics/opengl/context.go +++ b/graphics/opengl/context.go @@ -70,6 +70,7 @@ func (context *Context) DrawTextureParts( context.offscreen.DrawTextureParts(tex, parts, geometryMatrix, colorMatrix) } +// Init initializes the context. The initial state is saved for each GL context. func (context *Context) Init() { C.glEnable(C.GL_TEXTURE_2D) C.glEnable(C.GL_BLEND) diff --git a/graphics/opengl/offscreen/offscreen.go b/graphics/opengl/offscreen/offscreen.go index e9e8f71e0..7d80e223b 100644 --- a/graphics/opengl/offscreen/offscreen.go +++ b/graphics/opengl/offscreen/offscreen.go @@ -28,8 +28,6 @@ func New(screenWidth, screenHeight, screenScale int) *Offscreen { screenScale: screenScale, } - // The main framebuffer should be created sooner than any other - // framebuffers! mainFramebuffer := C.GLint(0) C.glGetIntegerv(C.GL_FRAMEBUFFER_BINDING, &mainFramebuffer) diff --git a/graphics/opengl/rendertarget/render_target.go b/graphics/opengl/rendertarget/render_target.go index 3b2d9ff4e..c26f879da 100644 --- a/graphics/opengl/rendertarget/render_target.go +++ b/graphics/opengl/rendertarget/render_target.go @@ -49,7 +49,7 @@ func Create(width, height int, filter texture.Filter) ( if err != nil { return nil, nil, err } - return tex.NewRenderTarget(&framebufferCreator{}), tex, nil + return tex.CreateRenderTarget(&framebufferCreator{}), tex, nil } func CreateWithFramebuffer(width, height int, framebuffer Framebuffer) ( diff --git a/graphics/texture/texture.go b/graphics/texture/texture.go index 5b047f8e7..17e2e6c79 100644 --- a/graphics/texture/texture.go +++ b/graphics/texture/texture.go @@ -111,7 +111,6 @@ type FramebufferCreator interface { Create(native interface{}) interface{} } -func (texture *Texture) NewRenderTarget(creator FramebufferCreator) *RenderTarget { +func (texture *Texture) CreateRenderTarget(creator FramebufferCreator) *RenderTarget { return NewRenderTarget(creator.Create(texture.native), texture.width, texture.height) } -