mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
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
This commit is contained in:
parent
92631e64ed
commit
f5336ce7bc
@ -162,7 +162,7 @@ func (c *Context) NewTexture(width, height int) (Texture, error) {
|
|||||||
|
|
||||||
func (c *Context) bindFramebufferImpl(f Framebuffer) {
|
func (c *Context) bindFramebufferImpl(f Framebuffer) {
|
||||||
_ = c.runOnContextThread(func() error {
|
_ = c.runOnContextThread(func() error {
|
||||||
gl.BindFramebuffer(gl.FRAMEBUFFER, uint32(f))
|
gl.BindFramebufferEXT(gl.FRAMEBUFFER, uint32(f))
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
|
|||||||
var framebuffer Framebuffer
|
var framebuffer Framebuffer
|
||||||
var f uint32
|
var f uint32
|
||||||
if err := c.runOnContextThread(func() error {
|
if err := c.runOnContextThread(func() error {
|
||||||
gl.GenFramebuffers(1, &f)
|
gl.GenFramebuffersEXT(1, &f)
|
||||||
// TODO: Use gl.IsFramebuffer
|
// TODO: Use gl.IsFramebuffer
|
||||||
if f <= 0 {
|
if f <= 0 {
|
||||||
return errors.New("opengl: creating framebuffer failed: gl.IsFramebuffer returns false")
|
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))
|
c.bindFramebuffer(Framebuffer(f))
|
||||||
if err := c.runOnContextThread(func() error {
|
if err := c.runOnContextThread(func() error {
|
||||||
gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, uint32(texture), 0)
|
gl.FramebufferTexture2DEXT(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, uint32(texture), 0)
|
||||||
s := gl.CheckFramebufferStatus(gl.FRAMEBUFFER)
|
s := gl.CheckFramebufferStatusEXT(gl.FRAMEBUFFER)
|
||||||
if s != gl.FRAMEBUFFER_COMPLETE {
|
if s != gl.FRAMEBUFFER_COMPLETE {
|
||||||
if s != 0 {
|
if s != 0 {
|
||||||
return fmt.Errorf("opengl: creating framebuffer failed: %v", s)
|
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) {
|
func (c *Context) DeleteFramebuffer(f Framebuffer) {
|
||||||
_ = c.runOnContextThread(func() error {
|
_ = c.runOnContextThread(func() error {
|
||||||
ff := uint32(f)
|
ff := uint32(f)
|
||||||
if !gl.IsFramebuffer(ff) {
|
if !gl.IsFramebufferEXT(ff) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if c.lastFramebuffer == f {
|
if c.lastFramebuffer == f {
|
||||||
@ -281,7 +281,7 @@ func (c *Context) DeleteFramebuffer(f Framebuffer) {
|
|||||||
c.lastViewportWidth = 0
|
c.lastViewportWidth = 0
|
||||||
c.lastViewportHeight = 0
|
c.lastViewportHeight = 0
|
||||||
}
|
}
|
||||||
gl.DeleteFramebuffers(1, &ff)
|
gl.DeleteFramebuffersEXT(1, &ff)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user