我复制了一个在Linux中使用OpenGL的Hello世界示例,但是我在执行时遇到了问题。
在此之前,我使用“-lGL”和“lllut”建立链接,编译器很高兴并且没有错误。
然后当我启动可执行文件时,我得到了这个:
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request: GLXBadContext
Major opcode of failed request: 155 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request: 49
Current serial number in output stream: 48
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 155 (GLX)
Minor opcode of failed request: 24 (X_GLXCreateNewContext)
Value in failed request: 0x0
Serial number of failed request: 48
Current serial number in output stream: 49
[2016-12-15 21:41:44] process exited with status 1, elapsed time: 00.21s
这是简单的hello world代码:
#include <GL/glut.h>
void displayMe(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.5, 0.0, 0.0);
glVertex3f(0.5, 0.5, 0.0);
glVertex3f(0.0, 0.5, 0.0);
glEnd();
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE);
glutInitWindowSize(300, 300);
glutInitWindowPosition(100, 100);
glutCreateWindow("Hello world :D");
glutDisplayFunc(displayMe);
glutMainLoop();
return 0;
}
我使用的是戴尔XPS 9530,我使用以下驱动程序:Mesa DRI英特尔(R)HD Graphics 520(Skylake GT2)
所以我不明白为什么OpenGL想得到i965的指针。
编辑:我刚刚发现,当我从终端启动二进制文件时,它的工作正常并且窗口正确显示。只有当我在IDE(Gnat Programming Studio)中使用终端时才会出现错误。奇怪