graphics: Better error messages for framebuffer creation

This commit is contained in:
Hajime Hoshi 2016-02-06 03:48:15 +09:00
parent 8d4ca8f8a9
commit fb9f133389
2 changed files with 12 additions and 4 deletions

View File

@ -132,8 +132,15 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
gl.BindFramebuffer(gl.FRAMEBUFFER, f) gl.BindFramebuffer(gl.FRAMEBUFFER, f)
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)
if gl.CheckFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE { s := gl.CheckFramebufferStatus(gl.FRAMEBUFFER)
return 0, errors.New("creating framebuffer failed") if s != gl.FRAMEBUFFER_COMPLETE {
if s != 0 {
return 0, errors.New(fmt.Sprintf("creating framebuffer failed: %d", s))
}
if e := gl.GetError(); e != gl.NO_ERROR {
return 0, errors.New(fmt.Sprintf("creating framebuffer failed: (glGetError) %d", e))
}
return 0, errors.New(fmt.Sprintf("creating framebuffer failed: unknown error"))
} }
return Framebuffer(f), nil return Framebuffer(f), nil

View File

@ -195,8 +195,9 @@ func (c *Context) NewFramebuffer(t Texture) (Framebuffer, error) {
c.bindFramebuffer(Framebuffer{f}) c.bindFramebuffer(Framebuffer{f})
gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, t.Object, 0) gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, t.Object, 0)
if gl.CheckFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE { s := gl.CheckFramebufferStatus(gl.FRAMEBUFFER)
return Framebuffer{nil}, errors.New("creating framebuffer failed") if s != gl.FRAMEBUFFER_COMPLETE {
return Framebuffer{nil}, errors.New(fmt.Sprintf("creating framebuffer failed: %d", s))
} }
return Framebuffer{f}, nil return Framebuffer{f}, nil