Hello,
I have got problems creating a texture with lwjgl.
Here’s the code:
loading data:
tga x = new tga();
x.load(new File("./test2.tga"));
ByteBuffer f = x.getPixelData();
TexBuf = BufferUtils.createIntBuffer(5);
GL11.glGenTextures(TexBuf);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, TexBuf.get(0));
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, x.getWidth(), x.getHeight(),
0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, x.getPixelData()); *
rendering code:
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glPushMatrix();
GL11.glTranslatef(0.0f, 0.0f, -12.0f );
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0.0f,0.0f);
GL11.glVertex3f(-1.0f, -1.0f, 0.0f);
GL11.glTexCoord2f(1.0f,0.0f);
GL11.glVertex3f(1.0f, -1.0f, 0.0f);
GL11.glTexCoord2f(1.0f,1.0f);
GL11.glVertex3f(1.0f, 1.0f, 0.0f);
GL11.glTexCoord2f(0.0f,1.0f);
GL11.glVertex3f(-1.0f, 1.0f, 0.0f);
GL11.glEnd();
GL11.glPopMatrix();
The tga getPixelData Method returns a ByteBuffer with the Pixeldata. I use only 24Bit TGAs with no alphabits.
I get a java.nio.BufferOverflowException in the line marked with the *
What am I doing wrong? I can’t really figure out at the moment. If you want I can post the tga-loading code, but it is really hacked together.
Greetings
thalador
