Hello Guest

TextureLoader Tutorial

  • 3 Replies
  • 19870 Views
TextureLoader Tutorial
« on: January 22, 2008, 15:16:46 »
I tried the TextureLoader Tutorial http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/devil/loadingtextures,
and for some reasons, I don't get it to work! I'm trying to load a jpeg-file.

I added

Code: [Select]
IL.create();
ILU.create();
ILUT.create();
      
after trying to load a Texture the first time, it throws a NullPointer-Exception when executing this part:

Code: [Select]
if (!IL.ilLoadFromURL(IL.class.getClassLoader().getResource(name))) {
return null;
}

I replaced it with:

Code: [Select]
if(!IL.ilLoadImage(name)) {
return null;
}

No the Exception is throwed around this part:

Code: [Select]
GL11.glGenTextures(scratch);

GL11.glBindTexture(GL11.GL_TEXTURE_2D, scratch.get(0));
oglImageHandle = scratch.get(0);


And I'm using it like this:

Code: [Select]
...
Texture tex = TexureLoader.loadTexture("resources/texture.jpg", false);
...

Does somebody got a clue whats wrong? Or is it my fault...I'm a bit confused...


Thanks in advance!

*

Offline Matzon

  • *****
  • 2242
Re: TextureLoader Tutorial
« Reply #1 on: January 22, 2008, 15:32:10 »
are you *sure* that it actually reads the file ?

Re: TextureLoader Tutorial
« Reply #2 on: January 22, 2008, 16:36:45 »
are you *sure* that it actually reads the file ?


I checked the variables width,height, textureWidthSize & textureHeightSize and they are correct (256 all of them). I think they would be
something like 0 if the picture wasn't read properly...also the imageData-Object says that 262144 Elemtents are remaining.


Shall I post the code?


« Last Edit: January 22, 2008, 16:38:18 by funkinlocke »

Re: TextureLoader Tutorial
« Reply #3 on: January 22, 2008, 16:41:13 »
are you *sure* that it actually reads the file ?


I checked the variables width,height, textureWidthSize & textureHeightSize and they are correct (256 all of them). I think they would be
something like 0 if the picture wasn't read properly...also the imageData-Object says that 262144 Elemtents are remaining.


Shall I post the code?





Forget about it, just found the error... i was calling the loading-function before GL11 was created...  :o


Thanks!
« Last Edit: January 22, 2008, 16:44:31 by funkinlocke »