SDL_GetDisplayMode returns display mode with 0 refresh rate

Code:

#include <SDL2/SDL.h>

int main()
{
SDL_DisplayMode displaymode;
int i;
int numdisplaymodes;

if(SDL_Init(SDL_INIT_VIDEO) < 0){
	SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\nExiting...\n", SDL_GetError());
	SDL_Quit();
	exit(EXIT_FAILURE);
}

numdisplaymodes = SDL_GetNumDisplayModes(0);
SDL_Log("Number of display modes: %d\n", numdisplaymodes);
for(i = 0; i < numdisplaymodes; i++){
	displaymode.format = 0;
	displaymode.w = 0;
	displaymode.h = 0;
	displaymode.refresh_rate = 0;
	displaymode.driverdata = 0;
	if(SDL_GetDisplayMode(0, i, &displaymode) < 0){
		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\nExiting...\n", SDL_GetError());
		SDL_Quit();
		exit(EXIT_FAILURE);
	}
	SDL_Log("%dx%d %d %X\n", displaymode.w, displaymode.h, displaymode.refresh_rate);
}

return 0;

}

This program gives the following output:

Code:

INFO: Number of display modes: 21
INFO: 1600x900 60 0
INFO: 1600x900 0 0
INFO: 1440x900 74 0
INFO: 1440x900 59 0
INFO: 1280x800 74 0
INFO: … etc

The second returned display mode has 0 refresh rate. Is this intended or a bug and should I report it?
1600x900 is my monitor’s native resolution. OS: Linux x64, nvidia binary drivers.

I’m not seeing this myself, also on nVidia’s x86-64 Linux drivers
(325.08). Are you running the latest HG version of SDL? This could be
related to http://bugzilla.libsdl.org/show_bug.cgi?id=1956 and I’ll have
a bit of a look.

Of course, I know the nVidia X11 drivers used to use fake display modes
to differentiate metamodes, though I think they’ve stopped that now that
XRandR 1.2 is supported. Do you have a multi-monitor setup?

– DavidOn 23/07/13 18:41, axper wrote:

Code:

#include

int main()
{
SDL_DisplayMode displaymode;
int i;
int numdisplaymodes;

if(SDL_Init(SDL_INIT_VIDEO) < 0){
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, “%s\nExiting…\n”,
SDL_GetError());
SDL_Quit();
exit(EXIT_FAILURE);
}

numdisplaymodes = SDL_GetNumDisplayModes(0);
SDL_Log(“Number of display modes: %d\n”, numdisplaymodes);
for(i = 0; i < numdisplaymodes; i++){
displaymode.format = 0;
displaymode.w = 0;
displaymode.h = 0;
displaymode.refresh_rate = 0;
displaymode.driverdata = 0;
if(SDL_GetDisplayMode(0, i, &displaymode) < 0){
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"%s\nExiting…\n", SDL_GetError());
SDL_Quit();
exit(EXIT_FAILURE);
}
SDL_Log("%dx%d %d %X\n", displaymode.w, displaymode.h,
displaymode.refresh_rate);
}

return 0;
}

This program gives the following output:

Code:

INFO: Number of display modes: 21
INFO: 1600x900 60 0
INFO: 1600x900 0 0
INFO: 1440x900 74 0
INFO: 1440x900 59 0
INFO: 1280x800 74 0
INFO: … etc

The second returned display mode has 0 refresh rate. Is this intended
or a bug and should I report it?
1600x900 is my monitor’s native resolution. OS: Linux x64, nvidia
binary drivers.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Eh, right I assumed I had the latest, but no. Updated and it works correctly now :slight_smile: