From f5336ce7bcc810d7043448f53bdcd03bbbcbbe68 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 9 May 2018 00:33:25 +0900 Subject: [PATCH] opengl: Use 'EXT' functions for framebuffers Some pretty old machines don't support OpenGL 3.x or later, and in such environment, some framebuffer functions like glGenFramebuffers are not available. Instead, EXT versions can be used even on machines that don't support OpenGL 3.x. After this change, Ebiten always tries to use EXT version of framebuffer functions. I believe EXT version is always available when non-EXT version is available, so this chang eshould be safe. Fixes #602 --- internal/opengl/context_desktop.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/opengl/context_desktop.go b/internal/opengl/context_desktop.go index 7767b4beb..faaae3fc8 100644 --- a/internal/opengl/context_desktop.go +++ b/internal/opengl/context_desktop.go @@ -162,7 +162,7 @@ func (c *Context) NewTexture(width, height int) (Texture, error) { func (c *Context) bindFramebufferImpl(f Framebuffer) { _ = c.runOnContextThread(func() error { - gl.BindFramebuffer(gl.FRAMEBUFFER, uint32(f)) + gl.BindFramebufferEXT(gl.FRAMEBUFFER, uint32(f)) return nil }) } @@ -233,7 +233,7 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) { var framebuffer Framebuffer var f uint32 if err := c.runOnContextThread(func() error { - gl.GenFramebuffers(1, &f) + gl.GenFramebuffersEXT(1, &f) // TODO: Use gl.IsFramebuffer if f <= 0 { return errors.New("opengl: creating framebuffer failed: gl.IsFramebuffer returns false") @@ -244,8 +244,8 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) { } c.bindFramebuffer(Framebuffer(f)) if err := c.runOnContextThread(func() error { - gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, uint32(texture), 0) - s := gl.CheckFramebufferStatus(gl.FRAMEBUFFER) + gl.FramebufferTexture2DEXT(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, uint32(texture), 0) + s := gl.CheckFramebufferStatusEXT(gl.FRAMEBUFFER) if s != gl.FRAMEBUFFER_COMPLETE { if s != 0 { return fmt.Errorf("opengl: creating framebuffer failed: %v", s) @@ -273,7 +273,7 @@ func (c *Context) setViewportImpl(width, height int) { func (c *Context) DeleteFramebuffer(f Framebuffer) { _ = c.runOnContextThread(func() error { ff := uint32(f) - if !gl.IsFramebuffer(ff) { + if !gl.IsFramebufferEXT(ff) { return nil } if c.lastFramebuffer == f { @@ -281,7 +281,7 @@ func (c *Context) DeleteFramebuffer(f Framebuffer) { c.lastViewportWidth = 0 c.lastViewportHeight = 0 } - gl.DeleteFramebuffers(1, &ff) + gl.DeleteFramebuffersEXT(1, &ff) return nil }) }