Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Huge OGL/Windows error on exit

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2004
    Posts
    6

    Huge OGL/Windows error on exit

    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).

    Code :
    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?

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2001
    Posts
    354

    Re: Huge OGL/Windows error on exit

    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).

  3. #3
    Advanced Member Frequent Contributor yooyo's Avatar
    Join Date
    Apr 2003
    Location
    Belgrade, Serbia
    Posts
    883

    Re: Huge OGL/Windows error on exit

    Try deleting RC before switching back to desktop.

    yooyo

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2004
    Posts
    6

    Re: Huge OGL/Windows error on exit

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •