glewInit() Failed, OpenGL App

You are using Core OpenGL version 3.3 so you must specify you are using "new" and by GLEW terms "experimental" API. Add this line before calling glewInit();

glewExperimental=GL_TRUE;

Here is a complete init code from my engine .It is for 4.2 but should work the same for you:

 void Engine::InitWithGLFW(){
    if(!glfwInit()){
        exit(EXIT_FAILURE);
    }
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 4);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
    //glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT,GL_TRUE);
    glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
    glfwOpenWindowHint(GLFW_FSAA_SAMPLES,4);
    glfwDisable(GLFW_AUTO_POLL_EVENTS);

 #ifdef DEBUG
    glfwOpenWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
 #endif

    if(!glfwOpenWindow(_width,_height,8, 8, 8, 8, 24, 8,GLFW_WINDOW)){
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    glfwSetWindowTitle("XDEngine V-1.0");
    InitGlew();
 }

 void Engine::InitGlew(){
    glewExperimental=GL_TRUE;
    GLenum err = glewInit(); 

    if (GLEW_OK != err)
    {
        /* Problem: glewInit failed, something is seriously wrong. */
        fprintf(stderr, "Error: %s\n", glewGetErrorString(err));

    }

    fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
    glEnable (GL_BLEND);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glEnable(GL_MULTISAMPLE);
    glEnable(GL_DEPTH_CLAMP);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);

    glfwSetWindowSizeCallback(Reshape);
 }

I know this answer comes a bit late, but I don't see you making the OpenGL context current by calling glfwMakeContextCurrent(window). You have to do that before calling glewInit()


If no error is returned from glewInit() it returns 0. For some reason the return wasn't comparing well to GLEW_OK but if the value is anything but 0, there's an error.

if(glewInit()) {

  //Handle Error

}

Tags:

Opengl

Glew