Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: about glTexImage2D problem

  1. #1
    Newbie Newbie
    Join Date
    Jan 2013
    Posts
    2

    Question about glTexImage2D problem

    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.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985
    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.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985
    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.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  4. #4
    Member Regular Contributor Nowhere-01's Avatar
    Join Date
    Feb 2011
    Location
    Novosibirsk
    Posts
    251
    Quote Originally Posted by aqnuep View Post
    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.
    Last edited by Nowhere-01; 01-11-2013 at 10:53 PM.

  5. #5
    Newbie Newbie
    Join Date
    Jan 2013
    Posts
    2
    oh ~ i get it. endianness problem. my fault. thank u mention it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •