View Full Version : wglCreateBufferRegionARB returns NULL on NVIDIA

04-19-2010, 12:57 AM
I recently added support for buffer regions in my software. It works perfectly on ATI but the call to wglCreateBufferRegionARB returns NULL on NVIDIA H/W and I haven't been able to figure out why.

The "WGL_ARB_buffer_region" extension string is present and wglGetProcAddress() works fine. GetLastError() returns the error code 0xC00705AA and FormatMessage() with that error code returns a NULL string.

These are the attributes I'm using for the pixel format:

pFd.nSize = sizeof(pFd);
pFd.nVersion = 1;
pFd.iPixelType = PFD_TYPE_RGBA;
pFd.iLayerType = PFD_MAIN_PLANE;
pFd.cDepthBits = 32;
pFd.cColorBits = 24;

(I tried with and without PFD_STEREO, which is the only thing that seems remotely unusual, and that didn't help. Neither did using 16 bits for depth.)

The call looks like this, but any combination of front and back buffer with and without depth makes no difference:


m_Buffer = wglCreateBufferRegionARB(pDC->m_hDC, 0, ColourBuffer | WGL_DEPTH_BUFFER_BIT_ARB);

This is such an old extension that I'm completely at a loss. It doesn't work on any GeForce or Quadro card I've tried, with any driver version, but works fine on all ATI cards. What am I doing wrong?

Piers Daniell
04-19-2010, 12:28 PM
What driver version? Which OS? Which GPU(s)? Also, if possible, could you submit a simple repro app source. Thanks.

04-20-2010, 03:09 AM
I put together a simple Win32 test program so I could post it and found it actually worked correctly, despite the OpenGL code being almost line-for-line identical.

After much mucking about I finally figured out what the difference was between the two versions -- in the original code all the OpenGL initialisation is done during the CView-derived OnCreate() method, which occurs after the window has been created but before it becomes visible, while the test program did the initialisation after the window was visible.

OnCreate() is the canonical OpenGL setup location in every example I've seen. We've been using it for about 15 years.

For ATI using OnCreate() doesn't cause any problems, and for all the other OpenGL initialisation that occurs this doesn't cause any problems, but apparently NVIDIA requires the window to be visible before wglCreateBufferRegionARB can be called successfully.

It would have been nice if calling FormatMessage() with the error code returned by GetLastError() had said something to that effect. :-)

I couldn't find anything in the specification that said the window has to be visible before this can be used. Now it looks like I'll need to put a once-off initialisation in OnDraw() because I'm not aware of a message that's sent in between.