# DevIL is making no sense to me

## Recommended Posts

Hey, I'm really getting pretty frustrated about this. My goal is to draw planet earth, which will be composed of two spheres: one with the main texture map, and the second with the clouds map (GL_LUMINANCE). I'm trying to use DevIL to load the textures. So: Declare the image name:
ILuint imageName;


ilInit();
ilGenImages(1, &imageName);
ilBindImage(imageName);

ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);


Texture parameters:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH),
ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE,
ilGetData());


now this is a strange question, but: why does this work (although with texture problems... see my other thread pls ;))?! I mean, I dont do glGenTextures, I dont even do glBindTexture!! Can anyone please tell me how to load textures with DevIL properly? Huge thanks!!

##### Share on other sites
I've never used DevIL, but you might wanna check that ilGetInteger(IL_IMAGE_BPP) actually returns the number of bytes per pixel and not the number of bits per pixel.

Quote:
 now this is a strange question, but: why does this work (although with texture problems... see my other thread pls ;))?! I mean, I dont do glGenTextures, I dont even do glBindTexture!!

Well, it can work for any number of weird reasons, however you shouldn't do it :) The glGenTextures you can actually skip, and I guess you can skip the glBindTexture too, however then you don't now the ID of the texture, which will lead to all sorts of problems later on when you got more textures :)

And I guess the weird texture in your other post could be because of weird texcoords..

##### Share on other sites
Quote:
Original post by angry
I've never used DevIL, but you might wanna check that ilGetInteger(IL_IMAGE_BPP) actually returns the number of bytes per pixel and not the number of bits per pixel.

Quote:
 now this is a strange question, but: why does this work (although with texture problems... see my other thread pls ;))?! I mean, I dont do glGenTextures, I dont even do glBindTexture!!

Well, it can work for any number of weird reasons, however you shouldn't do it :) The glGenTextures you can actually skip, and I guess you can skip the glBindTexture too, however then you don't now the ID of the texture, which will lead to all sorts of problems later on when you got more textures :)

I switched to NeHe's IPicture... simpler.

Quote:
 And I guess the weird texture in your other post could be because of weird texcoords..

well... I'm using glu quadrics, like:

mapQuadric = gluNewQuadric();gluQuadricDrawstyle(mapQuadric, GLU_FILL);gluQuadricNormals(mapQuadric, GLU_SMOOTH);gluQuadricTexture(mapQuadric, GL_TRUE);

they never gave any problems before...

thanks again

##### Share on other sites
oh. my. god. I should shoot myself, really...
was missing: glEnable(GL_DEPTH_TEST)...

eheh... oops

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627644
• Total Posts
2978372

• 10
• 12
• 22
• 13
• 33