Skip to main content
gamedev.net
🔒 Locked

Using ::ChangeDisplaySettings()

Started by shadowcomplex Oct 29, 2005 at 7:15 PM 3 replies 750+ views
Original Post
shadowcomplex
shadowcomplex
Hello, I want to change the resolution settings during the execution of my game so that they are locked at 32 bit and 1024x768. I have tried using ::ChangeDisplaySettings() but to no avail. My guess is that the DEVMODE I am passing it is not valid. So my real question is, how exactly do I make a valid DEVMODE? I initialized the dmBitsPerPel and the dmPelsWidth/Height members to 32 and 1024/768, but I guess this is not enough. I checked out the MSDN on it, but don't know how to set the dmSize member to the appropriate size first. Any help would be greatly appreciated. By the way I am developing a 2D hack and slash adventure game (demo available in a week, maybe..) using c++ and MFC in visual studio 6.0.
Dave Hunt
Dave Hunt
From the DEVMODE documentation page:

Quote:
dmSize
Specifies the size, in bytes, of the DEVMODE structure, not including any private driver-specific data that might follow the structure's public members. Set this member to sizeof(DEVMODE) to indicate the version of the DEVMODE structure being used.


Ro_Akira
Ro_Akira
Perhaps you are not filling the struct with zeros first, and then setting dmFields appropriatly.

DEVMODE new_mode;ZeroMemory (&new_mode, sizeof (DEVMODE));new_mode.dmSize = sizeof (DEVMODE);new_mode.dmPelsWidth = 1024;new_mode.dmPelsHeight = 768;new_mode.dmBitsPerPel = 32;new_mode.dmDisplayFrequency	= 60;new_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;ChangeDisplaySettingsEx (NULL, &new_mode, NULL, CDS_FULLSCREEN, NULL);


Note that this code sets the refresh rate to 60Hz to be on the safe side. I don't recommend it for it's eyestrain qualities however.

Topic Locked

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

Sign in to reply to this topic.