the "classic" opengl32.dll crash under win32

Hi,

Here’s a description of a bug i had the occasion to see quite often in my short (~3years) opengl programming experience.

It results in the opengl application to crash in the best case, blue screen in the worst case, even under windows2000 and XP.

To experience it, it’s extremely simple, just launch a first application using opengl, and a second one in fullscreen for example. when you exit the second application, the first one crashes, or the whole system crashes.

After further exploration of the issue i realised the problem is due to the fact the second application may use the command:
wglMakeCurrent(NULL,NULL);
in its deinitialisation. when the first application tries to send opengl commands again, no context is bound, which results in instability.

The only solution i know to the problem so far is to use a:
wglMakeCurrent(myHDC,myHRC);
in the rendering loop. However, the issue is that this command isn’t free in execution time.

To solve this kind of issue in a general way, 2 new functions would be necessary, something like:

wglPushContext();
wglPopContext();

assuming opengl32.dll would implement a context stack inside the library. It would enable the application to save the context possibly previously used and to restore it cleanly.

comments/ideas/whatever welcome

It’s the OS task manager’s responsibility to save/restore process environment, which includes the GL context.

The graphics driver is involved, of course. What have you been using?

your problem doesn’t sound logical the way you explain it, does this happen to any opengl app or just ones you wrote? does the second always have to be full screen?

first, wglMakeCurrent() operates only in the current thread therefore it should have no effect on any other app, second if the second has to be fullscreen then it can’t be your only problem, since wglMakeCurrent needs to be called at exit…

if it happens to all apps, including professional apps, then update you videocard drivers and hope that works, if not then you have a code problem.