Archived

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

EnumDisplayModes() gives 0hz

This topic is 5154 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I''m trying to enumerate the different refresh rates available on a display. I use the funcion EnumDisplayModes(). The problem is, that on alot of display drivers, I get refresh rates of 0hz, even when I specify the DDEDM_REFRESHRATES flag. This is kind of annoying, because I want to use the 640x480x16 resolution with a refresh rate of 60hz. However, when the EnumDisplayModes() function return 0, I can''t set the display mode using SetDisplayMode() with a refresh rate of 60hz, eventhough this is the mode it sets when I specify a refresh rate of 0, meaning it can use the default mode. I''m using DirectX 6.1 atm, but get the same results in DirectX 7 and 8.1. Hope you can give me some advice!

Share this post


Link to post
Share on other sites
( hehe... alleen Nederlanders tot hier toe )

I use this code to pick a display setting:


if (fullscreen)
{
memset(&sc, 0, sizeof(sc));
sc.dmSize = sizeof(sc);
sc.dmPelsWidth = width;
sc.dmPelsHeight = height;
sc.dmBitsPerPel = bpp;
sc.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

// try to find highest vsync frequency

if (g_bScreenVSyncMaximize)
{
g_LogFile.bPrint("window: searching screenmode for highest vsync (%dx%d %dbpp)...", width, height, bpp);

maxvsync = 0;
maxsyncmode = 0;
curmode = 0;
mode_found = false;

/* loop through all display modes keeping track of best match */
while (EnumDisplaySettings(0, curmode, &mode_enum))
{
if (mode_enum.dmPelsWidth == width && mode_enum.dmPelsHeight == height &&\
mode_enum.dmBitsPerPel == bpp)
{
if (mode_enum.dmDisplayFrequency >= maxvsync) // >=, NOT >, because 0 is a valid value

{
maxvsync = mode_enum.dmDisplayFrequency;
maxsyncmode = curmode;
mode_found = true;
}
}
curmode++;
}

/* now query the found mode (if there''s one) */
if (mode_found)
{
g_LogFile.bPrint("window: found screenMode with high vsync: %d (%d Hz)", maxsyncmode, mode_enum.dmDisplayFrequency);
if (EnumDisplaySettings(0, maxsyncmode, &mode_enum))
{
// we found our mode

sc.dmDisplayFrequency = mode_enum.dmDisplayFrequency;
sc.dmFields |= DM_DISPLAYFREQUENCY;
} else {
g_LogFile.bPrint("window: couldn''t enumerate high-vsync ScreenMode!");
}
}
}

if (ChangeDisplaySettings(&sc, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
g_LogFile.bPrint("window: failed to change display Settings");
fullscreen = false;
} else {
g_LogFile.bPrint("window: mode change successful");
}
}


I hope it is clear enough... I didn''t exclude the variable declarations because i''m too lazy to pick out the relevant parts...

With this method I only need to know the desired resolution and bit depth. The refresh rate gets maximized automatically (I think -- my computer switches to 1 (Hz...) which becomes 85 Hz. 0 would give me a migraine-causing 60 Hz).



[ Bananas | My dead site | www.sgi.com | Goegel ]

Share this post


Link to post
Share on other sites
thanks, both of you. i needed a 60hz refresh rate...i doubt it would give you a migraine, since the resolution is only 640x480. anyway, i use the directdraw setdisplaymode function to set the display mode (duh hehe), but because i couldnt change refresh rate with it, i first set the refresh rate using gdi functions, then call setdisplaymode...it works.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Well im i dont know about earlier versions.. but should this be EnumAdapterModes() in directx 9?

Share this post


Link to post
Share on other sites