Buffer problems - glTexImage2D

Started by rwgedeon, June 06, 2005, 00:44:56

Previous topic - Next topic

rwgedeon

Hi... I'm new here... I'm working on a 2D LWJGL game now, and I'm using DevIL for textures. I've been having problems with DevIL and Buffer(s).
Here's my fields and the method in my static TextureLoader class.


// fields
private static IntBuffer imageNames; // IL's image names
private static IntBuffer texNames; // GL's texture names
private static ByteBuffer texData; // actual texture data

// my tex load method
public static void loadImage()
{
       imageNames = BufferUtils.createIntBuffer(1);
       IL.ilGenImages(imageNames);
       IL.ilBindImage(imageNames.get(0));        
       IL.ilLoad(IL.IL_BMP, "F:\\TEST\\tex.bmp");                
       texData = IL.ilGetData();        
       texNames = BufferUtils.createIntBuffer(1);
       GL11.glGenTextures(texNames);
       GL11.glBindTexture(GL11.GL_TEXTURE_2D, texNames.get(0));        
       // this is where things seem to mess up
       GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 256,   256, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, texData);
}


Whenever I run the program I get this message when the program hits glTexImage2D:

IllegalArgumentException:
Number of remaining buffer elements is 196608, must be at least 262144 (in org.lwjgl.BufferChecks)


Any ideas at all? Must be related to that last parameter, the ByteBuffer. I'm pretty sure nothing's wrong with DevIL...My LWJGL/DevIL versions are completely up to date, by the way. Help!

Matzon

Problem is that the data you have is RGB (196608 bytes), and you specify it is RGBA (262144 bytes)

rwgedeon

Oops... Thank you very much, thought I was doing the buffers wrong or something. I'm guessing I would actually need an image with alpha data if I wanted alpha.

Again, thank you.