Search code examples
openglglfwglewfedora-25

opengl on Linux : unable to use a correct version


I tried to build a program using glfw + glew on Fedora 25. part of it is:

int main()
{
    glfwInit();
    glfwWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_ANY_PROFILE);
    //glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,3);
    //glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR,3);
    mainWindow = glfwCreateWindow(1024,768,"NONE",nullptr,nullptr);
    if(mainWindow == nullptr)
    {
        std::cout<<"Creating window ERROR.\n"<<std::endl;
        glfwTerminate();
        return 1;
    }
    .....
}

If I use glfwWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_CORE_PROFILE); to get the version 3.3, it'll be unable to create window though.

My hardware supports openGL 4.1.

upd: got the answer....


Solution

  • Just uncomment glfwWindowHint(GLFW_CONTEXT_VERSION_*,*) there.
    While using core profile with glfwWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_CORE_PROFILE),
    the explicit version needs to be requested.

    Thanks to the comment of Dietrich Epp.

    By the way, can anyone tell me how to get such information?