Matthias Calis
Matthias Calis

Reputation: 143

OpenGL GLUT on VirtualBox Ubuntu 11.10 segmentation fault

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:

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

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.

Upvotes: 4

Views: 4382

Answers (2)

FulminatedPostilion
FulminatedPostilion

Reputation: 91

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.

Upvotes: 9

Goyuix
Goyuix

Reputation: 24340

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.

Upvotes: 4

Related Questions