【问题标题】:libGL errors when executing OpenGL program执行 OpenGL 程序时出现 libGL 错误
【发布时间】:2016-09-01 22:27:26
【问题描述】:

当我尝试执行我的程序时出现此错误:

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:  GLXBadFBConfig
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  34 ()
  Serial number of failed request:  42
  Current serial number in output stream:  41

我的代码(我从“OpenGL Development Cookbook”一书中获取):

#include <GL/glew.h>
#include <GL/freeglut.h>
#include <iostream>

const int WIDTH = 640;
const int HEIGHT = 480;

void OnInit()
{
   glClearColor(1, 0, 0, 0);
   std::cout << "Initialization successfull" << std::endl;
}

void OnShutdown()
{
   std::cout << "Shutdown successfull" << std::endl;
}

void OnResize(int nw, int nh)
{

}

void OnRender()
{
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   glutSwapBuffers();
}

int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
   glutInitContextVersion(3, 3);
   glutInitContextFlags(GLUT_CORE_PROFILE | GLUT_DEBUG);
   glutInitContextProfile(GLUT_FORWARD_COMPATIBLE);
   glutInitWindowSize(WIDTH, HEIGHT);
   glutCreateWindow("OpenGL");

   glewExperimental = GL_TRUE;
   GLenum err = glewInit();

   if(GLEW_OK != err) {std::cerr << "Error: " << glewGetErrorString(err) << std::endl; }
   else{if(GLEW_VERSION_3_3) {std::cout << "Driver supports OpenGL 3.3\n Details: " << std::endl; }}

   std::cout << "\tUsing glew: " << glewGetString(GLEW_VERSION) << std::endl;
   std::cout << "\tVendor: " << glGetString(GL_VENDOR) << std::endl;
   std::cout << "\tRenderer: " << glGetString(GL_RENDERER) << std::endl;
   std::cout << "\tGLSL: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;

   OnInit();
   glutCloseFunc(OnShutdown);
   glutDisplayFunc(OnRender);
   glutReshapeFunc(OnResize);
   glutMainLoop();
   return 0;
}

我通过 glxinfo | 验证了我的驱动程序是否支持我正在使用的 OpenGL 版本。 grep "OpenGL" 命令:

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Sandybridge Mobile 
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.5.9
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 10.5.9
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:

我正在使用 Ubuntu 14.04.3

我不确定,但我认为我收到此错误是因为我使用的是 intel 而不是 Nvidia

【问题讨论】:

    标签: c++ ubuntu opengl


    【解决方案1】:

    很难从远处分辨出来,但那里出现的错误看起来像是 OpenGL 客户端库安装损坏。 glxinfo 查询加载到 Xorg 服务器中的 GLX 驱动程序,该驱动程序在某种程度上独立于已安装的 libGL(只要只进行间接渲染调用)。这些错误表明安装的 libGL 与 DRI 驱动程序不匹配或 DRI 库已损坏。

    无论哪种方式,最好的做法是在您的系统上彻底重新安装与 OpenGL 相关的所有内容。 IE。强制重新安装 xorg-server、xf86-video-…、mesa、libdri…等。

    【讨论】:

    • 如何重新安装,我只是删除并安装?
    • 您使用的是 Ubuntu,所以我建议 apt-get install --reinstall libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa i965-va-driver libdrm-intel1 xserver-xorg-video-intel xserver-xorg libdrm2 负责处理所有参与英特尔显卡的软件包。
    • 我做到了,现在我得到了这个:X Error of failed request: GLXBadFBConfig Major opcode of failed request: 154 (GLX) Minor opcode of failed request: 34 () Serial number of failed request: 36 Current serial number in output stream: 35 和以前不一样了
    • 它有效,我评论了glutInitContextProfile(GLUT_FORWARD_COMPATIBLE);,现在它有效。感谢您尝试帮助我。
    【解决方案2】:

    我遇到了一个非常相似的错误:

    X Error of failed request:  GLXBadFBConfig
      Major opcode of failed request:  154 (GLX)
      Minor opcode of failed request:  34 ()
      Serial number of failed request:  42
      Current serial number in output stream:  41
    

    删除以下行解决了它:

    glutInitContextVersion(3, 3);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-20
      • 2019-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多