View Full Version : Texture Replication
02-20-2004, 06:49 AM
I'm having a rather strange issue that I'm having a hard time tracking down. I have my program working such that I can load an image, bind it, and have it display correctly. My problem is, when I try and create two of my entities, it uses the last texture loaded on both of them. I'm using DevIL to load images for me (which appears to be working fine) and I'm getting my texture objects bound correctly (at least, it's returning different names for each). Has anyone else had any other problems like this and might have a suggestion on where to look into? Thanks much!
02-20-2004, 09:18 AM
DevIL will not manage multiple GL textures. ilBindImage does not switch GL to a different texture object.
You must create multiple texture objects and bind them before telling DevIL to hand the image data to GL.
If that did make sense or doesn't work, post your texture setup code, please.
02-20-2004, 10:25 AM
Thanks for the quick response! Yes, your message makes sense and I'll give it a try as soon as I get home from work http://www.opengl.org/discussion_boards/ubb/smile.gif Thanks!
02-20-2004, 07:04 PM
Okay, I think I'm finally getting to the bottom of my issue here... it appears that ilGenImages is generating the same number multiple times? I'm not deleting any images in between my calls to ilGenImage or anything... am I wrong, or isn't it supposed to automatically increment the image name (like opengl? which, btw, is incrementing like it's supposed to http://www.opengl.org/discussion_boards/ubb/wink.gif
If you have any idea why this might be happening, I'd love to hear. Thanks!
02-20-2004, 09:38 PM
Here's my texturing code that goes along with my problem (obviously this isn't 100% complete due to a lack of class definitions and such, but those should be pretty self-explanitory)
ILuint Width = ilGetInteger(IL_IMAGE_WIDTH);
ILuint Height = ilGetInteger(IL_IMAGE_HEIGHT);
ILubyte *Data = ilGetData();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
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, GL_RGB, Width, Height, 0, GL_RGB, GL_UNSIGNED_BYTE, Data);
glVertex3d(this->verts.x, this->verts.y, this->verts.z); // bottom left corner
glVertex3d(this->verts.x, this->verts.y, this->verts.z); // bottom right corner
glVertex3d(this->verts.x, this->verts.y, this->verts.z); // top right corner
glVertex3d(this->verts.x, this->verts.y, this->verts.z); // top left corner
02-21-2004, 06:34 AM
I suggest you ask on the support forum for your image loading library. This appears to not be OpenGL related at all -- and ceratainly not "advanced."
02-21-2004, 08:53 AM
I posted on the library forum as well. I posted here originally because I didn't know if it was an issue with the library or opengl, and I posted back here in hopes of hearing from zeckensack again, as he has apparently used DevIL in the past. Thanks for being so helpful, though...
02-21-2004, 10:22 AM
Yes, I've used DevIL, briefly. Your code appears to be correct. It's expected that DevIL returns the same image name, because when you call ilGenImages the second time, you've already deleted the first DevIL-image. The name is free again, so it's alright if DevIL reuses it.
(and besides, you're reinitializing DevIL anyway)
The only thing I don't really recognize is ilutRenderer(ILUT_OPENGL). If that turns on some automatic image forwarding to OpenGL, it may be the cause of your problems. Try removing that one line and see what happens.
(though IMO it shouldn't do anything, as you don't use any other ilut functions)
Anyway, the OpenGL related parts of the code are correct. I agree that this topic doesn't exactly belong here. I now somewhat suspect that you simply pass the wrong filename to the function.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.