title: X Error of failed request: GLXBadFBConfig
body: <p>I'm trying to do a Sierpinski gasket as specified in <em>"INTERACTIVE COMPUTER GRAPHICS
  A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL®"</em> 6th edition.</p>
  
  <p>I have this code</p>
  
  <p>Sierpinski.cpp
  </p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;GL/glew.h&gt;
  #include &lt;GL/glut.h&gt;
  #include &lt;glm/glm.hpp&gt;
  #include "Angel.h"
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;cmath&gt;
  #define NUM_PUNTOS 4
  #define DIVISIONES 5
  
  
  namespace Global
  {
      GLint Ndivisions = DIVISIONES;
      GLint Nvertices = (GLint) std::pow(3,Ndivisions + 1);
      std::vector&lt;glm::vec2&gt; points;
  
  };
  
  void display(void);
  void init();
  //void idle(void);
  void triangle(glm::vec2,glm::vec2,glm::vec2,std::vector&lt;glm::vec2&gt; &amp;);
  void divide_triangle(glm::vec2,glm::vec2,glm::vec2,GLint,std::vector&lt;glm::vec2&gt; &amp;);
  inline glm::vec2 dividir(glm::vec2,double);
  glm::vec2 dividir(glm::vec2,double);   
  
  int main(int argc, char **argv)
  {
      glutInit(&amp;argc,argv);
      glutInitDisplayMode(GLUT_RGBA);
      glutInitWindowSize(800,600);
      glutInitContextVersion(3,2);
      glutInitContextProfile(GLUT_CORE_PROFILE);
      //IMPORTANTE: CREAR ANTES QUE LOS CALLBACKS
      glutCreateWindow("Sierpinski gasket");    //Init
      glewInit();//IMPORTANTÍSIMO
      init();    
      glutDisplayFunc(display);
      #ifdef LIBGL_DEBUG
      std::cout&lt;&lt;LIBGL_DEBUG&lt;&lt;'\n';
      #endif
  
      //Despues de todo es que se crea la ventana
      glutMainLoop();    
  
  }
  void display(void)
  {
      glClear(GL_COLOR_BUFFER_BIT);
      glDrawArrays(GL_POINTS, 0, Global::Nvertices);
      glFlush();
  }
  void init()
  {
      //Inicializamos array global
      divide_triangle(glm::vec2(0.0,0.0),glm::vec2(1.0,0.0),glm::vec2(0.5,1.0),Global::Ndivisions,Global::points);
      glm::vec2 *points = &amp;Global::points[0];
      GLuint vao,program;
      program = Angel::InitShader("shaders/Sierpinski.vertex.glsl",
              "shaders/Sierpinski.fragment.glsl");
      glUseProgram(program);
  
      for(int x = 0; x&lt;Global::points.size();x++)
          std::cout&lt;&lt;"X: "&lt;&lt;points[x].x&lt;&lt;" Y: "&lt;&lt;points[x].y&lt;&lt;"\n";
  
      glGenVertexArrays(1, &amp;vao);
      glBindVertexArray(vao);
      //Buffers
      GLuint buffer;
      glGenBuffers(1, &amp;buffer);
      std::cout&lt;&lt;"Primer test\n";
      glBindBuffer(GL_ARRAY_BUFFER, buffer);
      glBufferData(GL_ARRAY_BUFFER,sizeof(points),
              points,GL_STATIC_DRAW);
      //glGenVertexArrays(1, &amp;buffer);
      //glBindVertexArray(buffer);
      std::cout&lt;&lt;buffer&lt;&lt;'\n';
      // Initialize the vertex position attribute from the vertex shader
      GLuint loc = glGetAttribLocation( program, "vPosition" );
      glEnableVertexAttribArray( loc );
      glVertexAttribPointer( loc, 2, GL_FLOAT, GL_FALSE, 0,
              BUFFER_OFFSET(0) );
  
  }
  void triangle(glm::vec2 a,glm::vec2 b,glm::vec2 c,std::vector&lt;glm::vec2&gt; &amp;points)
  {
      size_t old_size = points.size();
      points.resize(old_size + 3);
      points[old_size] = a;
      points[old_size + 1] = b;
      points[old_size + 2] = c;
      //std::cout&lt;&lt;"Finalizado\n";
  }
  
  void divide_triangle(glm::vec2 a,glm::vec2 b,glm::vec2 c,GLint k,std::vector&lt;glm::vec2&gt; &amp;points)
  {
      if(k&gt;0)
      {
          glm::vec2 ab = dividir(a + b,2.0);
          glm::vec2 ac = dividir(a + c,2.0);
          glm::vec2 bc = dividir(b + c,2.0);
  
          //Dividimos triángulo
          int new_k = k - 1;
          divide_triangle(a,ab,ac,new_k,points);
          divide_triangle(c,ac,bc,new_k,points);
          divide_triangle(b,bc,ab,new_k,points);
      }
      else
      {
          triangle(a,b,c,points);
      }
  }
  
  glm::vec2 dividir(glm::vec2 vectorcito,double escalar)
  {
      return glm::vec2(vectorcito.x/escalar,vectorcito.y/escalar);
  }
  //void idle(void){}
  </code></pre>
  
  <p>Angel.h</p>
  
  
  
  <pre class="lang-c prettyprint-override"><code>//////////////////////////////////////////////////////////////////////////////
  //
  //  --- Angel.h ---
  //
  //   The main header file for all examples from Angel 6th Edition
  //
  //////////////////////////////////////////////////////////////////////////////
  
  #ifndef __ANGEL_H__
  #define __ANGEL_H__
  
  //----------------------------------------------------------------------------
  // 
  // --- Include system headers ---
  //
  
  #include &lt;cmath&gt;
  #include &lt;iostream&gt;
  
  //  Define M_PI in the case it's not defined in the math header file
  #ifndef M_PI
  #  define M_PI  3.14159265358979323846
  #endif
  
  //----------------------------------------------------------------------------
  //
  // --- Include OpenGL header files and helpers ---
  //
  //   The location of these files vary by operating system.  We've included
  //     copies of open-soruce project headers in the "GL" directory local
  //     this this "include" directory.
  //
  
  #ifdef __APPLE__  // include Mac OS X verions of headers
  #  include &lt;OpenGL/OpenGL.h&gt;
  #  include &lt;GLUT/glut.h&gt;
  #else // non-Mac OS X operating systems
  #  include &lt;GL/glew.h&gt;
  #  include &lt;GL/freeglut.h&gt;
  #  include &lt;GL/freeglut_ext.h&gt;
  #endif  // __APPLE__
  
  // Define a helpful macro for handling offsets into buffer objects
  #define BUFFER_OFFSET( offset )   ((GLvoid*) (offset))
  
  //----------------------------------------------------------------------------
  //
  //  --- Include our class libraries and constants ---
  //
  
  namespace Angel {
  
  //  Helper function to load vertex and fragment shader files
  GLuint InitShader( const char* vertexShaderFile,
             const char* fragmentShaderFile );
  
  //  Defined constant for when numbers are too small to be used in the
  //    denominator of a division operation.  This is only used if the
  //    DEBUG macro is defined.
  const GLfloat  DivideByZeroTolerance = GLfloat(1.0e-07);
  
  //  Degrees-to-radians constant 
  const GLfloat  DegreesToRadians = M_PI / 180.0;
  
  }  // namespace Angel
  
  /*#include "vec.h"
  #include "mat.h"
  #include "CheckError.h"*/
  
  #define Print(x)  do { std::cerr &lt;&lt; #x " = " &lt;&lt; (x) &lt;&lt; std::endl; } while(0)
  
  //  Globally use our namespace in our example programs.
  //using namespace Angel;
  
  namespace Angel {
  
  // Create a NULL-terminated string by reading the provided file
  static char*
  readShaderSource(const char* shaderFile)
  {
      FILE* fp = fopen(shaderFile, "r");
  
      if ( fp == NULL ) { return NULL; }
  
      fseek(fp, 0L, SEEK_END);
      long size = ftell(fp);
  
      fseek(fp, 0L, SEEK_SET);
      char* buf = new char[size + 1];
      fread(buf, 1, size, fp);
  
      buf[size] = '\0';
      fclose(fp);
  
      return buf;
  }
  
  
  // Create a GLSL program object from vertex and fragment shader files
  GLuint
  InitShader(const char* vShaderFile, const char* fShaderFile)
  {
      struct Shader {
      const char*  filename;
      GLenum       type;
      GLchar*      source;
      }  shaders[2] = {
      { vShaderFile, GL_VERTEX_SHADER, NULL },
      { fShaderFile, GL_FRAGMENT_SHADER, NULL }
      };
  
      GLuint program = glCreateProgram();
  
      for ( int i = 0; i &lt; 2; ++i ) {
      Shader&amp; s = shaders[i];
      s.source = readShaderSource( s.filename );
      if ( shaders[i].source == NULL ) {
          std::cerr &lt;&lt; "Failed to read " &lt;&lt; s.filename &lt;&lt; std::endl;
          exit( EXIT_FAILURE );
      }
  
      GLuint shader = glCreateShader( s.type );
      glShaderSource( shader, 1, (const GLchar**) &amp;s.source, NULL );
      glCompileShader( shader );
  
      GLint  compiled;
      glGetShaderiv( shader, GL_COMPILE_STATUS, &amp;compiled );
      if ( !compiled ) {
          std::cerr &lt;&lt; s.filename &lt;&lt; " failed to compile:" &lt;&lt; std::endl;
          GLint  logSize;
          glGetShaderiv( shader, GL_INFO_LOG_LENGTH, &amp;logSize );
          char* logMsg = new char[logSize];
          glGetShaderInfoLog( shader, logSize, NULL, logMsg );
          std::cerr &lt;&lt; logMsg &lt;&lt; std::endl;
          delete [] logMsg;
  
          exit( EXIT_FAILURE );
      }
  
      delete [] s.source;
  
      glAttachShader( program, shader );
      }
  
      /* link  and error check */
      glLinkProgram(program);
  
      GLint  linked;
      glGetProgramiv( program, GL_LINK_STATUS, &amp;linked );
      if ( !linked ) {
      std::cerr &lt;&lt; "Shader program failed to link" &lt;&lt; std::endl;
      GLint  logSize;
      glGetProgramiv( program, GL_INFO_LOG_LENGTH, &amp;logSize);
      char* logMsg = new char[logSize];
      glGetProgramInfoLog( program, logSize, NULL, logMsg );
      std::cerr &lt;&lt; logMsg &lt;&lt; std::endl;
      delete [] logMsg;
  
      exit( EXIT_FAILURE );
      }
  
      /* use program object */
      glUseProgram(program);
  
      return program;
  }
  
  }  // Close namespace Angel block
  
  #endif // __ANGEL_H__
  </code></pre>
  
  <p>I compile it using the following commands</p>
  
  <pre class="lang-c prettyprint-override"><code>g++ Sierpinski.cpp -I. -lGL -lglut -lGLU -lGLEW -g -o Sierpinski.out
  </code></pre>
  
  <p>When I run it, the follows appears:</p>
  
  <pre class="lang-c prettyprint-override"><code>[asdrubal@localhost tests]$ ./Sierpinski.out 
  libGL error: failed to load driver: i965
  libGL error: Try again with LIBGL_DEBUG=verbose for more details.
  libGL error: failed to load driver: swrast
  libGL error: Try again with LIBGL_DEBUG=verbose for more details.
  X Error of failed request:  GLXBadFBConfig
    Major opcode of failed request:  154 (GLX)
    Minor opcode of failed request:  34 ()
    Serial number of failed request:  39
    Current serial number in output stream:  38
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>P.S.: I'm using right now</p>
  
  <pre class="lang-c prettyprint-override"><code>3.6.9-1-ARCH (Arch Linux)
  </code></pre>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p><strong>Shaders</strong></p>
  
  <p>Sierpinski.fragment.glsl </p>
  
  <pre class="lang-c prettyprint-override"><code>void main()
  {
      gl_FragColor = vec4(0.0,1.0,0.0,1.0);
  }
  </code></pre>
  
  <p>Sierpinski.vertex.glsl</p>
  
  <pre class="lang-c prettyprint-override"><code>#version 120
  attribute vec4 vPosition; /*Si se quieren setear variables*/
  void main()
  {
  
    gl_Position = vPosition;
  
  }
  </code></pre>
  
  <p>Output with LIBGL_DEBUG=verbose</p>
  
  <pre class="lang-c prettyprint-override"><code>[asdrubal@localhost tests]$ ./Sierpinski.out 
  libGL: OpenDriver: trying /usr/lib32/dri/tls/i965_dri.so
  libGL: OpenDriver: trying /usr/lib32/dri/i965_dri.so
  libGL error: dlopen /usr/lib32/dri/i965_dri.so failed (/usr/lib32/dri/i965_dri.so: cannot open shared object file: No such file or directory)
  libGL error: unable to load driver: i965_dri.so
  libGL error: driver pointer missing
  libGL error: failed to load driver: i965
  libGL: OpenDriver: trying /usr/lib32/dri/tls/swrast_dri.so
  libGL: OpenDriver: trying /usr/lib32/dri/swrast_dri.so
  libGL error: dlopen /usr/lib32/dri/swrast_dri.so failed (/usr/lib32/dri/swrast_dri.so: cannot open shared object file: No such file or directory)
  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:  39
    Current serial number in output stream:  38
  </code></pre>
  
  <p>EDIT 2:</p>
  
  <p>Command:</p>
  
  <pre class="lang-c prettyprint-override"><code>lspci | grep VGA
  </code></pre>
  
  <p>Returns </p>
  
  <pre class="lang-c prettyprint-override"><code>00:02.0 VGA compatible controller: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller (primary) (rev 03)
  </code></pre>