opengl: Use gl.IsTexture and gl.IsFramebuffer

This commit is contained in:
Hajime Hoshi 2016-02-25 00:26:16 +09:00
parent 6d5e09ad36
commit 06ec244ff3

View File

@ -111,8 +111,8 @@ func (c *Context) Check() {
func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) (Texture, error) { func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) (Texture, error) {
t := gl.CreateTexture() t := gl.CreateTexture()
if t.Value < 0 { if !gl.IsTexture(t) {
return Texture{}, errors.New("opengl: glGenTexture failed") return Texture{}, errors.New("opengl: creating texture failed")
} }
gl.PixelStorei(mgl.UNPACK_ALIGNMENT, 4) gl.PixelStorei(mgl.UNPACK_ALIGNMENT, 4)
gl.BindTexture(mgl.TEXTURE_2D, t) gl.BindTexture(mgl.TEXTURE_2D, t)
@ -160,8 +160,8 @@ func (c *Context) BindZeroFramebuffer() {
func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) { func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
f := gl.CreateFramebuffer() f := gl.CreateFramebuffer()
if f.Value == 0 { if !gl.IsFramebuffer(f) {
return Framebuffer{}, errors.New("opengl: creating framebuffer failed: gl.CreateFramebuffer must not return 0") return Framebuffer{}, errors.New("opengl: creating framebuffer failed: gl.IsFramebuffer returns false")
} }
gl.BindFramebuffer(mgl.FRAMEBUFFER, f) gl.BindFramebuffer(mgl.FRAMEBUFFER, f)