Hi,
I'm trying to switch my game to fullscreen as shown in the code below. I'm starting the game at 640x480 windowed, then setting the resolution to 1024x768 fullscreen. It works fine at first, but a little while later, the top left part of the screen (I think its the top left 640x480 pixels) continues to display fine, while the remainder of the screen "freezes." Sometimes the screen freezes entirely.
Here's my code:
Any pointers as to what I'm be doing wrong? Thanks!
I'm trying to switch my game to fullscreen as shown in the code below. I'm starting the game at 640x480 windowed, then setting the resolution to 1024x768 fullscreen. It works fine at first, but a little while later, the top left part of the screen (I think its the top left 640x480 pixels) continues to display fine, while the remainder of the screen "freezes." Sometimes the screen freezes entirely.
Here's my code:
- Code:
bool fullFlag = true;
int height = 768;
int width = 1024;
int bpp = 32;
if(fullFlag) {
DEVMODE devmodescreen;
memset(&devmodescreen;, 9, sizeof(devmodescreen));
devmodescreen.dmSize = sizeof(devmodescreen);
devmodescreen.dmPelsHeight = height;
devmodescreen.dmPelsWidth = width;
devmodescreen.dmBitsPerPel = bpp;
devmodescreen.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
if(ChangeDisplaySettings(&devmodescreen;, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
MessageBox(NULL, "Display mode failed", NULL, MB_OK);
fullFlag = false;
}
}
HWND ghwnd = (HWND)shared->main->GetWindowHandle();
if(!ghwnd)
return;
ShowWindow(ghwnd, SW_SHOWMAXIMIZED);
LONG style = GetWindowLong(ghwnd, GWL_STYLE);
style &= ~(WS_BORDER|WS_CAPTION);
SetWindowLong(ghwnd, GWL_STYLE, style);
UpdateWindow(ghwnd);
shared->ecd->dispcfg->width = width;
shared->ecd->dispcfg->height = height;
Any pointers as to what I'm be doing wrong? Thanks!