NVidia, TwinView, and OpenGL

I’ve been trying out Ubuntu Feisty Fawn (do they get 12 year old’s to pick the names? Its not that I don’t like the name, they are just… odd)… I have previously been a Debian zealot, but Ubuntu is so much fun, I’m dropping Debian (shock and horror).

When I first setup Ubuntu I was impressed that I could enable NVidia’s proprietary driver with a few clicks. I was disappointed that I pretty much had to, as with a dual screen setup, the right LCD was displaying blinking garbage the whole time with the free driver.

This brings me to my main point, after enabling the NVidia driver, and using their nvidia-settings program, I had it all looking exactly how I wanted. Unfortunately when launching any OpenGL program (such as OpenArena), the program would centre itself between the two monitors, leaving a less than desirable view.

After not finding any information on how to solve this on the Ubuntu Forums, I posted a help request. 10 minutes later I stumbled across a solution on the web. I updated my Ubuntu question with the solution. That was about 5 days ago.

Today I went back to the forum, and tried to find my question again. All I could find was more people asking the exact same question I had, with to replies, so I set about replying to their questions with a link to my answer.

I now reproduce that answer here, so that Google might find it and index it.

Solution

The problem is OpenGL needs a mode available where only one screen is active. The solution is to give it one.
Edit /etc/X11/xorg.conf (Use your favourite method, I use sudo vim /etc/X11/xorg.conf )

Find the “Screen” section
Change the metamodes option to add a new mode at your primary resolution, with only one screen with the mode, the other with NULL.

eg My new metamodes option looks like this:
Option “metamodes” “1280×1024,1280×1024; 1280×1024,NULL”
(The above should be all on one line obviously)
Restart the X server (Ctrl+Alt+Backspace), and it works.

Adding the 1280×1024,NULL mode seems to allow OpenGL apps to use just the left screen. (Obviously if you use this solution, change the resolutions to match your monitors).

One of the biggest problems with Open Source programs its difficult to find a single place to look for solutions, and when you do find that place, its difficult to find your problem described in the same way you describe it.

2 Responses to “NVidia, TwinView, and OpenGL”

  1. Jack Says:

    I tried your solution but have had problems. I have Ubuntu on an AMD64 system with some old generic Jaton video card with an nvidia chipset with dual CRTs (I know, Old School). When I set the metamode option and rebooted X, I got just one monitor on and the whole desktop was squished into it. This was just logging in, not even in an open gl app. Just wanted to get the word out to see if anyone else had similar problems.

  2. zaf Says:

    My solution above deals with allowing OpenGL to display only in one window. If, without my above changes, you still have the problem of the squished screen, then fix that problem first.

    If however adding that one line makes your single screen squished, check /etc/X11/xorg.conf
    Look at Section “Screen”
    And look at subsection “Display”. Mine reads:
    SubSection “Display”
    Depth 24
    Modes “1600×1200″ “1280×1024″ “1024×768″ “800×600″ “640×480″
    EndSubSection
    This is basically saying, first try a 1600 x 1200 (dual head) setup, then try the other modes. I’m suspecting that your X is trying for one of the non dual head modes (say 1280 x 1024).
    It will do this if it rejects the first option (1600 x 1200). It may reject it for many reasons, and the “easiest” way to find out is to exit out of X entirely (So goto the console (ctrl+alt+f1), login, and type sudo /etc/init.d/gdm stop).
    Then try running X from a console like so:
    # startx 2>/tmp/x.log
    After X starts, abort (ctrl+alt+backspace), and read x.log, looking for why X is rejecting the 1600×1200 mode (or whatever your dual head set up is).

    In the end, if you still can’t get it working, the best advice I can give is post to the Ubuntu forums with all your system details (xorg.conf file, x.log log file, etc)

Leave a Reply