I am relatively new to OpenGL programming (only about 6 months experience) and I have having some troubles using glTexImage2D and Texture objects. My application draws a polygon (rectangular polygon made from two triangles) in 3D space and textures an image onto it. Sometimes, during the course of execution the image is modified somewhat, and I need to make sure that the polygon’s texture changes to reflect it. My application is XWindows based, using Motif GLwDrawingArea widgets. This is all of the texture code in my application:
This code is present in my object’s constructor to create the texture object and store some texture settings
// Initialize texture object
Whenever the image changes, this code is called to modify the texture object to reflect the change. _imageBuf contains the correct image data (I have verified this)
// Bind (select) this image’s texture object
// Assign the texture image
glTexImage2D(GL_TEXTURE_2D, 0 , 3, _texWidth, _texHeight, 0, GL_LUMINANCE,GL_UNSIGNED_BYTE, _imageBuf);
My draw routine contains this code to draw the polygon and texture it.
// Draw the fluoro image
glTexCoord2f(0.0, 1.0); glVertex2f((-1.0*(texWidth/2)),(-1.0*(texHeight/2)));
Now, I have gotten into a state where sometimes the texture is updated and sometimes it is not. I am just looking to any of the gurus out there who may be able to point out a serious flaw in my way of texturing. Sorry for the long-winded post.
[This message has been edited by GregR (edited 05-11-2000).]