Original Post
I want to test out how slow drawing to a bitmap and blitting will be using PFD_DRAW_TO_BITMAP instead of PFD_DOUBLEBUFFER but I'm having trouble when the window needs resized. When I try to resize I always get an unknown exception. It has something to do with copying the context because when I don't do It everything works fine UNTIL I resize. Here is some code: The reason I'm using wglCopyContext is because my textures are deleted along with the context. Is there something I should know about wglCopyContext or did I do something else wrong? [Edited by - aewarnick on April 9, 2005 5:49:52 PM]
//Everything in here is fine.
HGLRC SetUpOpenGL(HDC hdc, bool doubleBuffed, byte depthBits= 0)
{
DoubleBuffed= doubleBuffed;
PIXELFORMATDESCRIPTOR pfd;
memset( & pfd, 0, sizeof(pfd));
pfd.nSize= sizeof(pfd);
pfd.nVersion= 1;
pfd.dwFlags= PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI;
pfd.iPixelType= PFD_TYPE_RGBA;
pfd.cDepthBits= depthBits;
pfd.cColorBits= 24;
int pf= ChoosePixelFormat(hdc, & pfd);
if(!pf) MessageBox(0, "ChoosePixelFormat", "Error", 0);
if(!SetPixelFormat(hdc, pf, & pfd))
MessageBox(0, "SetPixelFormat", "Error", 0);
HGLRC hgl= wglCreateContext(hdc);
wglMakeCurrent(hdc, hgl);
}
//In WM_SIZE. Both wglCopyContext pass.
HGLRC cur= wglGetCurrentContext();
if(hGL!=cur)
wglMakeCurrent(memDC->hDC, hGL);
if(!wglCopyContext(hGL, App::glDummyHgl, GL_ALL_ATTRIB_BITS)) MB("no copy");
DisableOpenGL(); //makes no context current and deletes hGL
CreateBackBuffer(); //creates the bitmap for back buffing rendering
hGL= SetUpOpenGL(memDC->hDC, 1); //memDC selected the bitmap above into a dc
wglMakeCurrent(App::glDummyDC.hDC, App::glDummyHgl);
if(!wglCopyContext(App::glDummyHgl, hGL, GL_ALL_ATTRIB_BITS)) MB("no second");
wglMakeCurrent(memDC->hDC, hGL);