PDA

View Full Version : Glut Game Mode



dorix
01-09-2001, 08:01 AM
Hi all,

I'm having a problem getting glutGameModeString to change the display resolution in Linux. I'm using an nVidia GeForce2 GTS with the nVidia supplied drivers (everything else works like a top), Glut 3.7, XFree86 4.0.1/2, Linux kernel 2.4.0 final. In my XF86Config file, I have the DDC, EXTMOD, DBE, TYPE1, FREETYPE, GLX modules loaded. Modes that I've allowed to run (and do work properly with CtrlAlt+/-) are 1280x1024 at 24bit depth and 640x480 at 24bit depth. Both modes are available with a refresh rate of 85.0Hz.

Normally, I would expect glutGameModeGet(...) to return successful when I pass in a valid game mode string. I've tried this on a different computer running Windows NT and got exactly the results one would expect. However, on my Linux box, no matter what game mode string I pass, I get an unsuccessful return from glutGameModeGet, indicating that there are no display modes I can use.

Here is a code snippet to demonstrate what I'm trying. The printf function ("Valid mode") never occurs. With all the possible modes I'm trying, one would expect at least one to work, right?

By the way, yes, I know I have to call glutEnterGameMode to actually change the resolution/settings, but glutGameModeGet is supposed to tell me immediately if a game mode string will work.




unsigned char* res[] =
{"320x200", "320x240", "512x384",
"640x400", "640x480", "800x600",
"1024x768", "1280x1024", "1600x1200"};
unsigned char* depth[] =
{"8", "15", "16", "24", "32"};
unsigned char* ref[] =
{"60", "65", "70", "72", "75", "80",
"85", "90", "95", "100", "105", "110",
"115", "120"};

// Other code snipped out

void myInitFunc(int argc, char** argv)
{
int r, d, rf;
char gameString[20];
glutInit(argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEP TH);

for (r = 0; r < 9; r++) {
for (d = 0; d < 5; d++) {
for (rf = 0; rf < 14; rf++) {
memset(gameString, 0, 20);
sprintf(gameString, "%s:%s@%s", res[r], depth[d], ref[rf]);
glutGameModeString(gameString);
if (glutGameModeGet(GLUT_GAME_MODE_WIDTH) != -1) {
printf("Valid mode: %s\n", gameString);
}
}
}
}
}



[This message has been edited by dorix (edited 01-09-2001).]

dorix
01-09-2001, 08:37 AM
Seems that I'm a goof. Game Mode doesn't work in X at all, if I had tried glutGameModeGet(GLUT_GAME_MODE_POSSIBLE) I'd have seen that right away.

What messed me up was that glutEnterGameMode actually will go full screen, in the current display mode.

Cheers!


[This message has been edited by dorix (edited 01-09-2001).]