I notice that the current OpenGL context is made active every time a frame is drawn. Is there a particular reason for this? It seems like you could just make the context active once at the beginning of the program. Or am I wrong? I’m just wondering because I’ve heard that there is some overhead for making a context active.
Strangely though, when I do try to just call it once at the beginning of the program, it doesn’t seem to work, though I can’t figure out why.
User-code in the callback or paint method could do anything - it may activate a different context for some reason. What’s wrong with calling it each time? If the context is already active, there’ll be almost no overhead in making the call…
“Checking” things is an expensive OpenGL operation. It involves sync’ing the GL command queue and the CPU. If your app has knowledge about what state is active (any state, but especially the active context) it should void re-setting it.
Having said that, changing context is very expensive, more than just checking.