4

DISCLAIMER: I see that some suggestions for the exact same question come up, however that (similar) post was migrated to SuperUsers and seems to have been removed. I however would still like to post my question here because I consider it software/programming related enough not to post on SuperUsers (the line is vague sometimes between what is a software and what is a hardware issue).

I am running a very simple OpenGL program in Code::Blocks in VirtualBox with Ubuntu 11.10 installed on a SSD. Whenever I build&run a program I get these errors:

  • OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x232dbe0
  • OpenGL Warning: Retry with 0x802 returned 0 visuals
  • Segmentation fault

From what I have gathered myself so far this is VirtualBox related. I need to set

  • LIBGL_ALWAYS_INDIRECT=1

In other words, enabling indirect rendering via X.org rather then communicating directly with the hardware. This issue is probably not related to the fact that I have an ATI card as I have a laptop with an ATI card that runs the same program flawlessly.

Still, I don't dare to say that the fact that my GPU is an ATI doesn't play any role at all. Nor am I sure if the drivers are correctly installed (it says under System info -> Graphics -> graphics driver: Chromium.)

Any help on HOW to set LIBGL_ALWAYS_INDIRECT=1 would be greatly appreciated. I simply lack the knowledge of where to put this command or where/how to execute it in the terminal.

Sources:

EDIT: in the terminal type:

export LIBGL_ALWAYS_INDIRECT = 1

To verfiy that direct rendering is off:

glxinfo | grep direct

However, the problem persists. I still get mentioned OpenGL warnings and the segmentation fault.

Matthias Calis
  • 143
  • 1
  • 12

2 Answers2

9

I ran into this same problem running the Bullet Physics OpenGL demos on Ubuntu 12.04 inside VirtualBox. Rather than using indirect rendering, I was able to solve the problem by modifying the glut window creation code in my source as described here: https://groups.google.com/forum/?fromgroups=#!topic/comp.graphics.api.opengl/Oecgo2Fc9Zc.

This entailed replacing the original

...
glutCreateWindow(title);
...

with

...
if (!glutGet(GLUT_DISPLAY_MODE_POSSIBLE))
{ 
    exit(1); 
}
glutCreateWindow(title);
...

as described in the link. It's not clear to me why this should correct the segfault issue; apparently glutGet has some side effects beyond retrieving state values. It could be a quirk of freeglut's implementation of glut.

4

If you look at the /etc/environment file, you can see a couple of variables exposed there - this will give you and idea of how to expose that environment variable across the entire system. You could also try putting it in either ~/.profile or ~/.bash_profile depending on your needs.

The real question in my mind is: Did you install the guest additions for Ubuntu? You shouldn't need to install any ATI drivers in your guest as VirtualBox won't expose the actual physical graphics hardware to your VM. You can configure your guest to support 3D acceleration in the virtual machine settings (make sure you turn off the VM first) under the Display section. You will probably want to boost the allocated virtual memory - 64MB or 128MB should be plenty depending on your needs.

Goyuix
  • 23,614
  • 14
  • 84
  • 128
  • I did a full, fresh install of ubuntu on some spare SSD space, all runs well now. It seems the problem is Vbox related. I had my graphical memory at 128MB btw. Still, you are the only person who answered and took the effort to look into this, therefore I will accpet this answer. – Matthias Calis Mar 20 '12 at 09:40
  • Bumping up the virtual memory and adding ``export LIBGL_ALWAYS_INDIRECT=1`` to ``~/.bashrc`` worked for me, thank you! – A D Jul 18 '12 at 16:08