Improve GL error messages

This commit is contained in:
Hajime Hoshi 2015-06-22 23:14:40 +09:00
parent e3608d08eb
commit 0bc321d3ef

View File

@ -102,7 +102,7 @@ func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8,
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))
if e := gl.GetError(); e != gl.NO_ERROR { if e := gl.GetError(); e != gl.NO_ERROR {
return nil, errors.New(fmt.Sprintf("gl error: %d", e)) return nil, errors.New(fmt.Sprintf("glReadPixels: %d", e))
} }
return pixels, nil return pixels, nil
} }
@ -136,10 +136,9 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
func (c *Context) SetViewport(f Framebuffer, width, height int) error { func (c *Context) SetViewport(f Framebuffer, width, height int) error {
gl.Flush() gl.Flush()
gl.BindFramebuffer(gl.FRAMEBUFFER, uint32(f)) gl.BindFramebuffer(gl.FRAMEBUFFER, uint32(f))
err := gl.CheckFramebufferStatus(gl.FRAMEBUFFER) if err := gl.CheckFramebufferStatus(gl.FRAMEBUFFER); err != gl.FRAMEBUFFER_COMPLETE {
if err != gl.FRAMEBUFFER_COMPLETE { if e := gl.GetError(); e != 0 {
if gl.GetError() != 0 { return errors.New(fmt.Sprintf("glBindFramebuffer failed: %d", e))
return errors.New(fmt.Sprintf("glBindFramebuffer failed: %d", gl.GetError()))
} }
return errors.New("glBindFramebuffer failed: the context is different?") return errors.New("glBindFramebuffer failed: the context is different?")
} }