I'm roughly following this tutorial (it's in french, sorry) to learn the basics of modern OpenGL, except I'm adapting the tutorial to use GLFW instead of SDL.
The earlier parts of the tutorial were working fine, which only used basic OpenGL functions (glClear, glClearColor), but the functions glVertexAttribPointer, glEnableVertexAttribArray and glDisableVertexAttribArray are giving me implicit declaration of function warnings, and when I try to run the program it says There is no current context. Here's the relevent code:
implicit declaration of function
There is no current context
#define GL3_PROTOTYPES 1
GLFWwindow* window = glfwCreateWindow(...
float vertices = ...
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glDrawArrays(GL_TRIANGLES, 0, 3);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
Am I doing all the required steps to set up an OpenGL 3.1 context? What am I doing wrong?
I'm doing this on Ubuntu by the way.
You need to use GLEW or a similar library, like the tutorial does.
Thanks, using GLEW fixed it.
The tutorial actually said that GLEW wasn't needed for Linux, and just to include gl3.h, but I guess that's not right.
I think your problem is here:
Core profile is not supported on OGL 3.1 and requires OGL 3.2+. You can stick to a forward compatibility profile instead.