wglCreateContextAttribs_ARB never called?

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
0xc0dec
Posts: 2
Joined: Thu Sep 27, 2012 5:04 pm

wglCreateContextAttribs_ARB never called?

Post by 0xc0dec »

While debugging my app, I came across this code in OpenGL driver and I find it quite strange:

Code: Select all

 #ifdef WGL_ARB_create_context
    PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
    if (wglCreateContextAttribs_ARB)
    {
        int iAttribs[] =
        {
            WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
            WGL_CONTEXT_MINOR_VERSION_ARB, 1,
            0
        };
        hrc=wglCreateContextAttribs_ARB(HDc, 0, iAttribs);
    }
    else
#endif
        hrc=wglCreateContext(HDc);
My experiments show that wglCreateContextAttribs_ARB always gets zero value, thus "if { ... }" block is never executed, and hrc always receives value from wglCreateContext(HDc). The reason for that is probably that wglGetProcAddress is called after the temporary context is destroyed in previous lines. If you call wglGetProcAddress before the temp context is destroyed, it returns a valid pointer and the "if" block gets executed:

Code: Select all

#endif
        AntiAlias=0;
 
#ifdef WGL_ARB_create_context
    PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
#endif
 
    wglMakeCurrent(HDc, NULL);
    wglDeleteContext(hrc);
    ReleaseDC(temporary_wnd, HDc);
    DestroyWindow(temporary_wnd);
    UnregisterClass(ClassName, lhInstance);
 
    // ...
 
#ifdef WGL_ARB_create_context
    if (wglCreateContextAttribs_ARB)
    {
        int iAttribs[] =
        {
            WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
            WGL_CONTEXT_MINOR_VERSION_ARB, 1,
            0
        };
        hrc=wglCreateContextAttribs_ARB(HDc, 0, iAttribs);
    }
    else
#endif
        hrc=wglCreateContext(HDc);
Is it a bug, or I missed something? Irrlicht version is 1.8.0.

BTW, just curious: what version of context does wglCreateContext create?
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: wglCreateContextAttribs_ARB never called?

Post by Nadro »

It looks like a drivers for your graphic card doesn't support wglCreateContextAttribsARB. If your card is compatible with Direct3D 10.x / OpenGL 3.x please update drivers.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
0xc0dec
Posts: 2
Joined: Thu Sep 27, 2012 5:04 pm

Re: wglCreateContextAttribs_ARB never called?

Post by 0xc0dec »

As I said, wglCreateContextAttribsARB pointer is loaded correctly when wglGetProcAddress is called before temporary context destruction, so then everything works OK. It doesn't look like a driver problem. I have GTX 660 with latest drivers.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: wglCreateContextAttribs_ARB never called?

Post by Nadro »

You are right, there is a bug in the engine, anyway for OpenGL 3.x we will have dedicated driver soon, so wglCreateContextAttribs_ARB call should be removed from current OpenGL driver.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Post Reply