You are not switching the context with glfwMakeContextCurrent(window);
Here is an example of a full initialization of GLFW and GLEW :
//Init GLFW
if(!glfwInit())
{
std::cout << "ERROR" << std::endl;
return(-1);
}
//Give hints
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
glfwWindowHint(GLFW_VISIBLE, GL_TRUE);
glfwWindowHint(GLFW_DECORATED, GL_TRUE);
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
#if defined(__APPLE__)
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
int const DPI = 2; // For retina screens only
#else
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE);
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
int const DPI = 1;
# endif
// Create Wikndow
window = glfwCreateWindow(screenWidth, screenHeight, "DEMO", NULL, NULL );
if(window == 0)
{
std::cout << "ERROR" << std::endl;
glfwTerminate();
return(-1);
}
//Switch context to use on window
glfwMakeContextCurrent(window);
//Init glew
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK)
{
std::cout << "ERROR" << std::endl;
return(-1);
}