mardi 28 juin 2016

Crash on Nvidia card, when trying to switch VSync

I wanna try to enable and disable VSync in my OpenGL Application. I have created a window with the winapi and did also the context by myself. I have now a rotating 3D cube with a texture being displayed in this context, so everything I did works correctly.

Now I habe problems with managing VSync in my window.

On my main machine (GTX770SLI, latest driver) my program crashes, when I try to configure VSync, a call from setVSync(bool) let my program crash. On the other side, my notebook (AMD APU + dedicated AMD GPU, dont know the exact model, but around 2014) has no problems with that kind of code.

On the Nvidia machine, I was able to activate/deactivate VSync in the driverpanel, by changing the global VSync Settings to auto/off. On the AMD machine, it was set to "let the application decide".

This code is used to toggle VSync:

void setVSync(bool sync)
{
    // Function pointer for the wgl extention function we need to enable/disable
    // vsync
    typedef BOOL(APIENTRY *PFNWGLSWAPINTERVALPROC)(int);
    PFNWGLSWAPINTERVALPROC wglSwapIntervalEXT = 0;
const char *extensions = (char*)glGetString(GL_EXTENSIONS);

if (strstr(extensions, "WGL_EXT_swap_control") == 0)
{

    cout << "VSync Extension not supported" << endl;
    return;
}
else
{
    wglSwapIntervalEXT = (PFNWGLSWAPINTERVALPROC)wglGetProcAddress("wglSwapIntervalEXT");

    if (wglSwapIntervalEXT)
        wglSwapIntervalEXT(sync);
    cout << "VSync Extension is supported ! yeah ! " << endl;
}
}

What can be wrong here ? TIA !

Update: The crash happens in the if-statement. I have the IDE now in a different language, but it says, that there is a exception at 0x6D66E72F (vcruntime140.dll) in my .exe: 0xC0000005: Access injury when reading at position 0x00000000. Well, I must say I am not very good in debugging.

Update 2: (char*)getString(GL_EXTENSIONS); returns on my nvidia system 0.

Aucun commentaire:

Enregistrer un commentaire