hburd wrote on Tuesday, August 06, 2013:
Hi,
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:
#define GL3_PROTOTYPES 1
#define GLFW_INCLUDE_GL3
#include <GLFW/glfw.h>
...
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(...
glfwMakeContextCurrent(window);
float vertices[] = ...
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glEnableVertexAttribArray(0);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(0);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
...
glfwPollEvents();
glfwSwapBuffers(window);
glClear(GL_COLOR_BUFER_BIT);
...
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.
Thanks.