mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 17:32:02 +01:00
opengl: BindFramebuffer no longer returns error
This commit is contained in:
parent
ade56f8176
commit
b590005c7a
@ -61,21 +61,16 @@ func (c *Context) BindTexture(t Texture) {
|
||||
c.lastTexture = t
|
||||
}
|
||||
|
||||
func (c *Context) bindFramebuffer(f Framebuffer) error {
|
||||
func (c *Context) bindFramebuffer(f Framebuffer) {
|
||||
if c.lastFramebuffer.equals(f) {
|
||||
return nil
|
||||
}
|
||||
if err := c.bindFramebufferImpl(f); err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
c.bindFramebufferImpl(f)
|
||||
c.lastFramebuffer = f
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) SetViewport(f Framebuffer, width, height int) error {
|
||||
if err := c.bindFramebuffer(f); err != nil {
|
||||
return err
|
||||
}
|
||||
c.bindFramebuffer(f)
|
||||
if c.lastViewportWidth != width || c.lastViewportHeight != height {
|
||||
if err := c.setViewportImpl(width, height); err != nil {
|
||||
return nil
|
||||
|
@ -169,14 +169,11 @@ func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) (
|
||||
return texture, nil
|
||||
}
|
||||
|
||||
func (c *Context) bindFramebufferImpl(f Framebuffer) error {
|
||||
if err := c.runOnContextThread(func() error {
|
||||
func (c *Context) bindFramebufferImpl(f Framebuffer) {
|
||||
_ = c.runOnContextThread(func() error {
|
||||
gl.BindFramebuffer(gl.FRAMEBUFFER, uint32(f))
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8, error) {
|
||||
@ -187,9 +184,7 @@ func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := c.bindFramebuffer(f); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.bindFramebuffer(f)
|
||||
if err := c.runOnContextThread(func() error {
|
||||
pixels = make([]uint8, 4*width*height)
|
||||
gl.ReadPixels(0, 0, int32(width), int32(height), gl.RGBA, gl.UNSIGNED_BYTE, gl.Ptr(pixels))
|
||||
@ -241,8 +236,8 @@ func (c *Context) TexSubImage2D(p []uint8, width, height int) {
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Context) BindScreenFramebuffer() error {
|
||||
return c.bindFramebuffer(c.screenFramebuffer)
|
||||
func (c *Context) BindScreenFramebuffer() {
|
||||
c.bindFramebuffer(c.screenFramebuffer)
|
||||
}
|
||||
|
||||
func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
|
||||
@ -258,9 +253,7 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
|
||||
}); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if err := c.bindFramebuffer(Framebuffer(f)); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
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)
|
||||
|
@ -192,10 +192,9 @@ func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) (
|
||||
return Texture{t}, nil
|
||||
}
|
||||
|
||||
func (c *Context) bindFramebufferImpl(f Framebuffer) error {
|
||||
func (c *Context) bindFramebufferImpl(f Framebuffer) {
|
||||
gl := c.gl
|
||||
gl.BindFramebuffer(gl.FRAMEBUFFER, f.Object)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8, error) {
|
||||
|
@ -148,10 +148,9 @@ func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) (
|
||||
return Texture(t), nil
|
||||
}
|
||||
|
||||
func (c *Context) bindFramebufferImpl(f Framebuffer) error {
|
||||
func (c *Context) bindFramebufferImpl(f Framebuffer) {
|
||||
gl := c.gl
|
||||
gl.BindFramebuffer(mgl.FRAMEBUFFER, mgl.Framebuffer(f))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8, error) {
|
||||
|
@ -491,9 +491,7 @@ func (u *userInterface) loop(g GraphicsContext) error {
|
||||
return err
|
||||
}
|
||||
// The bound framebuffer must be the default one (0) before swapping buffers.
|
||||
if err := opengl.GetContext().BindScreenFramebuffer(); err != nil {
|
||||
return err
|
||||
}
|
||||
opengl.GetContext().BindScreenFramebuffer()
|
||||
_ = u.runOnMainThread(func() error {
|
||||
u.swapBuffers()
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user