Skip to main content
GameDev.net gamedev.net
🔒 Locked

Force Change Resoultion

Started by coderx04 Nov 23, 2004 at 4:41 AM 3 replies 1k views
Original Post
coderx04
coderx04
Quote:
void ChangeRes() { // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_7gz7.asp // #include // get the current devices display settings DEVMODE lpDevMode; ZeroMemory(&lpDevMode, sizeof(DEVMODE)); lpDevMode.dmSize = sizeof(DEVMODE); lpDevMode.dmDriverExtra = 0; if (!EnumDisplaySettings(NULL/* current device */,ENUM_CURRENT_SETTINGS, &lpDevMode)) ExitProcess(1); if (lpDevMode.dmPelsWidth == 800 && lpDevMode.dmPelsHeight == 600) return; // no need to change // set settings lpDevMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; lpDevMode.dmPelsWidth = 800; lpDevMode.dmPelsHeight = 600; lpDevMode.dmDisplayFrequency = 85; // change settings long status; do { status = ChangeDisplaySettings(&lpDevMode, CDS_FULLSCREEN /* temporary, till program exits*/); lpDevMode.dmDisplayFrequency -= 5; } while (status != DISP_CHANGE_SUCCESSFUL && lpDevMode.dmDisplayFrequency >= 60); if (status != DISP_CHANGE_SUCCESSFUL) { lpDevMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT ; status = ChangeDisplaySettings(&lpDevMode, CDS_FULLSCREEN /* temporary, till program exits*/); if (status != DISP_CHANGE_SUCCESSFUL) ExitProcess(1); } }
I got this code from my tutor for borland C++ builder, But When I use it in Visual C++ win32 application. and use SDL library, its not working, Can you tell me whats wrong with that..? This is the error when im compiling it : c:\program files\microsoft visual studio\vc98\include\winuser.h(39) : error C2146: syntax error : missing ';' before identifier 'HDWP' c:\program files\microsoft visual studio\vc98\include\winuser.h(39) : fatal error C1004: unexpected end of file found Error executing cl.exe.
JohnHurt
JohnHurt
Not sure I've ever needed to use an HDWP structure. But anyways, check where your declaring that, sounds like you need to include another header for that structure. like windows.h.

btw, when you get that working, i wouldn't hard-code the res settings in like that if i where you. it'd be much safer to enumerate what the display can do somwhere else and let the user select it.

[Edited by - JohnHurt on November 23, 2004 7:29:45 AM]
coderx04
coderx04
Why not hard Code it? Is there any other way to force change the resolution when the game start.

because, I dont want to have the game be different if the use change the display settings.

And thanks, After I include windows.h before include winuser.h
It did compile, but still no different.
coderx04
coderx04
Please help
superpig
superpig
If you're using SDL, use SDL. Look up SDL_SetVideoMode. It lets you initialise the display to a specific screen resolution.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.