0

I'm learning OpenGL on Mac, where it works fine and I'm trying to recreate my programs on Linux Mint 17.3 in a VirtualBox virtual machine.

I am told I only need g++, make, freeglut3-dev and a text editor and I believe I already have all of these. If I do sudo apt-get install g++ for example, it will say g++ is already the newest version and it is the same for the rest as well.

I've written a simple program:

#include <GL/freeglut.h>
#include <GL/gl.h>

void renderFunction() {
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
    glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
    glBegin(GL_POLYGON);
    glVertex2f(-0.5, -0.5);
    glVertex2f(-0.5, 0.5);
    glVertex2f(0.5, 0.5);
    glVertex2f(0.5, -0.5);
    glEnd();
    glFlush();
}

int main(int argc, char** argv) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE);
    glutInitWindowSize(500,500);
    glutInitWindowPosition(100,100);
    glutCreateWindow("OpenGL - First window demo");
    glutDisplayFunc(renderFunction);
    glutMainLoop();  

return 0;
}

The compile command g++ opengl.c -lglut -lGL -lGLEW -lGLU -o opengl seems to work. But when I run ./opengl I get a massive error message:

pci id for fd 4: 80ee:beef, driver (null)
OpenGL Warning: glFlushVertexArrayRangeNV not found in mesa table
OpenGL Warning: glVertexArrayRangeNV not found in mesa table
OpenGL Warning: glCombinerInputNV not found in mesa table
OpenGL Warning: glCombinerOutputNV not found in mesa table
OpenGL Warning: glCombinerParameterfNV not found in mesa table
OpenGL Warning: glCombinerParameterfvNV not found in mesa table
OpenGL Warning: glCombinerParameteriNV not found in mesa table
OpenGL Warning: glCombinerParameterivNV not found in mesa table
OpenGL Warning: glFinalCombinerInputNV not found in mesa table
OpenGL Warning: glGetCombinerInputParameterfvNV not found in mesa table
OpenGL Warning: glGetCombinerInputParameterivNV not found in mesa table
OpenGL Warning: glGetCombinerOutputParameterfvNV not found in mesa table
OpenGL Warning: glGetCombinerOutputParameterivNV not found in mesa table
OpenGL Warning: glGetFinalCombinerInputParameterfvNV not found in mesa table
OpenGL Warning: glGetFinalCombinerInputParameterivNV not found in mesa table
OpenGL Warning: glDeleteFencesNV not found in mesa table
OpenGL Warning: glFinishFenceNV not found in mesa table
OpenGL Warning: glGenFencesNV not found in mesa table
OpenGL Warning: glGetFenceivNV not found in mesa table
OpenGL Warning: glIsFenceNV not found in mesa table
OpenGL Warning: glSetFenceNV not found in mesa table
OpenGL Warning: glTestFenceNV not found in mesa table
libGL error: core dri or dri2 extension not found
libGL error: failed to load driver: vboxvideo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000023ace70
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000023b2810
OpenGL Warning: Retry with 0x8003 returned 0 visuals

...

OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000023b1520
OpenGL Warning: Retry with 0x8003 returned 0 visuals
freeglut (./opengl):  ERROR:  Internal error <visualInfo could not be retrieved from FBConfig> in function fgOpenWindow

I have no idea what any of this means or how to deal with it.

1 Answer 1

2

OpenGL relies on graphics drivers. VirtualBox does not have the most up-to-date, working drivers. Best you can do is install guest additions. Freeglut isn't helping either, most promising would be to write the minimal code needed by hand only using glad and GLFW. But don't expect much and certainly not "testing the portability of my program".

I once managed to get OpenGL 3.3 working on a particular version of Ubuntu with some experimental mesa drivers after a few tries, but I have no idea how to reliably reproduce that. Almost the same question on askubuntu.

Sign up to request clarification or add additional context in comments.

4 Comments

I've already installed guest additions and tried a whole bunch of other 'solutions'. The only one that seems to work is disabling 3D acceleration in VBox Manager. Is it only a problem with VirtualBox and not Ubuntu itself? If so, would OpenGL work if I just installed the OS alongside MacOS (via Bootcamp)? I was planning on doing that soon anyway.
Yes, this is a problem with VirtualBox graphics drivers. Installing Linux normally should be better, but I am not sure how mature are Linux drivers for Mac PCs(AMD GPUs), you might want to do some googling about which distribution is the best for this.
Thanks for the advice, I will do some more research on this before making a decision.
@kashveyron: Yes, it's a problem caused by running inside a VM. OpenGL first and foremost is an API to talk to GPUs. Inside a VM you have either no GPU at all, which will make some OpenGL implementations (like the one of Linux, called Mesa) fall back to a software rasterizer. If you pass through 3D acceleration, you need an OpenGL implementation that knows how to talk to the VM. And often these are not well integrated into typical Linux environments/package managers. If you want to do OpenGL programming in a VM, either do it without acceleration, or give it a true GPU by PCI passthrough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.