wglMakeCurrent with hdc parameter NULL

718 views Asked by At

According to the registered here (khronos site):

If the OpenGL context version of <hglrc> is 3.0 or above, and if either the <hdc> parameter of wglMakeCurrent is NULL, or both of the <hDrawDC> and <hReadDC> parameters of wglMakeContextCurrentARB are NULL, then the context is made current, but with no default framebuffer defined. The effects of having no default framebuffer on the GL are defined in Chapter 4 of the OpenGL 3.0 Specification.

Trusting this information I created a device context "off screen" with:

HDC m_hDC = CreateCompatibleDC(NULL);

I configured the Pixels and added to DC with the SetPixelFormat function:

SetPixelFormat(m_hDC, iPixelFormat, &chosenPFD);

Then I created a rendering context:

m_hGLRC = ::wglCreateContextAttribsARB(m_hDC, NULL, &(iAttributes[0]));

So far so good, it works. Now it's time to make the context current.

First I delete the DC (I will not need it anymore) and call the wglMakeCurrent with a NULL dc parameter:

DeleteDC(m_hDC);
bool ret = wglMakeCurrent(NULL, m_hGLRC);

That did not work. The ret is false and I get this error:

Win32 Error# (6): ERROR_INVALID_HANDLE

0

There are 0 answers