无法在 Linux 分钟内 运行 简单的 OpenGL 程序
Not able to run simple OpenGL program in Linux Minut
我正在 Mac 上学习 OpenGL,它工作正常,我正在尝试在 VirtualBox 虚拟机中的 Linux Mint 17.3 上重新创建我的程序。
有人告诉我我只需要 g++、make、freeglut3-dev 和一个文本编辑器,我相信我已经拥有了所有这些。例如,如果我做 sudo apt-get install g++
,它会说 g++ is already the newest version
,其余的也一样。
我写了一个简单的程序:
#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;
}
编译命令g++ opengl.c -lglut -lGL -lGLEW -lGLU -o opengl
似乎有效。但是当我 运行 ./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
我不知道这意味着什么或如何处理它。
OpenGL 依赖于图形驱动程序。 VirtualBox 没有最新的可用驱动程序。您能做的最好的事情就是安装来宾添加项。 Freeglut
也无济于事,最有希望的是仅使用 glad
和 GLFW
手动编写所需的最少代码。但不要期望太多,当然也不要 "testing the portability of my program".
我曾在几次尝试后设法让 OpenGL 3.3 在 Ubuntu 的特定版本上使用一些实验性台面驱动程序,但我不知道如何可靠地重现它。
askubuntu.
上几乎是同样的问题
我正在 Mac 上学习 OpenGL,它工作正常,我正在尝试在 VirtualBox 虚拟机中的 Linux Mint 17.3 上重新创建我的程序。
有人告诉我我只需要 g++、make、freeglut3-dev 和一个文本编辑器,我相信我已经拥有了所有这些。例如,如果我做 sudo apt-get install g++
,它会说 g++ is already the newest version
,其余的也一样。
我写了一个简单的程序:
#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;
}
编译命令g++ opengl.c -lglut -lGL -lGLEW -lGLU -o opengl
似乎有效。但是当我 运行 ./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
我不知道这意味着什么或如何处理它。
OpenGL 依赖于图形驱动程序。 VirtualBox 没有最新的可用驱动程序。您能做的最好的事情就是安装来宾添加项。 Freeglut
也无济于事,最有希望的是仅使用 glad
和 GLFW
手动编写所需的最少代码。但不要期望太多,当然也不要 "testing the portability of my program".
我曾在几次尝试后设法让 OpenGL 3.3 在 Ubuntu 的特定版本上使用一些实验性台面驱动程序,但我不知道如何可靠地重现它。 askubuntu.
上几乎是同样的问题