tags:

views:

557

answers:

2

Hi,

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)

+1  A: 

It might not be a conflict of glTexImage2D and glCallList at all. Is your texture mapping ok ? have you set the texture coordinates propperly? Try checking for a vertex to texture coordinates missmatch.

Azder
texture mapping looks ok for my particle system. the two, when instantiated independently, work fine. it's only when i to have them both displayed on the same screen, it doesnt work.
ShaChris23
+1  A: 

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.

Nils Pipenbrinck
hi nils..yes i only call glTextImage2D once (at the start of the program)
ShaChris23
if you do so, why do you want to put it into a list?
Nils Pipenbrinck
hi..i'm sorry i dont explain clearly. i put all of my 3D fonts into a list. for particle system, i use glGenTextures(1, glBindTexture(GL_TEXTURE_2D, this->texture); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
ShaChris23