-1

I'm new to OpenGL and started studying using Anton's OpenGL tutorials. I finished the "Hello Triangle" tutorial and compiled it without errors with the following g++ command:

g++ -o hello_triangle main.c -lGLEW -lglfw -lGL -lX11 -lXxf86vm -lXrandr -lpthread -lXi -lm

However, the system window shows only a black screen, both in my code and in the code from the book repository.

The output from glGetString(GL_RENDERER) and glGetString(GL_VERSION) is the following:

Renderer: Mesa DRI Intel(R) Sandybridge Mobile  
OpenGL version supported 3.0 Mesa 11.0.6

What might be the reason of this black screen?

If you want to check the code just look at the '00_hello_triangle' code.

chicao
  • 86
  • 10
  • 1
    checkout vertex & fragment shader, you will find the code use `#version 410` which is not supported by your GL. try replacing it with `#version 130` – Gnimuc Dec 03 '15 at 14:20

1 Answers1

0

As @gnimuc-key suggested, when I changed the version in the shaders code, both vertex and fragment shader, it worked:

const char* vertex_shader =
    "#version 130\n"
    "in vec3 vp;"
    "void main () {"
    " gl_Position = vec4 (vp, 1.0);"
    "}"; 

const char* fragment_shader =
    "#version 130\n"
    "out vec4 frag_colour;"
    "void main () {"
    " frag_colour = vec4 (0.5, 0.0, 0.5, 1.0);"
    "}"; 

I changed "#version 150" to "#version 130" and worked properly

chicao
  • 86
  • 10