wglDeleteContext access violation

839 Views Asked by At

I work with a large solution in Visual C++ that uses MFC. Everything worked well before changes. When I just modified a dialog and added a new one. Program began to raise exception at close at the first line of:

    if (!wglDeleteContext(m_hRc))
    {
        throw;
    }
    m_hRc = NULL;
    return;

in file RenderDevice.cpp.

I'm using TortoiseSVN and thus I reverted all the changes and recompiled the projects in solution. But the problem remained.

Can anyone tell me what could be wrong?

4

There are 4 best solutions below

0
On
  1. Try deleting your user settings file.
  2. Try to debug and watch for application call stack
0
On

If i were you I would install Application Verifier from Microsoft and turn on the heap/memory detection for your application then run it in the debugger.

0
On

Place GetLastError after wglDeleteContext:

if (!wglDeleteContext(m_hRc))
{
    DWORD dwError = GetLastError();
    throw;
}
m_hRc = NULL;
return;

Place debugger at line with

DWORD dwError = GetLastError();

You will get root cause why wglDeleteContext fails and why it throws exception.

0
On

I was having similar issues, it is happening because you're not freeing up any space that may have been allocated by your OpenGL Textures, vertex array object, VBO, FBOs, etc, in case of OpenGL at least.


if you're not using OpenGL, then see if you're freeing up the objects you've used in your program.