hello,
i am trying to generate textures without using jogl’s Texture and TextureIO classes. this is what i try:
// the file is a 256*256*4 TGA so i am reading from the 12th byte
try {
fileinputstream.read( b,12,256*256*4-12 );
buffer = ByteBuffer.wrap(b);//.allocate(256*256*4);
buffer.rewind();
} catch (IOException e) {
e.printStackTrace();
}
texId = IntBuffer.allocate(1);
gl.glGenTextures(1, texId);
gl.glBindTexture(GL.GL_TEXTURE_2D, texId.get(0));
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, 256, 256, 0, GL.GL_RGBA, GL.GL_BYTE, buffer);
if i look into the ByteBuffer the data really seems to be there. it contains values from -127 to 128.
then i try to render it this way
gl.glBindTexture(GL.GL_TEXTURE_2D, texId.get(0));
gl.glBegin(GL.GL_QUADS);
gl.glTexCoord2d(0,0);
gl.glVertex2i(0, 0);
gl.glTexCoord2d(1,0);
gl.glVertex2i(100, 0);
gl.glTexCoord2d(1,1);
gl.glVertex2i(100, 100);
gl.glTexCoord2d(0,1);
gl.glVertex2i(0, 100);
gl.glEnd();
unfortunately i only see a white quad. no texture at all. when i use the textureIO functions the texture displays correctly.
what am i doing wrong? thanks!