I've tried searching the forums to see if someone else has been having this problem, but I didn't find anything.
My problem is that after updating my game from 1.5 to 2.0 it keeps crashing every time I exit the application. So I put together a minimal app to see if it still happens, and it does. I don't know whether it's an SFML issue, or a driver issue, or me screwing something up. I'm running the latest drivers for my graphics card.
So, the exact problem is that when I exit out of the app, it gives me an unhandled exception, and the issue appears to be on line 91 of ContextWGL.cpp:
if (myContext)
{
if (wglGetCurrentContext() == myContext)
----> wglMakeCurrent(NULL, NULL);
wglDeleteContext(myContext);
}
My call stacks looks like this:
atioglxx.dll!6903a3ad()
[Frames below may be incorrect and/or missing, no symbols loaded for atioglxx.dll]
atioglxx.dll!690925d5()
opengl32.dll!676e9286()
opengl32.dll!676e9583()
> sfml-window-d.dll!sf::priv::ContextWGL::~ContextWGL() Line 91 + 0xc bytes C++
sfml-window-d.dll!`anonymous namespace'::`dynamic atexit destructor for 'referenceContext''() + 0x28 bytes C++
sfml-window-d.dll!_CRT_INIT(void * hDllHandle=0x00100000, unsigned long dwReason=0x00000000, void * lpreserved=0x00000001) Line 449 C
sfml-window-d.dll!__DllMainCRTStartup(void * hDllHandle=0x00100000, unsigned long dwReason=0x00000000, void * lpreserved=0x00000001) Line 560 + 0x11 bytes C
sfml-window-d.dll!_DllMainCRTStartup(void * hDllHandle=0x00100000, unsigned long dwReason=0x00000000, void * lpreserved=0x00000001) Line 510 + 0x11 bytes C
And the code for my minimal program looks like this:
#include <SFML/Window.hpp>
int main()
{
sf::VideoMode mode;
mode.Width = 1280;
mode.Height = 800;
mode.BitsPerPixel = 32;
sf::Window Screen;
Screen.Create(mode, "oglgame");
return 0;
}
I'm going to feel really stupid if I'm just missing a line or two.
Edit: If I run in release instead of debug it instead seems to crash in crtdll.c on line 449:
/* call the function, which can eventually change __onexitbegin and __onexitend */
(*function_to_call)();
----> onexitbegin_new = (_PVFV *)_decode_pointer(__onexitbegin);
onexitend_new = (_PVFV *)_decode_pointer(__onexitend);
And the call stack then looks like this:
atioglxx.dll!6903a3ad()
[Frames below may be incorrect and/or missing, no symbols loaded for atioglxx.dll]
atioglxx.dll!690925d5()
opengl32.dll!67ed9286()
opengl32.dll!67ed9583()
sfml-window.dll!sf::priv::ContextWGL::~ContextWGL() + 0x24 bytes C++
> sfml-window.dll!_CRT_INIT(void * hDllHandle=0x001c409c, unsigned long dwReason=0x001c4080, void * lpreserved=0x001c4080) Line 449 C