PDA

View Full Version : glTexImage2D issues with data display



Michael Price
12-16-2010, 05:17 AM
All,

I am working with some legacy code written (and working) in openGL. However, my target environment is the SC profile, therefore the only parameters I can use with glPixelStorei is GL_[UN]PACK_ALIGNMENT.

I can't get the textures to display. I've pasted my code below. The commented out lines are the ones that I have removed from the legacy code (slightly sanitised to make some sense to everyone).

The format of the data area is a 3D array: plotData[512][512][4]

// glPixelStorei( (GLenum)GL_UNPACK_ROW_LENGTH, 512 );
// temp = lonTexture*64;
// glPixelStorei( (GLenum)GL_UNPACK_SKIP_PIXELS, (GLint) temp);
// temp = latTexture*64;
// glPixelStorei( (GLenum)GL_UNPACK_SKIP_ROWS, (GLint) temp);
// glPixelStorei( (GLenum)GL_PACK_ALIGNMENT, 1 );

glPixelStorei( (GLenum)GL_UNPACK_ALIGNMENT, 1 );

glBindTexture( (GLenum)GL_TEXTURE_2D, this->plotTextures->textures[latTexture][lonTexture]);
glTexParameteri((GLenum)GL_TEXTURE_2D, (GLenum)GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri((GLenum)GL_TEXTURE_2D, (GLenum)GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri((GLenum)GL_TEXTURE_2D, (GLenum)GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri((GLenum)GL_TEXTURE_2D, (GLenum)GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D((GLenum)GL_TEXTURE_2D, 0, 4, 64, 64, 0,
(GLenum)GL_RGBA, (GLenum)GL_UNSIGNED_BYTE, this->plotData);

I've looked at a number of examples and they haven't got me anywhere yet.

Any suggestions gratefully received. I've not done much with openGL before and need to get this conversion to the SC profile done ASAP.

Regards,
Michael Price