Search code examples
openglinteloptimus

OpenGL glfwOpenWindow Doesn't work on Optimus video card


I have a Geforce GT 540M, my laptop uses Optimus so it will 'switch' between the Intel GPU and the Geforce GPU depending on the applications/settings etc.

As far as I can tell on the line to open a window, it returns false:

if( !glfwOpenWindow( 1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW ) )
{
    fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the     tutorials.\n" );
    system("pause");
    glfwTerminate();
    return -1;
}

The system command was just to confirm the error message I received.

Is there a way to force the compiler to recognize my graphics card? My assumption is that it can only spot my Intel gpu.


Solution

  • You're asking for 32 depth bits. That's a rather unusual format. Typical choices are 24 depth bits and 8 stencil bits in a combined 32 bit depth-stencil format. Also you can use glfwOpenWindowHint to request an OpenGL-3 context, which should give you a context on the NVidia GPU.

    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 0);
    
    err = glfwOpenWindow(...);
    /* ... */