I have a simple OpenGL application where I have 2 objects displayed on screen:
1) particle system, where each particle is texture mapped with glTexImage2D() call. In the drawEvent function, I draw it as a GL_TRIANGLE_STRIP with 4 glVertex3f.
2) a 3D text loaded from an object file, where each point is loaded using glNewList/glGenLists and store each point as glVertex. I draw it by making call to glCallList.
The problem is as soon as I call glTexImage2D() to map my particle with a .bmp file, the 3D text would not show on the screen. The particle would look fine. (this is not expected)
If I dont call glTexImage2D, I see both the 3D text and particle system. In this case, particle system looks horrible because I didnt texture map with anything. (this is expected)
Does anyone know why using call list and glTexImage2D might conflict with each other?
EDIT i also forgot to mention: I do call glBindTexture(GL_TEXTURE_2D, this->texture); inside the drawLoop before particle system is called.
EDIT2 i only call glTexImage2D() once at system start up (when I texture mapped the bitmap)
glTexImage2D uploads the texture to the video-ram (simplified said).
If OpenGL would allow you to place a glTexImage2D call inside the list it had to store the pixel-data in the list as well. Now what happends if you would execute the list? You would upload the same image data into the same texture all over gain.
That makes no sense, therefore it’s left out.
If you want to change textures between draw calls use glBindTexure. That call sets the current texture. It’s much faster.
Regarding your image-upload via glTexImage2D: Do that only once for each texture. Either at the start of your program (if it’s small) or each time you load new content from disk.