Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • 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:

  • https://forums.virtualbox.org/viewtopic.php?f=3&t=30964
  • https://www.virtualbox.org/ticket/6848

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.

like image 823
Matthias Calis Avatar asked Dec 13 '22 04:12

Matthias Calis


1 Answers

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.

like image 159
FulminatedPostilion Avatar answered Dec 31 '22 01:12

FulminatedPostilion