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
|
c.lastTexture = t
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) bindFramebuffer(f Framebuffer) error {
|
func (c *Context) bindFramebuffer(f Framebuffer) {
|
||||||
if c.lastFramebuffer.equals(f) {
|
if c.lastFramebuffer.equals(f) {
|
||||||
return nil
|
return
|
||||||
}
|
|
||||||
if err := c.bindFramebufferImpl(f); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
c.bindFramebufferImpl(f)
|
||||||
c.lastFramebuffer = f
|
c.lastFramebuffer = f
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) SetViewport(f Framebuffer, width, height int) error {
|
func (c *Context) SetViewport(f Framebuffer, width, height int) error {
|
||||||
if err := c.bindFramebuffer(f); err != nil {
|
c.bindFramebuffer(f)
|
||||||
return err
|
|
||||||
}
|
|
||||||
if c.lastViewportWidth != width || c.lastViewportHeight != height {
|
if c.lastViewportWidth != width || c.lastViewportHeight != height {
|
||||||
if err := c.setViewportImpl(width, height); err != nil {
|
if err := c.setViewportImpl(width, height); err != nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -169,14 +169,11 @@ func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) (
|
|||||||
return texture, nil
|
return texture, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) bindFramebufferImpl(f Framebuffer) error {
|
func (c *Context) bindFramebufferImpl(f Framebuffer) {
|
||||||
if err := c.runOnContextThread(func() error {
|
_ = c.runOnContextThread(func() error {
|
||||||
gl.BindFramebuffer(gl.FRAMEBUFFER, uint32(f))
|
gl.BindFramebuffer(gl.FRAMEBUFFER, uint32(f))
|
||||||
return nil
|
return nil
|
||||||
}); err != nil {
|
})
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8, error) {
|
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 {
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := c.bindFramebuffer(f); err != nil {
|
c.bindFramebuffer(f)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := c.runOnContextThread(func() error {
|
if err := c.runOnContextThread(func() error {
|
||||||
pixels = make([]uint8, 4*width*height)
|
pixels = make([]uint8, 4*width*height)
|
||||||
gl.ReadPixels(0, 0, int32(width), int32(height), gl.RGBA, gl.UNSIGNED_BYTE, gl.Ptr(pixels))
|
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 {
|
func (c *Context) BindScreenFramebuffer() {
|
||||||
return c.bindFramebuffer(c.screenFramebuffer)
|
c.bindFramebuffer(c.screenFramebuffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
|
func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
|
||||||
@ -258,9 +253,7 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
if err := c.bindFramebuffer(Framebuffer(f)); err != nil {
|
c.bindFramebuffer(Framebuffer(f))
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
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.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, uint32(texture), 0)
|
||||||
s := gl.CheckFramebufferStatus(gl.FRAMEBUFFER)
|
s := gl.CheckFramebufferStatus(gl.FRAMEBUFFER)
|
||||||
|
@ -192,10 +192,9 @@ func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) (
|
|||||||
return Texture{t}, nil
|
return Texture{t}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) bindFramebufferImpl(f Framebuffer) error {
|
func (c *Context) bindFramebufferImpl(f Framebuffer) {
|
||||||
gl := c.gl
|
gl := c.gl
|
||||||
gl.BindFramebuffer(gl.FRAMEBUFFER, f.Object)
|
gl.BindFramebuffer(gl.FRAMEBUFFER, f.Object)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8, error) {
|
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
|
return Texture(t), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) bindFramebufferImpl(f Framebuffer) error {
|
func (c *Context) bindFramebufferImpl(f Framebuffer) {
|
||||||
gl := c.gl
|
gl := c.gl
|
||||||
gl.BindFramebuffer(mgl.FRAMEBUFFER, mgl.Framebuffer(f))
|
gl.BindFramebuffer(mgl.FRAMEBUFFER, mgl.Framebuffer(f))
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8, error) {
|
func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8, error) {
|
||||||
|
@ -491,9 +491,7 @@ func (u *userInterface) loop(g GraphicsContext) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// The bound framebuffer must be the default one (0) before swapping buffers.
|
// The bound framebuffer must be the default one (0) before swapping buffers.
|
||||||
if err := opengl.GetContext().BindScreenFramebuffer(); err != nil {
|
opengl.GetContext().BindScreenFramebuffer()
|
||||||
return err
|
|
||||||
}
|
|
||||||
_ = u.runOnMainThread(func() error {
|
_ = u.runOnMainThread(func() error {
|
||||||
u.swapBuffers()
|
u.swapBuffers()
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user