Texture mapping does not work correctly using OpenGL -


the goal of program mix video stream kinect simple triangle using opengl. display video stream load simple quad , put video frame buffer on classical texture mapping. until here ok. if add in scene simple colored triangle (red, green , blue 3 vertices) triangle displayed correctly texture tainted in blue. in fact api seems keep last color loaded last vertex of triangle, blue color here. don't understand why keep it.

here's screen of first frame (all correct):

enter image description here

and appearence of second , following frames :

enter image description here

and c++ rendering code :

    getkinectvideodata(_videodata); //method fills video frame buffer each frame      glclear(gl_color_buffer_bit | gl_depth_buffer_bit);     glclearcolor(0.0f, 0.0f, 0.0f, 1.0f);     glcleardepth(1.0f);      glviewport(0, 0, width, height);     glmatrixmode(gl_projection);     glloadidentity();     gluperspective(45.0f, (float)width/(float)height, 1.0f, 100.0f);     glulookat(0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);      glmatrixmode(gl_modelview);      glbindtexture(gl_texture_2d, textureid);       gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_nearest);     gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_nearest);     glteximage2d(gl_texture_2d, 0, gl_rgba8, width, height, 0, gl_bgra_ext, gl_unsigned_byte, (glvoid*)_videodata);     glbindtexture(gl_texture_2d, 0);      glenable(gl_texture_2d);      glbindtexture(gl_texture_2d, textureid);     gltexsubimage2d(gl_texture_2d, 0, 0, 0, width, height, gl_bgra_ext, gl_unsigned_byte, (glvoid*)_videobuffer->getbuffer());      glbegin(gl_quads);     gltexcoord2f(0.0f, 0.0f);     glvertex3f(-1, -1, 0.0f);     gltexcoord2f(1.0f, 0.0f);     glvertex3f(1, -1, 0.0f);     gltexcoord2f(1.0f, 1.0f);     glvertex3f(1, 1, 0.0f);     gltexcoord2f(0.0f, 1.0f);     glvertex3f(-1, 1, 0.0f);     glend();      glbindtexture(gl_texture_2d, 0);      gldisable(gl_texture_2d);      glbegin(gl_triangles);     glcolor3ub(255, 0, 0);     glvertex3f(0.0f, 0.75f, 0.0f);     glcolor3ub(0, 255, 0);     glvertex3f(0.75f, 0.0f, 0.0f);     glcolor3ub(0, 0, 255);     glvertex3f(-0.75f, 0.0f, 0.0f);     glend(); 

i clear buffer @ begin of each frame using glclear call it's strange. can me?

you have reset color (255, 255, 255) (using glcolor), because impacts texture processing.

on first frame, color full white, , image displayed correctly. however, last call glcolor (0,0,255), , loop goes beginning.


Comments