From 0bf319f7d0d2480311bb7e55104defa1d5609eb4 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 27 Oct 2013 21:29:39 +0900 Subject: [PATCH] Refactoring --- graphics/opengl/rendertarget/render_target.go | 12 ++++++------ graphics/texture/texture.go | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/graphics/opengl/rendertarget/render_target.go b/graphics/opengl/rendertarget/render_target.go index c2a9f1d6c..681ee1956 100644 --- a/graphics/opengl/rendertarget/render_target.go +++ b/graphics/opengl/rendertarget/render_target.go @@ -37,12 +37,12 @@ func New(width, height int, filter texture.Filter) ( if err != nil { return nil, err } - framebuffer := C.GLuint(0) - tex.CreateFramebuffer(func(native interface{}) { - framebuffer = - createFramebuffer(C.GLuint(native.(texture.Native))) - }) - return rendertarget.NewWithFramebuffer(tex, Framebuffer(framebuffer)), nil + f := func(native interface{}) interface{}{ + return createFramebuffer(C.GLuint(native.(texture.Native))) + } + framebuffer := tex.CreateFramebuffer(f) + return rendertarget.NewWithFramebuffer(tex, + Framebuffer(framebuffer.(C.GLuint))), nil } func NewWithFramebuffer(width, height int, framebuffer Framebuffer, diff --git a/graphics/texture/texture.go b/graphics/texture/texture.go index 058f14b07..debdb6837 100644 --- a/graphics/texture/texture.go +++ b/graphics/texture/texture.go @@ -126,6 +126,7 @@ func (texture *Texture) DrawParts(parts []graphics.TexturePart, draw(texture.native, quads) } -func (texture *Texture) CreateFramebuffer(create func(native interface{})) { - create(texture.native) +func (texture *Texture) CreateFramebuffer( + create func(native interface{}) interface{}) interface{} { + return create(texture.native) }