#### Archived

This topic is now archived and is closed to further replies.

# Problems with wglCreateContext()

This topic is 5532 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Here's the code:

hRC = wglCreateContext(hDC);
if(hRC == NULL)
{
MessageBox(NULL, "Can not create the Rendering Context. This application will now close.", "GLCrusader", MB_OK);
ShowLastError();
//   ShutDown();

return false;
}

Every time the hRC comes back NULL, and all functions taking hRC as an argument fail, but GetLastError() ( held within the function ShowLastError() ) comes back with the error code 0x00000000 ( The function completed successfuly ). Has anyone else had this problem? Does anyone know what might cause wglCreateContext() to fail? //////////// // Update // //////////// My problem was that I forgot to call SetPixelFormat() before hand. This still does not excuse the error code however. [edited by - QBRADQ on December 27, 2002 1:56:41 AM]

##### Share on other sites
The reason ShowLastError() showed success was because you called it after calling MessageBox(). It showed the result of that call, rather than the wglCreateContext() call.

##### Share on other sites

int PixelFormat ChoosePixelFormat(Canvas->Handle,&pfd);
isnt PixelFormat NULL ?
or what does that return ?
SetPixelFormat(Canvas->Handle,PixelFormat,&pfd);