glGenTextures not returning a texture name
I am creating an OpenGL game on a Windows 7 machine using VS2010. In addition, SDL, QtCore, QtXML and FbxSdk are also used to assist in development. I am experiencing a very peculiar problem with glGenTextures when running outside debug mode. Let me explain.
When I compile and run the application in Debug mode, the models are textured and displayed properly. As soon as I debug the application or compile and run the application using release mode textures are no longer being applied to the models.
I have tracked down the problem to glGenTextures not giving me a valid name. It does not give me any errors either. The way I am loading everything is as follows:
Models are loaded as FBX through FbxSdk, Required textures are loaded as the model is loaded. All models are loaded in another thread, I made sure that no OpenGL functions get called anywhere while this thread is loading models. If I don't load models in another thread everything works. I tried everything I can think of including halting the main thread while the models get loaded to guarantee nothing else if happening while models get loaded. None of it works.
Again this wouldn't be as weird except compiling as debug works. Release and Debugging the application开发者_如何学运维 doesn't work. Any thoughts?
I can only guess, but did you maybe not make the GL context current on the model loading thread? Remember that the OpenGL context is thread specific!
On the other hand, it's usually advised against to use the same GL context in different threads. Either use a different context and share resources, or defer all the GL calls to the main GL thread.
The difference when using the debugging mode is that VS will use the debug-heap when you debug, but won't use it when you just run a debug build without actual debugging.
However, if you get the threads thing wrong, all kinds of crazy side-effects can happen which the debug heap might "hide".
精彩评论