java - LWJGL Texture Unbinding -
i'm working on simple textured rectangle class using lwjgl (gl11). have far in draw method.
glenable(gl_texture_2d); color.bind(); glbegin(gl_quads); t.bind(); if (centered) { gltexcoord2d(0, 0); glvertex2d(x - (width / 2), y - (height / 2)); gltexcoord2d(t.getwidth(), 0); glvertex2d(x + (width / 2), y - (height / 2)); gltexcoord2d(t.getwidth(), t.getheight()); glvertex2d(x + (width / 2), y + (height / 2)); gltexcoord2d(0, t.getheight()); glvertex2d(x - (width / 2), y + (height / 2)); } else { gltexcoord2d(0, 0); glvertex2d(x, y); gltexcoord2d(t.getwidth(), 0); glvertex2d(x + width, y); gltexcoord2d(t.getwidth(), t.getheight()); glvertex2d(x + width, y + height); gltexcoord2d(0, t.getheight()); glvertex2d(x, y + height); } glend(); glbindtexture(gl_texture_2d, 0); gldisable(gl_texture_2d);
the problem second last line (glbindtexture(gl_texture_2d, 0)
). if leave on, image display split second (probably 1 frame) , turn solid white. if comment out, display, displays last texture loaded. ideas?
i think it's because binding texture between glbegin() , glend() calls. invalid. i'm guessing when leave glbindtexture(gl_texture_2d, 0) call off, binding taking effect next frame. not sure why work 1 frame, though.
you can use glgeterror see if there errors generated.
Comments
Post a Comment