You're choosing the OpenGL Core Profile for your rendering:
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
Your code is missing a number of things to be Core Profile compliant:
- You need to implement shader programs. The Core Profile does not support the old fixed pipeline anymore, and requires you to implement your own shaders in GLSL. Explaining how to do this in detail is beyond the scope of an answer, but you will be using calls like
glCreateProgram
, glCreateShader
, glShaderSource
, glCompileShader
, glAttachShader
, glLinkProgram
. You should be able to find material online and in books.
- You need to use Vertex Array Objects (VAO). Look up
glGenVertexArrays
and glBindVertexArray
.