Games, SDL, setting resolution

From Ubuntuwiki.net

Jump to: navigation, search

Very, very many games originally written for Windows have resolution issues. The fix for this is to generate Modelines in /etc/X11/xorg.conf to match the desired resolutions.

For example, let's create a Modeline for 1024x768:

me@banshee:~$ cvt 1024 768
# 1024x768 59.92 Hz (CVT 0.79M3) hsync: 47.82 kHz; pclk: 63.50 MHz
Modeline "1024x768_60.00"   63.50  1024 1072 1176 1328  768 771 775 798 -hsync +vsync

Now let's test our new Modeline before we commit it to /etc/X11/xorg.conf for good:

me@banshee:~$ xrandr
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 3360 x 1050, current 3360 x 1050, maximum 3360 x 1050
default connected 3360x1050+0+0 0mm x 0mm
   3360x1050      50.0* 
        h: width  1024 start 1072 end 1176 total 1328 skew    0 clock   47.8KHz
        v: height  768 start  771 end  775 total  798           clock   59.9Hz

Notice here that my screen is named "default" - see where it says "default connected 3360x1050"? That's important; if your screen name isn't "default" when you check xrandr, you'll need to substitute that name in the following commands. Note that in our xrandr --newmode command, we are using the output of the cvt command we entered above - don't just blindly copy and paste the following, you too need to use the output you got when you ran cvt!

me@banshee:~$ xrandr --newmode "1024x768_60.00"   63.50  1024 1072 1176 1328  768 771 775 798 -hsync +vsync
xrandr: Failed to get size of gamma for output default

Now that you've created your new mode, you'll need to add that mode to the current display (remember, use the display name you got from xrandr above):

me@banshee:~$ xrandr --addmode default 1024x768_60.00
xrandr: Failed to get size of gamma for output default

Now you'll see your new resolution show up when you run xrandr with no arguments:

me@banshee:~$ xrandr
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 1024 x 768, current 3360 x 1050, maximum 3360 x 1050
default connected 3360x1050+0+0 0mm x 0mm
   3360x1050      50.0* 
   1024x768_60.00   59.9  

Voila - this should be sufficient to get your games to recognize this as a valid windowed resolution. (For reference, I had to figure all this out in order to make Dungeons of Dredmor, from Gaslamp Games, behave.) Go ahead and test it briefly to make sure it all works - then, before you get too busy playing games, make sure it will STAY this way when you reboot or restart X; so far, all you've done has been ephemeral and will be wiped out with the next restart!

Edit /etc/X11/xorg.conf, and insert the Modeline that cvt gave us, like so:

Section "Monitor"
   # HorizSync source: edid, VertRefresh source: edid
   Identifier     "Monitor0"
   VendorName     "Unknown"
   ModelName      "Acer AL2216W"
   HorizSync       31.0 - 84.0
   VertRefresh     56.0 - 77.0
   Option         "DPMS"
   Modeline "1024x768_60.00"   63.50  1024 1072 1176 1328  768 771 775 798 -hsync +vsync
EndSection

That's all it took. Now, when we restart Xorg, the new Modeline will be present, and our new resolution should show up in games that offer specific windowed resolutions, just as it did in our initial testing using xrandr.

Personal tools