Texture Question using DevIL

I am trying to wrap a texture around a sphere. I was able to follow the tutorial on http://home.clara.net/paulyg/ogl.htm to load the texture of the earth in .raw form. However, the image I want to use is a jpg, so I downloaded DevIL. I think that I am loading the texture correctly because I am not getting any errors. But my sphere is turning out black. Here is my code:

GLuint texture[1];


texture[0] = ilutGLBindTexImage();

glColor4f(1.0, 1.0, 1.0, 1.0 );
glBindTexture(GL_TEXTURE_2D, texture[0]); // Select Our Texture
GLUquadricObj* qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj, GLU_FILL );
gluQuadricNormals (qobj, GLU_SMOOTH);
gluQuadricTexture (qobj, GL_TRUE );
gluSphere(qobj, Radius, 50, 50);


Thanks for your help,

Generally a good sign that your not setting up textures correctly is when everything goes white. Everything going black is usually a sign that you’ve set up the lighting wrong. Can’t see any lighting stuff in the code you sent. Are you using lights anywhere else?

Try this, the proper way to set up a devIL image is like this. They way you have it setup might cause some issues.

ilGenImages(1, &Image);
ilDeleteImages(1, &Image);

glBindTexture (GL_TEXTURE_2D, Image);

also your main loop should resemble this.

//ilut initialization

//glut setup
glutInit(&argc, argv);

//ilut setup for opengl

//input setup
//Scene setup
//continue glut setup


return 0;

henryj -
I don’t think its the lighting, because I didn’t use any.

dabeav -
Using the setup for devIL you suggested, my sphere turned white. Any ideas???

Thanks again,

is the jpg image in n^2 size?


Lets start from square one here. First, what Compiler you using? I know that devIL has to have the Code Generation set to multithreaded dll to work correctly, did you change that setting in the compiler?

Second, did you add glut to your project.

Third, how did you set up your devIL image variable, I use ILuint, which maps to a C++ unsinged int. But I stick with the ILuint to keep things portable. ie: ILuint Image;

Forth, did you set up your main “exactly” like shown?
ilInit(); HAS to come before glutInit();
and ilutRenderer(ILUT_OPENGL); has to come after glutInit(); or it wont work at all.

If this dosnt work, please either post more code, we will get this yet.

Edit: Oh by the way, i dont think you need these
iluInit(); ilutInit();

[This message has been edited by dabeav (edited 06-26-2002).]

I believe that the image is n^2.

I’m using BCB 5. I’m not quite sure how to check the multithreaded dll setting.

I’m currently in the process of adding glut to my project, its taking me a bit, because I’ve never used the library before.

I used ILuint as my image variable.

So I’ll get back to you with more code once I finish adding the glut.


Also check the size of image and the memory it will occupy on board. We have images turning black when we exceed the maximum texture size of 4kx4k on our boards (2kx2k on older boards). This also occurs when the total texture memory on the board is exceeded (for instance, loading 2 4K textures)… Remember some boards store 4 bytes per pixel reguardless of image, so 4kx4k (16mb * color components RGBA) would be 64Mb, no room even for rasterization on a 64Mb board. Mipmapping increases texture memory by 4/3. When you exceed a limit, a board/driver has two choices, ignore it, or swap with real memory. Both choices are bad… Ignoring it often results in black-out textures (especially on Nvidia hardware), swapping generally results in an instant drop to 1/10 frame rate or less. Image size for mip-mapping, I think, is limited to 512x512 max on some boards, so you can only go higher in texture size if you don’t use mipmaps (however, that problem, in my experience, is generally characterized by a crash of the program during Mip-map creation and storage). When diagnosing texture problems, I often drop the texture size down to 512x512 or 256x256 for debugging and then step up from there. There are also serious performance problems with textures greater than 1kx1k on pre lightning memory architecture boards (DDR double pumped throughput).

[This message has been edited by Jeffry J Brickley (edited 06-26-2002).]

Ok, I believe Ilut, operates ontop of glut, so you need that atleast initialized in the program. Im not positive, but I think so. Never tried it without. But you do have to figure out how to set the multithreaded DLL setting to your project, thats a biggie, may not be causing your problem currently, but will eventualy. Let me know how things work out for ya.

Thank you to everybody for you help. With a little bit of work and a lot of frustration I was finally able to correct my code and get an error message.

The line:

always returns false, so I’m checking into that. But, thanks again.

ilLoadImage(“image.jpg”); would be the right syntax. remembering the “”. Also if your coding for linux, or mac, remember that there Case sensative.

Who-hoo!!! I finally got it working. I think some of the image files were corrupted and that’s why I was getting an error. But thanks.