Skip to main content
gamedev.net
🔒 Locked

Can't call "glGetString"???

Started by VanKurt 6 replies 1.3k views
Original Post
VanKurt
VanKurt
Hi there! I have a really weird problem. The situation is the following: My OpenGL-MFC-Application is up and running (I can draw all kinds of primitives on the screen). But when I call char *ext = (char*)glGetString( GL_EXTENSIONS ); if( ext == NULL ) MessageBoxA(NULL,"Nasty error!, "ERROR",MB_OK); else MessageBoxA(NULL,"Everything's OK", "OK",MB_OK); I get the error-message! How can that be? I NEVER had glGetString fail... what could cause this strange behavior? Thank's a lot!
frca
frca
Maybe you called it before initializing OpenGL window.
typek
VanKurt
VanKurt
As I wrote: "My OpenGL-MFC-Application is up and running (I can draw all kinds of primitives on the screen)"

SO that can't be it...
Brother Bob
Brother Bob
Having a window to render to at some point in the program is not enough. The window and rendering context must be fully created BEFORE you attempt to call any OpenGL function. Do you call it after creating the rendering context?
VanKurt
VanKurt
Yes, I do. The function is called when I press a button - and that is AFTER evrything's initialized. :-(
Brother Bob
Brother Bob
Call wglGetCurrentContext right before that code and see of the context is really active. If the return value is NULL, then you don't have a rendering context active. You may hav created and activated it, but maybe MFC deactivates it in some way.
VanKurt
VanKurt
You're right, the return value is NULL!!!! But how can this be? Is it possible to render to a window when there's NO rendering context????
Brother Bob
Brother Bob
Different threads maybe. A rendering context can only be active in one thread, so if the button callback is executed in a different thread from the rendering, then the rendering context isn't active. I don't know how MFC works, so can't say.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.