Search code examples
c++openglglutsfmlstereo-3d

activate quad buffered stereo with sfml or openGL


My program works perfectly fine in a normal 3D with one buffer, it is coded with SFML window management. I would like to add quad buffered stereo, therefore i changed my drawing code to the following :

        glDrawBuffer(GL_BACK_LEFT);
    camera->OnMouseMotion(sf::Vector2i(-1,0));
    for (auto i = objects->cbegin(); i != objects->cend(); ++i)
        (*i)->draw(camera);
    glFlush();
    glDrawBuffer(GL_BACK_RIGHT);
    camera->OnMouseMotion(sf::Vector2i(2,0));
    for (auto i = objects->cbegin(); i != objects->cend(); ++i)
        (*i)->draw(camera);
    glFlush();
    camera->OnMouseMotion(sf::Vector2i(-1,0));

Notice that my camera changed are not perfectly right and i know i will have to change these, right now i am focusing on displaying an image just using quad buffered stereo. I noticed in all examples of programs using this stereo that they were initialising the window with something like this :

    type = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STEREO;
  glutInitDisplayMode(type);

Using SFML, such function isn't available, my questions are : Can i use a low-level openGL function to achieve the same result ? Can i use another window managing library with SFML ? Should i forget SFML for my program and completly change it to another one ?


Solution

  • SFML doesn't have an initialisation function, it creates openGL context automatically, two things you can do :

    • Modify SFML sources you are using, and try to add somewhere in the window creation function your parameter
    • change your display library to create the openGL context, however you may or not keep SFML 2D drawing functions, i am not sure these are gonna work if you create your context with glut for example.

    EDIT : after a small check, you cannot create a context with another library and still use SFML for drawing simple 2D forms, i am afraid you are forced to let SFML go.