PDA

View Full Version : glTexImage2D and glGetTexImage Issue



divas
08-23-2009, 11:42 PM
I m trying to test glTexImage2D and glGetTexImage but it does not seem to work

i m filling a input texture with 5 but when geeting the data using glGetTexImage it contains only 0. where i m wrong ?

unsigned short* data = new unsigned short[32*32]();
for(int i = 0 ; i < 32*32 - 1; i++)
{
data[i] = 5;
}

GLuint textureID;
glGenTextures(1, &amp;textureID);

glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA16F_ARB, 32, 32, 0, GL_ALPHA16, GL_UNSIGNED_SHORT, data);




unsigned short *pVolumedata = new unsigned short[32*32]();
glBindTexture(GL_TEXTURE_2D, textureID);
glGetTexImage( GL_TEXTURE_2D, 0, GL_ALPHA16F_ARB, GL_UNSIGNED_SHORT, pVolumedata );



delete data;
delete pVolumedata;

scratt
08-24-2009, 12:17 AM
Can you use float textures with glGetTexImage?
I am not sure that you can.

divas
08-24-2009, 01:30 AM
but i want to read a float texture, then how should i do it.