Original Post
Hi!
I''ve been developing a GUI now for my spare-time-project and have bumped into a problem. My GUI is based upon 10 textured quads with 2 textures each (20 textures a 128*32*24)
When I''m changing the resolution with the GUI, the texures disappear and i have to reload all my textures and when I''ve changed the resolution about 7 times (bug-hunting) my whole computer locks up due to low resources.
Do I really have to reload all my textures when I''m changing resolution and changing from Fullscreen to Windowed mode?
My reinitialize-function
ReInitialize(int new_iWidth, int new_iHeight, int new_iDepth, bool new_bFullscreen, HWND hWnd)
{
iWidth = new_iWidth;
iHeight = new_iHeight;
iDepth = new_iDepth;
bFullscreen = new_bFullscreen;
if(hRenderContext)
{
if(0 == (wglMakeCurrent(NULL, NULL)))
MessageBox(NULL, "wglMakeCurrent Failed", "The Unrevealed", ERROR_STYLE);
if(0 == (wglDeleteContext(hRenderContext)))
MessageBox(NULL, "wglDeleteContext Failed", "The Unrevealed", ERROR_STYLE);
hRenderContext = 0;
}
if(hDeviceContext)
{
if(0 == (ReleaseDC(hWnd, hDeviceContext)))
MessageBox(NULL, "ReleaseDC Failed", "The Unrevealed", ERROR_STYLE);
hDeviceContext = 0;
}
if(hWnd)
hWnd = 0;
if(!bFullscreen)
{
if(ChangeDisplaySettings(NULL, NULL) != DISP_CHANGE_SUCCESSFUL)
MessageBox(NULL, "ChangeDisplaySettings Failed", "The Unrevealed", ERROR_STYLE);
SetWindowPos(hWnd, HWND_TOP, GetSystemMetrics(SM_CXSCREEN) / 2 - iWidth / 2, GetSystemMetrics(SM_CYSCREEN) / 2 - iHeight / 2, iWidth, iHeight, SWP_SHOWWINDOW);
}
if(bFullscreen)
{
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsHeight = iHeight;
dmScreenSettings.dmPelsWidth = iWidth;
dmScreenSettings.dmBitsPerPel = iDepth;
dmScreenSettings.dmFields = DM_PELSHEIGHT | DM_PELSWIDTH | DM_BITSPERPEL;
if(ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
MessageBox(NULL, "ChangeDisplaySettings Failed", "The Unrevealed", MB_OK);
SetWindowPos(hWnd, HWND_TOP, 0, 0, iWidth, iHeight, SWP_SHOWWINDOW);
}
memset(&pfPixelFormatDescriptor, 0, sizeof(pfPixelFormatDescriptor));
pfPixelFormatDescriptor.nSize = sizeof(pfPixelFormatDescriptor);
pfPixelFormatDescriptor.nVersion = 1;
pfPixelFormatDescriptor.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfPixelFormatDescriptor.iPixelType = PFD_TYPE_RGBA;
pfPixelFormatDescriptor.cColorBits = iDepth;
pfPixelFormatDescriptor.cDepthBits = 16;
pfPixelFormatDescriptor.iLayerType = PFD_MAIN_PLANE;
if(0 == (hDeviceContext = GetDC(hWnd)))
MessageBox(NULL, "GetDC Failed", "The Unrevealed", ERROR_STYLE);
if(0 == (iPixelFormat = ChoosePixelFormat(hDeviceContext, &pfPixelFormatDescriptor)))
MessageBox(NULL, "ChoosePixelFormat Failed", "The Unrevealed", ERROR_STYLE);
if(0 == (SetPixelFormat(hDeviceContext, iPixelFormat, &pfPixelFormatDescriptor)))
MessageBox(NULL, "SetPixelFormat Failed", "The Unrevealed", ERROR_STYLE);
if(0 == (hRenderContext = wglCreateContext(hDeviceContext)))
MessageBox(NULL, "wglCreateContext Failed", "The Unrevealed", ERROR_STYLE);
if(0 == (wglMakeCurrent(hDeviceContext, hRenderContext)))
MessageBox(NULL, "wglMakeCurrent Failed", "The Unrevealed", ERROR_STYLE);
glViewport(0, 0, iWidth, iHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (float)iWidth / (float)iHeight, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glAlphaFunc(GL_GREATER, 0.1f);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
UpdateWindow(hWnd);
}