Sunday, February 15, 2009

Full Screen gaming with Nvidia TwinView


One thing that has always bugged me with gaming on linux, is twinview. Due to the fact of how twinview works your absolute resolution is the total of all your displays... ie
2x 1280x1024 panels would be 2560x1024. Now most full screen games (ie games without windowing) see that as your screen size is 2560x1024, so you end up having the game spread across the two monitors.....yay.
Now most games have a windowed option which is generally what i use but there are some that dont have the in game option nor do they have a runtime flag.
So to fix this we need to add another metamode in the xorg.conf

GUI Way: press ALT+F2 to get a run box dialog and type in: gksudo nvidia-settings

So you should see something like th following:
Now we need to add another metamode, click 'Advanced' then click the 'X Screen' Tab.
Click 'Add' Next to metamode, then click back to the 'Display' Tab.
Now what we want to do is turn off the second monitor, so highligh the monitor you want off for gaming then set resolution to off.
Now you should have something like the following:

From here you want to click 'Save to X Configuration File' then click 'Quit' and reload your window manager either by closing all your desktop application and hitting ctr+alt+backspace, logging out/in or restarting the machine.

The CLI way:
Using your preferred editor open up /etc/X11/xorg.conf and locate the line: 'Option "metamodes" which will be under the screen section.
simply add another mode like the following:
Original:
Option "metamodes" "DFP-0: 1280x1024 +0+0, DFP-1: 1280x1024 +1280+0"
New:
Option "metamodes" "DFP-0: 1280x1024 +0+0, DFP-1: 1280x1024 +1280+0; DFP-0: 1280x1024 +0+0, DFP-1: NULL"

This simply says that have another mode that has the first monitor at 1280x1024 and the second is off. Write the file and relog/reload X.


Controlling the metamodes:

Now that we have 2 metamodes you can see them by opening up a terminal and typing:
xrandr -q

To switch between modes use (X being which mode starting from 0):
xrandr -s X

Now when we start up a game we can run
xrandr -s 1 (to change to one panel)
and
xrandr -s 0 (to change back to two panels when we are done)

If this is too cumbersome put it in a simple bash script:
File: /usr/local/bin/launch_somegame
#!/bin/bash
xrandr -s 1
/path/to/somegame
xrandr -s 0

1 comment:

  1. If you keep posting helpful gaming tips like this I might end up back in Linux again ;)

    ReplyDelete