I have problems with WGL_ARB pbuffer OpenGL

I tried to do off-screen rendering using pbufer WLG_ARB, but I had problems with wglCreatePbufferARB () It always returns NULL. Here is a piece of code.

bool COpenGLWnd::OffscreenRender
    (/* IN parameters */ int transitionID, int counts, int directionID,
    /* OUT parameters */ BYTE* pPixelArray)
{
    HDC tmpDC = ::GetDC(NULL);
    SetDCPixelFormat(tmpDC);

    HGLRC tmpRC = wglCreateContext(tmpDC);
    VERIFY(wglMakeCurrent(tmpDC, tmpRC));

    HDC hDC = ::GetDC(NULL);
    const int attribList[] =
    {
        WGL_DRAW_TO_PBUFFER_ARB, GL_TRUE,
        WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
        WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
        WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
        WGL_COLOR_BITS_ARB, 32,
        WGL_DEPTH_BITS_ARB, 24,
        WGL_STENCIL_BITS_ARB, 8,
        0,        //End
    };

    int pixelFormat;
    UINT numFormats = 1;

    if(!wglGetCurrentContext())
    {
        return false;
    }

    wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB");
    if(!wglGetExtensionsStringARB) return false;
    const GLubyte* extensions = (const GLubyte*) wglGetExtensionsStringARB(wglGetCurrentDC());
    if(!extensions)
    {
        return false;
    }

    wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC) wglGetProcAddress("wglChoosePixelFormatARB");
    wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC) wglGetProcAddress("wglCreatePbufferARB");
    wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC) wglGetProcAddress("wglGetPbufferDCARB");

    VERIFY(wglMakeCurrent(tmpDC, NULL));
    wglDeleteContext(tmpRC);
    ::ReleaseDC(NULL, tmpDC);

    if(!wglChoosePixelFormatARB) return false;
    if(!wglCreatePbufferARB) return false;
    if(!wglGetPbufferDCARB) return false;

    wglChoosePixelFormatARB(hDC, attribList, NULL, 1, &pixelFormat, &numFormats);


    const int attribTmp[] = {WGL_PBUFFER_LARGEST_ARB, 0, 0};
    m_hbuffer = wglCreatePbufferARB(hDC, pixelFormat, m_BmpWidth, m_BmpHeight, attribTmp);
    HDC hpbufferDC = wglGetPbufferDCARB(hbuffer);
    if(!hpbufferDC) return false;

    HGLRC hpbufferRC = wglCreateContext(hpbufferDC);
    VERIFY(wglMakeCurrent(hpbufferDC, hpbufferRC));
    ...
}

As I said, wglCreatePbufferARB returns NULL, so I cannot use wglGetBufferDCARB. Other WGL_ARB extension functions work very well, for example wglGetExtensionsStringARB and wglChoosePixelformetARB. And also the extension got a very normal line, it starts with "WGL_ARB_extensions_string ...". Each parameter used in wglCreatePbufferARB was not NULL, including hDC. Then why is wglCreatePbufferARB still returning NULL and not working, what did I intend?

++ p.s. GetLastError, ERROR_INVALID_DATA. - attribList, ? GetLastError.

++ p.s. . . !

+3

All Articles