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


GL - resolution - pixelformats - death of windows

Recommended Posts

Hi, I''ve posted a question about changing a window''s pixelformat because of bitdepth change. It is working well as the follows: I do destroy the gl context. realease the dc destroy the window recreate the window setup pixel format set the context It is usually working well (about 70%). When it is not I get various error messages: for example: "Could not load explorer.exe,... please reinstall windows." "General protection fault in kernel.dll" etc... Ofcourse I sould reboot after these. Is there a correct way to destroy an app''s main window and re create it without these funny little messages? Here is my code: // ------------------------------------------------------- void killmainwindow(void) { DestroyWindow(hwndApp); hwndApp = 0; }; BOOL createmainwindow(int width, int height) { hwndApp=CreateWindowEx(WS_EX_APPWINDOW,szAppName,szAppName, WS_EX_TOPMOST /WS_POPUP / WS_CLIPSIBLINGS / WS_CLIPCHILDREN /WS_VISIBLE, 0, 0, width,height, NULL,NULL,hInstApp,NULL); if(!hwndApp) return FALSE; ShowWindow(hwndApp,SW_SHOW); UpdateWindow(hwndApp); SetCursor(NULL); return TRUE; }; And this is how I call these: hRC = wglGetCurrentContext(); hDC = wglGetCurrentDC() ; wglMakeCurrent(NULL, NULL) ; ReleaseDC (hwndApp, hDC) ; wglDeleteContext(hRC); hRC = 0; #ifdef GLFULLSCREEN sman->ChangeResolution(width, height, bpp); killmainwindow(); if ( createmainwindow(width, height) == FALSE) { Fatal_Error("Could not create the OpenGL window"); ChangeDisplaySettings(NULL, 0); } #endif SetWindowPos( hwndApp, // handle to window HWND_TOP, 0, // horizontal position 0, // vertical position width, // width height, // height SWP_SHOWWINDOW / SWP_NOREDRAW ); hDC=GetDC(hwndApp); sman->SetupPixelFormat(hDC,bpp ); hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); Csaba Berényi - Programmer - CLEVERS TEAM

Share this post

Link to post
Share on other sites