I’m trying to use the video card for processing without anything being displayed on the screen. I really don’t want a window, hidden or otherwise, to be created. I am trying to use a bitmap to obtain a render context from which I can get the ARB function entry points I need to render-to-texture. However, although all appears to be well and I appear to have a valid render context, when I call wglGetProcAddress I get zip. I have no idea why, since the error codes are less than helpful. (The error after the wglGetProcAddress call is: The specified procedure could not be found. Well, thanks.)
Is what I want to do possible, and could anyone please help me? The offending code (without any error checking or the like) is below:
// Create bitmap
BITMAPINFOHEADER bih;
void *data;
memset( &bih, 0, sizeof( bih ) );
bih.biSize = sizeof( bih );
bih.biWidth = 256;
bih.biHeight = 256;
bih.biBitCount = 32;
bih.biCompression = BI_RGB;
bih.biPlanes = 1;
HDC memDC = CreateCompatibleDC( NULL );
HBITMAP memBMP = CreateDIBSection( memDC,
(BITMAPINFO*)&bih, DIB_RGB_COLORS, &data, NULL, 0 );
SelectObject( memDC, memBMP );
// Set pixel format
int pixelType = PFD_TYPE_RGBA;
DWORD flags = ( PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI );
PIXELFORMATDESCRIPTOR pfd;
memset( &pfd, 0, sizeof( PIXELFORMATDESCRIPTOR ) );
pfd.nSize = sizeof( PIXELFORMATDESCRIPTOR );
pfd.nVersion = 1;
pfd.dwFlags = flags;
pfd.iPixelType = pixelType;
pfd.cColorBits = 32;
pfd.cDepthBits = 8;
pfd.iLayerType = PFD_MAIN_PLANE;
int pixelFormat = ChoosePixelFormat( memDC, &pfd );
BOOL result = SetPixelFormat( memDC, pixelFormat, &pfd );
// Create context
HGLRC hglrc = wglCreateContext( memDC );
result = wglMakeCurrent( memDC, hglrc );
// Get ARB entry points
wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress(“wglGetExtensionsStringARB”);
wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC) wglGetProcAddress(“wglChoosePixelFormatARB”);
wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC) wglGetProcAddress(“wglCreatePbufferARB”);
memDC and hglrc appear valid, but all wglGetProcAddresses return NULL.
Cheers.