title: can't migrate from visual studio to linux with c++ and opengl
body: <p>I'm having classes of computer graphics on OpenGL. There we study and work with Visual Studio 2015 while I run Linux on my laptop. So there some differences between composing a program in our classes and in lessons I found on Wikibooks. I tried to run one tutorial code from there and everything was fine, while I couldn't run my code I wrote at my lesson. </p>
  
  <p>So I tried manipulating with my and tutorial code. I succeeded a few. The program runs but not shows my figures. So it actually must show a chesstable. But, for my regret, it shows a background color only. What may be wrong with that? </p>
  
  <p>The first part on <code>onDisplay()</code> is not displayed. The commented part is from tutorial which works and shows a triangle. </p>
  
  <p>Full code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  /* Use glew.h instead of gl.h to get all the GL prototypes declared */
  #include &lt;GL/glew.h&gt;
  /* Using the GLUT library for the base windowing setup */
  #include &lt;GL/freeglut.h&gt;
  
  GLuint program;
  GLint attribute_coord2d;
  
  int init_resources()
  {
      GLint compile_ok = GL_FALSE, link_ok = GL_FALSE;
  
      GLuint vs = glCreateShader( GL_VERTEX_SHADER );
      const char *vs_source =
      #ifdef GL_ES_VERSION_2_0
          "#version 100\n"  // OpenGL ES 2.0
      #else
          "#version 120\n"  // OpenGL 2.1
      #endif
          "attribute vec2 coord2d;                  "
          "void main(void) {                        "
          "  gl_Position = vec4(coord2d, 0.0, 1.0); "
          "}";
      glShaderSource( vs, 1, &amp;vs_source, NULL );
      glCompileShader( vs );
      glGetShaderiv( vs, GL_COMPILE_STATUS, &amp;compile_ok );
      if( !compile_ok )
      {
          fprintf( stderr, "Error in vertex shader\n" );
          return 0;
      }
  
      GLuint fs = glCreateShader( GL_FRAGMENT_SHADER );
      const char *fs_source =
      #ifdef GL_ES_VERSION_2_0
          "#version 100\n"  // OpenGL ES 2.0
      #else
          "#version 120\n"  // OpenGL 2.1
      #endif
          "void main(void) {        "
          "  gl_FragColor[0] = 0.0; "
          "  gl_FragColor[1] = 0.0; "
          "  gl_FragColor[2] = 1.0; "
          "}";
      glShaderSource( fs, 1, &amp;fs_source, NULL );
      glCompileShader( fs );
      glGetShaderiv( fs, GL_COMPILE_STATUS, &amp;compile_ok );
      if( !compile_ok )
      {
          fprintf( stderr, "Error in fragment shader\n" );
          return 0;
      }
  
      program = glCreateProgram();
      glAttachShader( program, vs );
      glAttachShader( program, fs );
      glLinkProgram( program );
      glGetProgramiv( program, GL_LINK_STATUS, &amp;link_ok );
      if( !link_ok )
      {
          fprintf( stderr, "glLinkProgram:" );
          return 0;
      }
  
      const char* attribute_name = "coord2d";
      attribute_coord2d = glGetAttribLocation( program, attribute_name );
      if( attribute_coord2d == -1 )
      {
          fprintf( stderr, "Could not bind attribute %s\n", attribute_name );
          return 0;
      }
  
      return 1;
  }
  
  void chess( double x, double y, double w, double h, int k )
  {
      glColor3f( 0.6, 0.6, 0.6 );
      glRecti( 20, 20, 480, 480 );
  
      for( int i = 0; i &lt; 8; i++ )
      {
          glRasterPos2i( ( i + 1 )*x + 20, 30 );
          glutBitmapCharacter( GLUT_BITMAP_9_BY_15, 'A' + i );
      }
  
      for( int j = 0; j &lt; 8; j++ )
      {
          for( int i = 0; i &lt; 8; i++ )
          {
              if( k % 2 == 0 )
              {
                  glColor3f( 1, 1, 1 );
              }
              else glColor3f( 0, 0, 0 );
              glRecti( x + w*i, y + h*j, 2 * x + w*i, 2 * y + h*j );
              k++;
          }
          k++;
      }
  }
  
  void onDisplay()
  {
      glClearColor( 0.5, 1.0, 1.0, 1.0 );
      glClear( GL_COLOR_BUFFER_BIT );
  
      glUseProgram( program );
      glEnableVertexAttribArray( attribute_coord2d );
      double x, y, w, h;
      int k;
      x = 50;
      y = 50;
      h = 50;
      w = 50;
      k = 1;
      chess( x, y, w, h, k );
      glFlush();
      /*
      GLfloat triangle_vertices[] = {
      0.0,  0.8,
      -0.8, -0.8,
      0.8, -0.8,
      };
      // Describe our vertices array to OpenGL (it can't guess its format automatically)
      glVertexAttribPointer(
      attribute_coord2d, // attribute
      2,                 // number of elements per vertex, here (x,y)
      GL_FLOAT,          // the type of each element
      GL_FALSE,          // take our values as-is
      0,                 // no extra data between each position
      triangle_vertices  // pointer to the C array
      );
  
      // Push each element in buffer_vertices to the vertex shader
  
      glDrawArrays(GL_TRIANGLES, 0, 3);
      */
      glDisableVertexAttribArray( attribute_coord2d );
      glutSwapBuffers();
  }
  
  void free_resources()
  {
      glDeleteProgram( program );
  }
  
  
  int main( int argc, char* argv[] )
  {
      glutInit( &amp;argc, argv );
      glutInitContextVersion( 2, 0 );
      glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
      glutInitWindowSize( 640, 640 );
      glutCreateWindow( "chesstable" );
  
      GLenum glew_status = glewInit();
      if( glew_status != GLEW_OK )
      {
          fprintf( stderr, "Error: %s\n", glewGetErrorString( glew_status ) );
          return 1;
      }
  
      if( init_resources() )
      {
          glutDisplayFunc( onDisplay );
          glutMainLoop();
      }
  
      free_resources();
      return 0;
  }
  </code></pre>