# OpenGL 2D Texturing Error

This topic is 3477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've been working on a 3d gaming application using the OpenGL API. Anyways, I'm getting a strange error with texturing. I have a model that contains only material data for lighting. The model draws perfectly well, but prior to drawing the wall I draw a skybox which is textured. So I turn on texturing, draw the skybox, turn off texturing, and draw the model. However, on random compiles, my model will draw with a certain portion being textured with one of the skybox's (Or so it looks like) textures, messing up the visual effects. It only happens every few times or so, but I'd like to see if anyone can give a valid reason for this mishap. Info: I'm using Win32 and OpenGL APIs in the Codeblocks IDE. The real interesting part is, when setting the build target in my IDE to "Debug", the above occurs. However, if I set the build target to "Release", the above occurs every time, meaning the model is messed up 100% of the time. I'm fairly comfortable using OpenGL, but can't seem to figure out why it would behave like this. If anyone can lend some information, I'd greatly appreciate it :). Thanks for your time.

##### Share on other sites
If I had to guess, I'd say that you've introduced undefined and/or non-deterministic behavior somewhere in your program (for example, an uninitialized variable). This sort of problem can lead to different behaviors depending on the build settings, just like what you've described.

Perhaps you could post the code you're using to set up the rendering state for the model and to render the model.

##### Share on other sites
Quote:
 Original post by JJFMJRI've been working on a 3d gaming application using the OpenGL API. Anyways, I'm getting a strange error with texturing. I have a model that contains only material data for lighting. The model draws perfectly well, but prior to drawing the wall I draw a skybox which is textured. So I turn on texturing, draw the skybox, turn off texturing, and draw the model. However, on random compiles, my model will draw with a certain portion being textured with one of the skybox's (Or so it looks like) textures, messing up the visual effects. It only happens every few times or so, but I'd like to see if anyone can give a valid reason for this mishap. Info: I'm using Win32 and OpenGL APIs in the Codeblocks IDE. The real interesting part is, when setting the build target in my IDE to "Debug", the above occurs. However, if I set the build target to "Release", the above occurs every time, meaning the model is messed up 100% of the time. I'm fairly comfortable using OpenGL, but can't seem to figure out why it would behave like this. If anyone can lend some information, I'd greatly appreciate it :). Thanks for your time.

I agree to what jyk has mentioned. I feel the OpenGL state machine is messed up somewhere. I usually do the following assertion in my rendering code to check the status of the error bit to make sure that the state machine is ok.
GLuint error = glGetError();assert(error == GL_NO_ERROR);

Hope this helps,
Mobeen

##### Share on other sites
yeah I thought the exact same thing, a variable initialized incorrectly. Have been searching for a while, haven't seemed to find it yet. I have been looking at the modeling class I wrote to draw the model. It loads it from a custom file that I'm using. I've had some strange problems with creating the file holding the model data in a different program. I'm thinking that it may be loading incorrectly. I'll keep looking, thanks :). Can't be too many reasons to cause this haha!

Thanks again.

1. 1
2. 2
Rutin
22
3. 3
4. 4
frob
17
5. 5

• 33
• 13
• 12
• 10
• 12
• ### Forum Statistics

• Total Topics
632575
• Total Posts
3007150

×