I’m using the LWJGL library to learn openGL. I am storing my pixel data in an IntBuffer. I made a call to glTexImage2D to map the pixels to a texture. I used the IntBuffer to make a checkerboard pattern of blues and white. I’m placing the following numbers for the components to represent blue (0, 0, 255, 255). When the texture was rendered, the checkerboard was a yellow instead of blue. I then tested all the components individually and found out the representation is in the order of ABGR instead of RGBA as I had thought.
I was following a tutorial that used the order or RGBA. It is a glut tutorial.
Here is the placement of pixel data
if ((i / 128 & 16 ^ i % 128 & 16) > 0) {
checkerBoard.put(i, 255);
checkerBoard.put(i, (checkerBoard.get(i) << 8) + 255);
checkerBoard.put(i, (checkerBoard.get(i) << 8) + 255);
checkerBoard.put(i, (checkerBoard.get(i) << 8) + 255);
} else {
checkerBoard.put(i, 0);
checkerBoard.put(i, (checkerBoard.get(i) << 8) + 0);
checkerBoard.put(i, (checkerBoard.get(i) << 8) + 255);
checkerBoard.put(i, (checkerBoard.get(i) << 8) + 255);
}
Here is my call to glTexImage2D
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
It is another class and checkerBoard is referenced by pixels.
Am I not thinking right or is this a system specific big/little endian scenario?