I’ve got a problem with switching the color depth (24bit to 16bit and vice versa) of the graphics card while my programme is running. After the user changes the color depth the newly created window does not show the 3D scene correctly. It seems as if only the first call of wglCreateContext initialises the buffers to the current display setting.
When the programme receives WM_DISPLAYCHANGE it’s doing the following:
// Delete the old window
wglMakeCurrent(NULL, NULL);
wglDeleteContext(hRC);
ReleaseDC(hWnd, hDC);
DestroyWindow(hWnd);
// …
// Create a new window
hWnd = CreateWindow(…);
// …
// Set pixel format and create context
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
24,
0,0,0,0,0,0,
0,0,
0,0,0,0,0,
32,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,0
};
int PixelFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC, PixelFormat, &pfd);
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
// Display scene
// …
Is there any possibility to reinitialise the buffers (e.g. unload and load the opengl32.dll) to the new resolution/color depth. The only way I found is to use a DIBsection, but the performance sucks.
Any ideas? Thanks for your help!