PDA

View Full Version : Huge OGL/Windows error on exit



sirSolarius
04-10-2004, 09:11 AM
In my KillGLWindow function (copied from NeHe), I'm getting a huge error (that I didn't used to get... I'm not sure what has triggered it).


Lvoid KillGLWindow(GLvoid) // Properly Kill The Window
{
if (fullscreen) // Are We In Fullscreen Mode?
{
ChangeDisplaySettings(NULL,0); // If So Switch Back To The Desktop
ShowCursor(TRUE); // Show Mouse Pointer
}

if (hRC) // Do We Have A Rendering Context?
{
if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts?
{
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);

}
/*********************************ERROR HERE***************/
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
{
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
hRC=NULL; // Set RC To NULL
}

if (hDC && !ReleaseDC(hWnd,hDC)) // Are We Able To Release The DC
{
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hDC=NULL; // Set DC To NULL
}

if (hWnd && !DestroyWindow(hWnd)) // Are We Able To Destroy The Window?
{
MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hWnd=NULL; // Set hWnd To NULL
}

if (!UnregisterClass("OpenGL",hInstance)) // Are We Able To Unregister Class
{
MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hInstance=NULL; // Set hInstance To NULL
}
}If I exit my program before looking at any of my objects, the program deconstructs perfectly. If I try to exit after looking at one, however, I get an error at the marked line with the following message:

"Unhandled exception in CurrentErikEngine.exe(NVOGLNT.DLL): 0xC0000005: Access violation."

What is going on?

kehziah
04-10-2004, 12:04 PM
It is a driver bug. Being a part of the operating system, a driver should (in theory) never crash like that.

Now why the wglDeleteContext function crashes? I don't know. Have you tried to monitor the behaviour of the hRC variable? Are you sure it doesn't get corrupted anywhere? (which would mean that it's not NULL, but the value is not meaningful anymore) More generally, double check your array code. If you write beyond array boundaries, you might completely screw your app (code or data, or even something else that happens to be here).

yooyo
04-10-2004, 11:37 PM
Try deleting RC before switching back to desktop.

yooyo

sirSolarius
04-11-2004, 06:59 AM
Ok, it gets weirder. Now, if I start my program up so all of my objects are behind my camera and then exit, VC++ says "User breakpoint called from code at 0x77f75a58," which points to the line "int 3" in "NTDLL!"

What is going on?