PDA

View Full Version : glGetTexImage not working...



Sanctus Animus
01-10-2004, 10:06 PM
Hi, I'm currently programming a kind of "worms" game where projectiles must make holes in the ground. To make this, I found the idea to set the alpha bytes to 0 around the explosion. Right now, I use .png files with RGBA format, and I have now problem showing them on screen. My problem is the fact that after using glGetTexImage in the following part of code, the pixels are not read (the data pointed isn't changed), but I get no glError!

Here is the code, and thanks for your help!

int w,h;
glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTUR E_WIDTH,&w);
glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTUR E_HEIGHT,&h);
GLubyte *pixels = new GLubyte[w*h*4];
glBindTexture(GL_TEXTURE_2D, TexID);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
delete [] pixels;

mw
01-11-2004, 03:56 AM
Why do you read back your texture images anyway? Just keep the original data you used when calling glTexImage2d and use glTexSubImage2D to update the corresponding texture (after the first call of glTexImage2D) - this should be much faster than reading textures back, change them and writing them again.