gl.texImage2D

Ok I have this image data in ARGB format but apparently OpenGL/LWJGL doesn’t like that. What’s the best way to get this data loaded as a texture? Do I need to just reposition the alpha bytes and just do GL.RGBA?

:confused:

Now no matter what I change the color values to, it just comes out red.

?

java Bytes is different of Unisgned Bytes, it used to trick me with RGBA images

okay… wanna elaborate on that? How would I pack an int with valid values?

Ok when I rip pixels from an image and give them to opengl it works, aside from the colors being wrong.

but lets say i do this

Edit: note that this isnt acually converting anything yet
public static final int[] ARGBtoRGBA( int[] temp ) {
final int n = temp.length;
int[] pixs = new int[ n ];

        for ( int i = 0; i < n; i++ ) {
              int a = temp[ i ] >> 24 & 0xFF;
              int r = temp[ i ] >> 16 & 0xFF;
              int g = temp[ i ] >> 8 & 0xFF;
              int b = temp[ i ] >> 0 & 0xFF;
              
              //System.out.println("before: " + a + " " + r + " " + g + " " + b );
              
              pixs[ i ] = ( ( ( byte ) a << 24 ) |
                          ( ( byte ) r << 16 ) |
                          ( ( byte ) g << 8 ) |
                          ( ( byte ) b << 0 ) );
              
              a = pixs[ i ] >> 24 & 0xFF;
              r = pixs[ i ] >> 16 & 0xFF;
              g = pixs[ i ] >> 8 & 0xFF;
              b = pixs[ i ] >> 0 & 0xFF;
              
              //System.out.println("after: " + a + " " + r + " " + g + " " + b );
        }
        
        return pixs;
  }

all i did was remove the values and place them exactly how they were in a new array and the output for pixels looks like this in one part

before: 255 24 49 45
after: 255 24 49 45
before: 255 49 49 66
after: 255 49 49 66
before: 255 76 88 91
after: 255 76 88 91
before: 255 78 99 111
after: 255 78 99 111
before: 255 79 117 118
after: 255 79 117 118
before: 255 79 117 118
after: 255 79 117 118
before: 255 78 99 111
after: 255 78 99 111
before: 255 49 65 58
after: 255 49 65 58
before: 255 8 16 16
after: 255 8 16 16
before: 255 16 49 57
after: 255 16 49 57
before: 255 12 66 78
after: 255 12 66 78
before: 255 25 84 75
after: 255 25 84 75
before: 255 16 33 24
after: 255 16 33 24
before: 255 33 96 76
after: 255 33 96 76

the same right? well when i have it return pixs instead of temp it LOOKS DIFFERENT. How the hell is that happening if the values are exactly the same?

I’ve been looking around as various sites today browsing code but I still can’t seem to answer my origional question.

Theres obviously something I’m not understanding about how this shit works. Also let’s say when i’m just returning the OG array temp, all those “alpha” values are 255 but when I tell opengl I’m using RGBA shouldnt that be the red component? The image displayed is NOT red at all, most of it is black, with some green and yellow.

It’s only turned all red when I started mixing those values around.

Is this something stupid? If so, please tell me so I can proceed in killing myself with blunt objects.

Try changing the cast from byte to int (byte is signed: -128 to 127) :slight_smile:

I thought I had tried that. I prolly had something else messed up at the time though. sigh.

Ok I solved my first problem but what the hell is going on?

I assumed doing GL.RGBA meant the pixel order would be red/green/blue/alpha?

No wonder it looked fucked up, when I put the values in alpha/blue/green/red order the image looks fine.

Did I miss that day at school? >:|

Sounds like a Little Endian vs. Big Endian thing. If the pixels are treated as 32 bit ints the interpretation would vary as to which bits go where based on endianness.