Well it should be 2562563 since it’s RGB, but I’m sure it’s fine.
I’ve made a complete texturing example so that you’ve got something to look at. The only problem is that it uses LWJGL instead of JOGL, but I’m sure it can be of some help:
import java.nio.*;
import org.lwjgl.opengl.*;
public class TextureTest {
public static void main(String args[]) throws Exception {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.create();
GL11.glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
// generate a pretty texture in RGBA format
int width = 256;
int height = 256;
ByteBuffer textureData = ByteBuffer.allocateDirect(4 * width * height);
for (int y=0; y<height; y++) {
for (int x=0; x<width; x++) {
textureData.put((byte)(x|y)).put((byte)(x&y)).put((byte)(x^y)).put((byte)0xff);
}
}
textureData.rewind();
// transfer texture to the card
int textureId = 1;
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, textureData);
// IMPORTANT: gets white quad without this, and I don't know why. Mipmapping issue pherhaps.
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
while (!Display.isCloseRequested()) {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
// we want it to be white
GL11.glColor4f(1, 1, 1, 1);
// enable texturing and bind our pretty image
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
// draw a 256x256 quad
int size = 256;
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2i(200, 200);
GL11.glTexCoord2f(0, 1);
GL11.glVertex2i(200, 200+size);
GL11.glTexCoord2f(1, 1);
GL11.glVertex2i(200+size, 200+size);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2i(200+size, 200);
GL11.glEnd();
Display.update();
Thread.yield();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
Display.destroy();
}
}
}
The only thing that stands out is this line:
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
Good luck!