diff --git a/graphics/opengl/rendertarget/render_target.go b/graphics/opengl/rendertarget/render_target.go index 7018bc843..3402a3b4c 100644 --- a/graphics/opengl/rendertarget/render_target.go +++ b/graphics/opengl/rendertarget/render_target.go @@ -11,7 +11,7 @@ import ( type Framebuffer C.GLuint -func createFramebuffer(nativeTexture C.GLuint) C.GLuint { +func createFramebuffer(nativeTexture C.GLuint) Framebuffer { framebuffer := C.GLuint(0) C.glGenFramebuffers(1, &framebuffer) @@ -33,7 +33,7 @@ func createFramebuffer(nativeTexture C.GLuint) C.GLuint { C.glClearColor(0, 0, 0, 1) C.glClear(C.GL_COLOR_BUFFER_BIT) - return framebuffer + return Framebuffer(framebuffer) } // TODO: Rename them @@ -46,9 +46,7 @@ func New(width, height int, filter texture.Filter) ( f := func(native interface{}) interface{} { return createFramebuffer(C.GLuint(native.(texture.Native))) } - framebuffer := tex.CreateFramebuffer(f) - return gtexture.NewRenderTarget(tex, - Framebuffer(framebuffer.(C.GLuint))), tex, nil + return gtexture.NewRenderTarget(tex, f), tex, nil } func NewWithFramebuffer(width, height int, framebuffer Framebuffer) ( @@ -57,5 +55,8 @@ func NewWithFramebuffer(width, height int, framebuffer Framebuffer) ( if err != nil { return nil, err } - return gtexture.NewRenderTarget(tex, framebuffer), nil + f := func(native interface{}) interface{} { + return framebuffer + } + return gtexture.NewRenderTarget(tex, f), nil } diff --git a/graphics/texture/render_target.go b/graphics/texture/render_target.go index 8cb5bbb73..3bcae2811 100644 --- a/graphics/texture/render_target.go +++ b/graphics/texture/render_target.go @@ -5,10 +5,10 @@ type RenderTarget struct { framebuffer interface{} } -func NewRenderTarget(texture *Texture, framebuffer interface{}) *RenderTarget { +func NewRenderTarget(texture *Texture, create func(native interface{}) interface{}) *RenderTarget { return &RenderTarget{ texture: texture, - framebuffer: framebuffer, + framebuffer: create(texture.native), } } diff --git a/graphics/texture/texture.go b/graphics/texture/texture.go index 38ede9fd1..8fa16b451 100644 --- a/graphics/texture/texture.go +++ b/graphics/texture/texture.go @@ -110,8 +110,3 @@ func (texture *Texture) DrawParts(parts []graphics.TexturePart, drawable Drawabl } drawable.Draw(texture.native, quads) } - -func (texture *Texture) CreateFramebuffer( - create func(native interface{}) interface{}) interface{} { - return create(texture.native) -}