简体   繁体   English

无法在Linux Minut中运行简单的OpenGL程序

[英]Not able to run simple OpenGL program in Linux Minut

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. 我正在Mac上学习OpenGL,在它可以正常工作的情况下,我试图在VirtualBox虚拟机中的Linux Mint 17.3上重新创建程序。

I am told I only need g++, make, freeglut3-dev and a text editor and I believe I already have all of these. 有人告诉我我只需要g ++,make,freeglut3-dev和文本编辑器,我相信我已经拥有了所有这些。 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. 例如,如果我执行sudo apt-get install g++ ,它将说g++ is already the newest version ,其余g++ is already the newest version也相同。

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. 编译命令g++ opengl.c -lglut -lGL -lGLEW -lGLU -o opengl似乎有效。 But when I run ./opengl I get a massive error message: 但是当我运行./opengl ,会收到大量错误消息:

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. 我不知道这意味着什么或如何处理。

OpenGL relies on graphics drivers. OpenGL依赖图形驱动程序。 VirtualBox does not have the most up-to-date, working drivers. VirtualBox没有最新,有效的驱动程序。 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 . FreeglutFreeglut ,最有希望的是仅使用gladGLFW来编写所需的最少代码。 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. 经过几次尝试,我曾经设法通过一些实验性的台面驱动程序使OpenGL 3.3在特定版本的Ubuntu上运行,但是我不知道如何可靠地重现它。 Almost the same question on askubuntu . 关于Askubuntu几乎是相同的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM