PDA

View Full Version : about glTexImage2D problem



jebe7282
01-11-2013, 08:59 PM
hi,guys,
I have two array that contains pixels that glTexImage2D needed .
As u know , the two are equal in the memory . i pass pixels data to glTexImage2D .
but they produce different results.
i dont'know why .

GLubyte pixels[4 * 4] =
{
255, 0, 0 , 255, // Red
0, 255, 0, 255,// Green
0, 0, 255, 255,// Blue
255, 255, 0 ,255// Yellow
};

// GLuint pixels2[4 ] =
// {
// (255L<<24)+(0<<16)+ (0<<8)+255,
// (0<<24)+(255L<<16)+(0<<8)+255,
// (0<<24)+(0<<16)+ (255L<<8)+255,
// (255L<<24)+(255L<<16)+(0<<8)+255,
// };

glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2 , 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels );


thank u in advance. any feedback will be appreciate.:)

aqnuep
01-11-2013, 09:38 PM
You are wrong, those two arrays are not equivalent on a system using little-endian format (http://en.wikipedia.org/wiki/Endianness). Also, this is not really an OpenGL question.

aqnuep
01-11-2013, 09:40 PM
Ignore the comment of Nowhere-01, he/she is confusing things. The problem is the endianness. There is no "incorrect interpretation". Everything is well defines and what he is referring to (integer texture formats) are a completely different thing.

Nowhere-01
01-11-2013, 09:46 PM
Ignore the comment of Nowhere-01, he/she is confusing things. The problem is the endianness. There is no "incorrect interpretation". Everything is well defines and what he is referring to (integer texture formats) are a completely different thing.

ok. i didn't pay attention to contents of arrays. but i don't get why would you do it like that. confusing comment was removed. it is really endianness issue.

jebe7282
01-12-2013, 01:45 AM
oh ~ i get it. endianness problem. my fault. thank u mention it.:p