title: opengl program compiles but gives error when run (UBUNTU 14.04)
body: <p>I compiled Opengl by installing the folowing packages through Synaptics Package manager.</p>
  <pre><code>freeglut3 freeglut3-dev freeglut3-dbg libglew1.5 libglew1.5-dev libglu1-mesa libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev
  </code></pre>
  <p>This is the output when I run the program.</p>
  <blockquote>
  <p>X Error of failed request:  GLXBadFBConfig</p>
  <p>Major opcode of failed request:  156 (GLX)</p>
  <p>Minor opcode of failed request:  34 ()</p>
  <p>Serial number of failed request:  42</p>
  <p>Current serial number in output stream:  41</p>
  </blockquote>
  <hr />
  <p>The input to this</p>
  <pre><code>(lspci | grep VGA) ; \
  (dpkg -l | egrep 'xorg-video|glx') ; \
  (ls -l /usr/lib/xorg/modules/{drivers,extensions})
  </code></pre>
  <p>gives an output to this</p>
  <pre><code>01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Seymour [Radeon HD 6400M/7400M Series]
  ii  libgl1-mesa-glx:amd64                                 10.1.0-4ubuntu5                                     amd64        free implementation of the OpenGL API -- GLX runtime
  ii  libxcb-glx0:amd64                                     1.10-2ubuntu1                                       amd64        X C Binding, glx extension
  ii  libxcb-glx0-dev:amd64                                 1.10-2ubuntu1                                       amd64        X C Binding, glx extension, development files
  ii  xserver-xorg-video-all                                1:7.7+1ubuntu8                                      amd64        X.Org X server -- output driver metapackage
  ii  xserver-xorg-video-ati                                1:7.3.0-1ubuntu3.1                                  amd64        X.Org X server -- AMD/ATI display driver wrapper
  ii  xserver-xorg-video-cirrus                             1:1.5.2-1build1                                     amd64        X.Org X server -- Cirrus display driver
  ii  xserver-xorg-video-fbdev                              1:0.4.4-1build1                                     amd64        X.Org X server -- fbdev display driver
  ii  xserver-xorg-video-glamoregl                          0.6.0-0ubuntu4                                      amd64        X.Org X server -- graphics acceleration module based on OpenGL
  ii  xserver-xorg-video-intel                              2:2.99.910-0ubuntu1                                 amd64        X.Org X server -- Intel i8xx, i9xx display driver
  ii  xserver-xorg-video-mach64                             6.9.4-1build1                                       amd64        X.Org X server -- ATI Mach64 display driver
  ii  xserver-xorg-video-mga                                1:1.6.3-1build1                                     amd64        X.Org X server -- MGA display driver
  ii  xserver-xorg-video-modesetting                        0.8.1-1build1                                       amd64        X.Org X server -- Generic modesetting driver
  ii  xserver-xorg-video-neomagic                           1:1.2.8-1build1                                     amd64        X.Org X server -- Neomagic display driver
  ii  xserver-xorg-video-nouveau                            1:1.0.10-1ubuntu2                                   amd64        X.Org X server -- Nouveau display driver
  ii  xserver-xorg-video-openchrome                         1:0.3.3-1build1                                     amd64        X.Org X server -- VIA display driver
  ii  xserver-xorg-video-qxl                                0.1.1-0ubuntu3                                      amd64        X.Org X server -- QXL display driver
  ii  xserver-xorg-video-r128                               6.9.2-1build1                                       amd64        X.Org X server -- ATI r128 display driver
  ii  xserver-xorg-video-radeon                             1:7.3.0-1ubuntu3.1                                  amd64        X.Org X server -- AMD/ATI Radeon display driver
  ii  xserver-xorg-video-s3                                 1:0.6.5-0ubuntu4                                    amd64        X.Org X server -- legacy S3 display driver
  ii  xserver-xorg-video-savage                             1:2.3.7-2ubuntu2                                    amd64        X.Org X server -- Savage display driver
  ii  xserver-xorg-video-siliconmotion                      1:1.7.7-2build1                                     amd64        X.Org X server -- SiliconMotion display driver
  ii  xserver-xorg-video-sis                                1:0.10.7-0ubuntu6                                   amd64        X.Org X server -- SiS display driver
  ii  xserver-xorg-video-sisusb                             1:0.9.6-2build1                                     amd64        X.Org X server -- SiS USB display driver
  ii  xserver-xorg-video-tdfx                               1:1.4.5-1build1                                     amd64        X.Org X server -- tdfx display driver
  ii  xserver-xorg-video-trident                            1:1.3.6-0ubuntu5                                    amd64        X.Org X server -- Trident display driver
  ii  xserver-xorg-video-vesa                               1:2.3.3-1build1                                     amd64        X.Org X server -- VESA display driver
  ii  xserver-xorg-video-vmware                             1:13.0.2-2ubuntu1                                   amd64        X.Org X server -- VMware display driver
  /usr/lib/xorg/modules/drivers:
  total 4728
  -rw-r--r-- 1 root root   10408 مٓی     2 01:55 ati_drv.so
  -rw-r--r-- 1 root root   31704 فروري  5 15:32 cirrus_alpine.so
  -rw-r--r-- 1 root root   19352 فروري  5 15:32 cirrus_drv.so
  -rw-r--r-- 1 root root   27832 فروري  5 15:32 cirrus_laguna.so
  -rw-r--r-- 1 root root   23560 فروري  5 15:31 fbdev_drv.so
  -rw-r--r-- 1 root root 1460976 فروري 10 17:15 intel_drv.so
  -rw-r--r-- 1 root root  174648 فروري  5 15:33 mach64_drv.so
  -rw-r--r-- 1 root root  140656 فروري  5 15:36 mga_drv.so
  -rw-r--r-- 1 root root   44488 فروري  5 15:37 modesetting_drv.so
  -rw-r--r-- 1 root root   66544 فروري  5 15:36 neomagic_drv.so
  -rw-r--r-- 1 root root  207440 فروري  5 15:38 nouveau_drv.so
  -rw-r--r-- 1 root root  356336 فروري  5 15:41 openchrome_drv.so
  -rw-r--r-- 1 root root  172456 فروري  5 15:43 qxl_drv.so
  -rw-r--r-- 1 root root  108712 فروري  5 15:39 r128_drv.so
  -rw-r--r-- 1 root root  432616 مٓی     2 01:55 radeon_drv.so
  -rw-r--r-- 1 root root   57656 فروري  5 15:41 s3_drv.so
  -rw-r--r-- 1 root root  140848 فروري  5 15:43 savage_drv.so
  -rw-r--r-- 1 root root  112192 فروري  5 15:46 siliconmotion_drv.so
  -rw-r--r-- 1 root root  547064 اپريل  2 16:01 sis_drv.so
  -rw-r--r-- 1 root root   77144 فروري  5 15:45 sisusb_drv.so
  -rw-r--r-- 1 root root  189392 فروري  5 15:43 spiceqxl_drv.so
  -rw-r--r-- 1 root root   65936 فروري  5 15:45 tdfx_drv.so
  -rw-r--r-- 1 root root  142224 فروري  5 15:50 trident_drv.so
  -rw-r--r-- 1 root root   27624 فروري  5 15:52 vesa_drv.so
  -rw-r--r-- 1 root root  157720 اپريل 10 13:56 vmware_drv.so
  
  /usr/lib/xorg/modules/extensions:
  total 272
  -rw-r--r-- 1 root root 277832 اپريل 16 18:38 libglx.so
  </code></pre>
  <hr />
  <p>for this input</p>
  <pre><code>glxinfo
  </code></pre>
  <p>this is the output</p>
  <pre><code>name of display: :0
  display: :0  screen: 0
  direct rendering: Yes
  server glx vendor string: SGI
  server glx version string: 1.4
  server glx extensions:
      GLX_ARB_create_context, GLX_ARB_create_context_profile, 
      GLX_ARB_fbconfig_float, GLX_ARB_framebuffer_sRGB, GLX_ARB_multisample, 
      GLX_EXT_create_context_es2_profile, GLX_EXT_framebuffer_sRGB, 
      GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, 
      GLX_EXT_visual_rating, GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer, 
      GLX_OML_swap_method, GLX_SGIS_multisample, GLX_SGIX_fbconfig, 
      GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, GLX_SGI_swap_control
  client glx vendor string: Mesa Project and SGI
  client glx version string: 1.4
  client glx extensions:
      GLX_ARB_create_context, GLX_ARB_create_context_profile, 
      GLX_ARB_create_context_robustness, GLX_ARB_fbconfig_float, 
      GLX_ARB_framebuffer_sRGB, GLX_ARB_get_proc_address, GLX_ARB_multisample, 
      GLX_EXT_create_context_es2_profile, GLX_EXT_fbconfig_packed_float, 
      GLX_EXT_framebuffer_sRGB, GLX_EXT_import_context, 
      GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, GLX_EXT_visual_rating, 
      GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer, 
      GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer, 
      GLX_MESA_swap_control, GLX_OML_swap_method, GLX_OML_sync_control, 
      GLX_SGIS_multisample, GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, 
      GLX_SGIX_visual_select_group, GLX_SGI_make_current_read, 
      GLX_SGI_swap_control, GLX_SGI_video_sync
  GLX version: 1.4
  GLX extensions:
      GLX_ARB_create_context, GLX_ARB_create_context_profile, 
      GLX_ARB_fbconfig_float, GLX_ARB_framebuffer_sRGB, 
      GLX_ARB_get_proc_address, GLX_ARB_multisample, 
      GLX_EXT_create_context_es2_profile, GLX_EXT_framebuffer_sRGB, 
      GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, 
      GLX_EXT_visual_rating, GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer, 
      GLX_MESA_multithread_makecurrent, GLX_MESA_swap_control, 
      GLX_OML_swap_method, GLX_OML_sync_control, GLX_SGIS_multisample, 
      GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, 
      GLX_SGI_make_current_read, GLX_SGI_swap_control, GLX_SGI_video_sync
  OpenGL vendor string: X.Org
  OpenGL renderer string: Gallium 0.4 on AMD CAICOS
  OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.1.0
  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:
      GL_AMD_conservative_depth, GL_AMD_draw_buffers_blend, 
      GL_AMD_seamless_cubemap_per_texture, GL_AMD_shader_stencil_export, 
      GL_AMD_shader_trinary_minmax, GL_AMD_vertex_shader_layer, 
      GL_ANGLE_texture_compression_dxt3, GL_ANGLE_texture_compression_dxt5, 
      GL_ARB_ES2_compatibility, GL_ARB_base_instance, 
      GL_ARB_blend_func_extended, GL_ARB_clear_buffer_object, 
      GL_ARB_conservative_depth, GL_ARB_copy_buffer, GL_ARB_debug_output, 
      GL_ARB_depth_buffer_float, GL_ARB_depth_clamp, GL_ARB_draw_buffers, 
      GL_ARB_draw_buffers_blend, GL_ARB_draw_elements_base_vertex, 
      GL_ARB_draw_instanced, GL_ARB_explicit_attrib_location, 
      GL_ARB_fragment_coord_conventions, GL_ARB_fragment_shader, 
      GL_ARB_framebuffer_object, GL_ARB_framebuffer_sRGB, 
      GL_ARB_get_program_binary, GL_ARB_half_float_pixel, 
      GL_ARB_half_float_vertex, GL_ARB_instanced_arrays, 
      GL_ARB_internalformat_query, GL_ARB_invalidate_subdata, 
      GL_ARB_map_buffer_alignment, GL_ARB_map_buffer_range, 
      GL_ARB_occlusion_query2, GL_ARB_pixel_buffer_object, GL_ARB_point_sprite, 
      GL_ARB_provoking_vertex, GL_ARB_robustness, GL_ARB_sampler_objects, 
      GL_ARB_seamless_cube_map, GL_ARB_shader_bit_encoding, 
      GL_ARB_shader_objects, GL_ARB_shader_stencil_export, 
      GL_ARB_shader_texture_lod, GL_ARB_shading_language_420pack, 
      GL_ARB_shading_language_packing, GL_ARB_sync, 
      GL_ARB_texture_buffer_object, GL_ARB_texture_buffer_object_rgb32, 
      GL_ARB_texture_buffer_range, GL_ARB_texture_compression_rgtc, 
      GL_ARB_texture_cube_map_array, GL_ARB_texture_float, 
      GL_ARB_texture_mirror_clamp_to_edge, GL_ARB_texture_multisample, 
      GL_ARB_texture_non_power_of_two, GL_ARB_texture_rectangle, 
      GL_ARB_texture_rg, GL_ARB_texture_rgb10_a2ui, GL_ARB_texture_storage, 
      GL_ARB_texture_storage_multisample, GL_ARB_texture_swizzle, 
      GL_ARB_timer_query, GL_ARB_transform_feedback2, 
      GL_ARB_transform_feedback3, GL_ARB_transform_feedback_instanced, 
      GL_ARB_uniform_buffer_object, GL_ARB_vertex_array_bgra, 
      GL_ARB_vertex_array_object, GL_ARB_vertex_attrib_binding, 
      GL_ARB_vertex_shader, GL_ARB_vertex_type_10f_11f_11f_rev, 
      GL_ARB_vertex_type_2_10_10_10_rev, GL_ATI_blend_equation_separate, 
      GL_ATI_texture_compression_3dc, GL_ATI_texture_float, 
      GL_ATI_texture_mirror_once, GL_EXT_abgr, GL_EXT_blend_equation_separate, 
      GL_EXT_draw_buffers2, GL_EXT_draw_instanced, GL_EXT_framebuffer_blit, 
      GL_EXT_framebuffer_multisample, GL_EXT_framebuffer_multisample_blit_scaled, 
      GL_EXT_framebuffer_sRGB, GL_EXT_packed_depth_stencil, GL_EXT_packed_float, 
      GL_EXT_pixel_buffer_object, GL_EXT_provoking_vertex, GL_EXT_texture_array, 
      GL_EXT_texture_compression_dxt1, GL_EXT_texture_compression_latc, 
      GL_EXT_texture_compression_rgtc, GL_EXT_texture_compression_s3tc, 
      GL_EXT_texture_filter_anisotropic, GL_EXT_texture_integer, 
      GL_EXT_texture_mirror_clamp, GL_EXT_texture_sRGB, 
      GL_EXT_texture_sRGB_decode, GL_EXT_texture_shared_exponent, 
      GL_EXT_texture_snorm, GL_EXT_texture_swizzle, GL_EXT_timer_query, 
      GL_EXT_transform_feedback, GL_EXT_vertex_array_bgra, 
      GL_IBM_multimode_draw_arrays, GL_KHR_debug, GL_MESA_pack_invert, 
      GL_MESA_texture_signed_rgba, GL_NV_conditional_render, GL_NV_depth_clamp, 
      GL_NV_packed_depth_stencil, GL_NV_texture_barrier, GL_NV_vdpau_interop, 
      GL_OES_EGL_image, GL_OES_read_format, GL_S3_s3tc
  
  OpenGL version string: 3.0 Mesa 10.1.0
  OpenGL shading language version string: 1.30
  OpenGL context flags: (none)
  OpenGL extensions:
      GL_AMD_conservative_depth, GL_AMD_draw_buffers_blend, 
      GL_AMD_seamless_cubemap_per_texture, GL_AMD_shader_stencil_export, 
      GL_AMD_shader_trinary_minmax, GL_ANGLE_texture_compression_dxt3, 
      GL_ANGLE_texture_compression_dxt5, GL_APPLE_packed_pixels, 
      GL_APPLE_vertex_array_object, GL_ARB_ES2_compatibility, 
      GL_ARB_base_instance, GL_ARB_blend_func_extended, 
      GL_ARB_clear_buffer_object, GL_ARB_color_buffer_float, 
      GL_ARB_conservative_depth, GL_ARB_copy_buffer, GL_ARB_debug_output, 
      GL_ARB_depth_buffer_float, GL_ARB_depth_clamp, GL_ARB_depth_texture, 
      GL_ARB_draw_buffers, GL_ARB_draw_buffers_blend, 
      GL_ARB_draw_elements_base_vertex, GL_ARB_draw_instanced, 
      GL_ARB_explicit_attrib_location, GL_ARB_fragment_coord_conventions, 
      GL_ARB_fragment_program, GL_ARB_fragment_program_shadow, 
      GL_ARB_fragment_shader, GL_ARB_framebuffer_object, 
      GL_ARB_framebuffer_sRGB, GL_ARB_get_program_binary, 
      GL_ARB_half_float_pixel, GL_ARB_half_float_vertex, 
      GL_ARB_instanced_arrays, GL_ARB_internalformat_query, 
      GL_ARB_invalidate_subdata, GL_ARB_map_buffer_alignment, 
      GL_ARB_map_buffer_range, GL_ARB_multisample, GL_ARB_multitexture, 
      GL_ARB_occlusion_query, GL_ARB_occlusion_query2, 
      GL_ARB_pixel_buffer_object, GL_ARB_point_parameters, GL_ARB_point_sprite, 
      GL_ARB_provoking_vertex, GL_ARB_robustness, GL_ARB_sampler_objects, 
      GL_ARB_seamless_cube_map, GL_ARB_shader_bit_encoding, 
      GL_ARB_shader_objects, GL_ARB_shader_stencil_export, 
      GL_ARB_shader_texture_lod, GL_ARB_shading_language_100, 
      GL_ARB_shading_language_420pack, GL_ARB_shading_language_packing, 
      GL_ARB_shadow, GL_ARB_sync, GL_ARB_texture_border_clamp, 
      GL_ARB_texture_compression, GL_ARB_texture_compression_rgtc, 
      GL_ARB_texture_cube_map, GL_ARB_texture_cube_map_array, 
      GL_ARB_texture_env_add, GL_ARB_texture_env_combine, 
      GL_ARB_texture_env_crossbar, GL_ARB_texture_env_dot3, 
      GL_ARB_texture_float, GL_ARB_texture_mirror_clamp_to_edge, 
      GL_ARB_texture_mirrored_repeat, GL_ARB_texture_multisample, 
      GL_ARB_texture_non_power_of_two, GL_ARB_texture_rectangle, 
      GL_ARB_texture_rg, GL_ARB_texture_rgb10_a2ui, GL_ARB_texture_storage, 
      GL_ARB_texture_storage_multisample, GL_ARB_texture_swizzle, 
      GL_ARB_timer_query, GL_ARB_transform_feedback2, 
      GL_ARB_transform_feedback3, GL_ARB_transform_feedback_instanced, 
      GL_ARB_transpose_matrix, GL_ARB_uniform_buffer_object, 
      GL_ARB_vertex_array_bgra, GL_ARB_vertex_array_object, 
      GL_ARB_vertex_attrib_binding, GL_ARB_vertex_buffer_object, 
      GL_ARB_vertex_program, GL_ARB_vertex_shader, 
      GL_ARB_vertex_type_10f_11f_11f_rev, GL_ARB_vertex_type_2_10_10_10_rev, 
      GL_ARB_window_pos, GL_ATI_blend_equation_separate, GL_ATI_draw_buffers, 
      GL_ATI_separate_stencil, GL_ATI_texture_compression_3dc, 
      GL_ATI_texture_env_combine3, GL_ATI_texture_float, 
      GL_ATI_texture_mirror_once, GL_EXT_abgr, GL_EXT_bgra, GL_EXT_blend_color, 
      GL_EXT_blend_equation_separate, GL_EXT_blend_func_separate, 
      GL_EXT_blend_minmax, GL_EXT_blend_subtract, GL_EXT_compiled_vertex_array, 
      GL_EXT_copy_texture, GL_EXT_draw_buffers2, GL_EXT_draw_instanced, 
      GL_EXT_draw_range_elements, GL_EXT_fog_coord, GL_EXT_framebuffer_blit, 
      GL_EXT_framebuffer_multisample, GL_EXT_framebuffer_multisample_blit_scaled, 
      GL_EXT_framebuffer_object, GL_EXT_framebuffer_sRGB, 
      GL_EXT_gpu_program_parameters, GL_EXT_multi_draw_arrays, 
      GL_EXT_packed_depth_stencil, GL_EXT_packed_float, GL_EXT_packed_pixels, 
      GL_EXT_pixel_buffer_object, GL_EXT_point_parameters, 
      GL_EXT_polygon_offset, GL_EXT_provoking_vertex, GL_EXT_rescale_normal, 
      GL_EXT_secondary_color, GL_EXT_separate_specular_color, 
      GL_EXT_shadow_funcs, GL_EXT_stencil_two_side, GL_EXT_stencil_wrap, 
      GL_EXT_subtexture, GL_EXT_texture, GL_EXT_texture3D, 
      GL_EXT_texture_array, GL_EXT_texture_compression_dxt1, 
      GL_EXT_texture_compression_latc, GL_EXT_texture_compression_rgtc, 
      GL_EXT_texture_compression_s3tc, GL_EXT_texture_cube_map, 
      GL_EXT_texture_edge_clamp, GL_EXT_texture_env_add, 
      GL_EXT_texture_env_combine, GL_EXT_texture_env_dot3, 
      GL_EXT_texture_filter_anisotropic, GL_EXT_texture_integer, 
      GL_EXT_texture_lod_bias, GL_EXT_texture_mirror_clamp, 
      GL_EXT_texture_object, GL_EXT_texture_rectangle, GL_EXT_texture_sRGB, 
      GL_EXT_texture_sRGB_decode, GL_EXT_texture_shared_exponent, 
      GL_EXT_texture_snorm, GL_EXT_texture_swizzle, GL_EXT_timer_query, 
      GL_EXT_transform_feedback, GL_EXT_vertex_array, GL_EXT_vertex_array_bgra, 
      GL_IBM_multimode_draw_arrays, GL_IBM_rasterpos_clip, 
      GL_IBM_texture_mirrored_repeat, GL_INGR_blend_func_separate, GL_KHR_debug, 
      GL_MESA_pack_invert, GL_MESA_texture_signed_rgba, GL_MESA_window_pos, 
      GL_NV_blend_square, GL_NV_conditional_render, GL_NV_depth_clamp, 
      GL_NV_fog_distance, GL_NV_light_max_exponent, GL_NV_packed_depth_stencil, 
      GL_NV_primitive_restart, GL_NV_texgen_reflection, GL_NV_texture_barrier, 
      GL_NV_texture_env_combine4, GL_NV_texture_rectangle, GL_NV_vdpau_interop, 
      GL_OES_EGL_image, GL_OES_read_format, GL_S3_s3tc, 
      GL_SGIS_generate_mipmap, GL_SGIS_texture_border_clamp, 
      GL_SGIS_texture_edge_clamp, GL_SGIS_texture_lod, GL_SUN_multi_draw_arrays
  </code></pre>
  <p>I cut the rest off since the body limit is 30000 characters and output is over 70000</p>
  <hr />
  <p>Below is all the source code, and I compiled it by typing this in the terminal:</p>
  <pre><code>g++ triangles.cpp LoadShaders.cpp -o output -lGL -lglut -lGLU -lGLEW
  </code></pre>
  <p>triangles.cpp:</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  #include &quot;vgl.h&quot;
  #include &quot;LoadShaders.h&quot;
  
  enum VAO_IDs {Triangles, NumVAOs};
  enum Buffer_IDs {ArrayBuffer, NumBuffers};
  enum Attrib_IDs {vPosition = 0};
  
  GLuint VAOs[NumVAOs];
  GLuint Buffers[NumBuffers];
  
  const GLuint NumVertices = 6;
  
  //init
  
  void init(void)
  {
      glGenVertexArrays(NumVAOs, VAOs);
      glBindVertexArray(VAOs[Triangles]);
  
      GLfloat vertices[NumVertices][2] = {
          {-0.90, -0.90}, //Triangle 1
          { 0.85, -0.90}, 
          {-0.90,  0.85},
          {-0.90, -0.85}, //Triangle 2
          { 0.90,  0.90},
          {-0.85,  0.90}
      };
  
      glGenBuffers(NumBuffers, Buffers);
      glBindBuffer(GL_ARRAY_BUFFER, Buffers[ArrayBuffer]);
      glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
  
      ShaderInfo shaders[] = {
          {GL_VERTEX_SHADER, &quot;triangles.vert&quot;},
          {GL_FRAGMENT_SHADER, &quot;triagles.frag&quot;},
          {GL_NONE, NULL}
      };
  
      GLuint program = LoadShaders(shaders);
      glUseProgram(program);
  
      glVertexAttribPointer(vPosition, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
      glEnableVertexAttribArray(vPosition);
  }
  
  //display
  
  void display(void)
  {
      glClear(GL_COLOR_BUFFER_BIT);
  
      glBindVertexArray(VAOs[Triangles]);
      glDrawArrays(GL_TRIANGLES, 0, NumVertices);
  
      glFlush();
  }
  
  //main
  
  int main(int argc, char **argv)
  {
      glutInit(&amp;argc, argv);
      glutInitDisplayMode(GLUT_RGBA);
      glutInitWindowSize(512, 512);
      glutInitContextVersion(4, 3);
      glutInitContextProfile(GLUT_CORE_PROFILE);
      glutCreateWindow(argv[0]);
  
      if(glewInit()) {
          cerr &lt;&lt; &quot;Unable to initialize GLEW...exiting&quot; &lt;&lt; endl;
          exit(EXIT_FAILURE);
      }
  
      init();
  
      glutDisplayFunc(display);
  
      glutMainLoop();
  }
  </code></pre>
  <p>vgl.h:</p>
  <pre><code>#ifndef __VGL_H__
  #define __VGL_H__
  
  // #define USE_GL3W
  
  #ifdef USE_GL3W
  
  #include &lt;GL3/gl3.h&gt;
  #include &lt;GL3/gl3w.h&gt;
  
  #else
  
  #define GLEW_STATIC
  
  #include &lt;GL/glew.h&gt;
  
  #ifdef _MSC_VER
  #  ifdef _DEBUG
  #    if (_MSC_VER &gt;= 1600)
  #      pragma comment (lib, &quot;glew_static_vs2010_d.lib&quot;)
  #    else
  #      pragma comment (lib, &quot;glew_static_d.lib&quot;)
  #    endif
  #  else
  #    if (_MSC_VER &gt;= 1600)
  #      pragma comment (lib, &quot;glew_static_vs2010.lib&quot;)
  #    else
  #      pragma comment (lib, &quot;glew_static.lib&quot;)
  #    endif
  #  endif
  #endif
  
  #endif
  
  #define FREEGLUT_STATIC
  
  #include &lt;GL/freeglut.h&gt;
  
  #ifdef _MSC_VER
  #  ifdef _DEBUG
  #    if (_MSC_VER &gt;= 1600)
  #      pragma comment (lib, &quot;freeglut_static_vs2010_d.lib&quot;)
  #    else
  #      pragma comment (lib, &quot;freeglut_static_d.lib&quot;)
  #    endif
  #  else
  #    if (_MSC_VER &gt;= 1600)
  #      pragma comment (lib, &quot;freeglut_static_vs2010.lib&quot;)
  #    else
  #      pragma comment (lib, &quot;freeglut_static.lib&quot;)
  #    endif
  #  endif
  #endif
  
  #define BUFFER_OFFSET(x)  ((const void*) (x))
  
  #endif /* __VGL_H__ */
  </code></pre>
  <p>LoadShaders.h:</p>
  <pre><code>//////////////////////////////////////////////////////////////////////////////
  //
  //  --- LoadShaders.h ---
  //
  //////////////////////////////////////////////////////////////////////////////
  
  #ifndef __LOAD_SHADERS_H__
  #define __LOAD_SHADERS_H__
  
  #include &lt;GL/gl.h&gt;
  
  #ifdef __cplusplus
  extern &quot;C&quot; {
  #endif  // __cplusplus
  
  //----------------------------------------------------------------------------
  //
  //  LoadShaders() takes an array of ShaderFile structures, each of which
  //    contains the type of the shader, and a pointer a C-style character
  //    string (i.e., a NULL-terminated array of characters) containing the
  //    entire shader source.
  //
  //  The array of structures is terminated by a final Shader with the
  //    &quot;type&quot; field set to GL_NONE.
  //
  //  LoadShaders() returns the shader program value (as returned by
  //    glCreateProgram()) on success, or zero on failure. 
  //
  
  typedef struct {
      GLenum       type;
      const char*  filename;
      GLuint       shader;
  } ShaderInfo;
  
  GLuint LoadShaders( ShaderInfo* );
  
  //----------------------------------------------------------------------------
  
  #ifdef __cplusplus
  };
  #endif // __cplusplus
  
  #endif // __LOAD_SHADERS_H__
  </code></pre>
  <p>LoadShaders.cpp</p>
  <pre><code>//////////////////////////////////////////////////////////////////////////////
  //
  //  --- LoadShaders.cxx ---
  //
  //////////////////////////////////////////////////////////////////////////////
  
  #include &lt;cstdlib&gt;
  #include &lt;cstdio&gt;
  #include &lt;iostream&gt;
  
  #define GLEW_STATIC
  #include &lt;GL/glew.h&gt;
  #include &quot;LoadShaders.h&quot;
  
  #ifdef __cplusplus
  extern &quot;C&quot; {
  #endif // __cplusplus
  
  //----------------------------------------------------------------------------
  
  static const GLchar*
  ReadShader( const char* filename )
  {
  #ifdef WIN32
      FILE* infile;
      fopen_s( &amp;infile, filename, &quot;rb&quot; );
  #else
      FILE* infile = fopen( filename, &quot;rb&quot; );
  #endif // WIN32
  
      if ( !infile ) {
  #ifdef _DEBUG
          std::cerr &lt;&lt; &quot;Unable to open file '&quot; &lt;&lt; filename &lt;&lt; &quot;'&quot; &lt;&lt; std::endl;
  #endif /* DEBUG */
          return NULL;
      }
  
      fseek( infile, 0, SEEK_END );
      int len = ftell( infile );
      fseek( infile, 0, SEEK_SET );
  
      GLchar* source = new GLchar[len+1];
  
      fread( source, 1, len, infile );
      fclose( infile );
  
      source[len] = 0;
  
      return const_cast&lt;const GLchar*&gt;(source);
  }
  
  //----------------------------------------------------------------------------
  
  GLuint
  LoadShaders( ShaderInfo* shaders )
  {
      if ( shaders == NULL ) { return 0; }
  
      GLuint program = glCreateProgram();
  
      ShaderInfo* entry = shaders;
      while ( entry-&gt;type != GL_NONE ) {
          GLuint shader = glCreateShader( entry-&gt;type );
  
          entry-&gt;shader = shader;
  
          const GLchar* source = ReadShader( entry-&gt;filename );
          if ( source == NULL ) {
              for ( entry = shaders; entry-&gt;type != GL_NONE; ++entry ) {
                  glDeleteShader( entry-&gt;shader );
                  entry-&gt;shader = 0;
              }
  
              return 0;
          }
  
          glShaderSource( shader, 1, &amp;source, NULL );
          delete [] source;
  
          glCompileShader( shader );
  
          GLint compiled;
          glGetShaderiv( shader, GL_COMPILE_STATUS, &amp;compiled );
          if ( !compiled ) {
  #ifdef _DEBUG
              GLsizei len;
              glGetShaderiv( shader, GL_INFO_LOG_LENGTH, &amp;len );
  
              GLchar* log = new GLchar[len+1];
              glGetShaderInfoLog( shader, len, &amp;len, log );
              std::cerr &lt;&lt; &quot;Shader compilation failed: &quot; &lt;&lt; log &lt;&lt; std::endl;
              delete [] log;
  #endif /* DEBUG */
  
              return 0;
          }
  
          glAttachShader( program, shader );
          
          ++entry;
      }
  
  #ifdef GL_VERSION_4_1
      if ( GLEW_VERSION_4_1 ) {
          // glProgramParameteri( program, GL_PROGRAM_SEPARABLE, GL_TRUE );
      }
  #endif /* GL_VERSION_4_1 */
      
      glLinkProgram( program );
  
      GLint linked;
      glGetProgramiv( program, GL_LINK_STATUS, &amp;linked );
      if ( !linked ) {
  #ifdef _DEBUG
          GLsizei len;
          glGetProgramiv( program, GL_INFO_LOG_LENGTH, &amp;len );
  
          GLchar* log = new GLchar[len+1];
          glGetProgramInfoLog( program, len, &amp;len, log );
          std::cerr &lt;&lt; &quot;Shader linking failed: &quot; &lt;&lt; log &lt;&lt; std::endl;
          delete [] log;
  #endif /* DEBUG */
  
          for ( entry = shaders; entry-&gt;type != GL_NONE; ++entry ) {
              glDeleteShader( entry-&gt;shader );
              entry-&gt;shader = 0;
          }
          
          return 0;
      }
  
      return program;
  }
  
  //----------------------------------------------------------------------------
  #ifdef __cplusplus
  }
  #endif // __cplusplus
  </code></pre>