0025556: Visualization - support stereo pair formats recognized by consumer display...
[occt.git] / src / OpenGl / OpenGl_ShaderManager.hxx
index 7573314..88f1f9c 100644 (file)
@@ -17,6 +17,7 @@
 #define _OpenGl_ShaderManager_HeaderFile
 
 #include <Graphic3d_ShaderProgram.hxx>
+#include <Graphic3d_StereoMode.hxx>
 
 #include <NCollection_DataMap.hxx>
 #include <NCollection_Sequence.hxx>
@@ -161,15 +162,21 @@ public:
          && myContext->BindProgram (myBlitProgram);
   }
 
-  //! Bind program for rendering Anaglyph image.
-  Standard_Boolean BindAnaglyphProgram()
+  //! Bind program for rendering stereoscopic image.
+  Standard_Boolean BindStereoProgram (const Graphic3d_StereoMode theStereoMode)
   {
-    if (myAnaglyphProgram.IsNull())
+    if (theStereoMode < 0 || theStereoMode >= Graphic3d_StereoMode_NB)
     {
-      prepareStdProgramAnaglyph();
+      return Standard_False;
     }
-    return !myAnaglyphProgram.IsNull()
-         && myContext->BindProgram (myAnaglyphProgram);
+
+    if (myStereoPrograms[theStereoMode].IsNull())
+    {
+      prepareStdProgramStereo (myStereoPrograms[theStereoMode], theStereoMode);
+    }
+    const Handle(OpenGl_ShaderProgram)& aProgram = myStereoPrograms[theStereoMode];
+    return !aProgram.IsNull()
+         && myContext->BindProgram (aProgram);
   }
 
 public:
@@ -370,8 +377,9 @@ protected:
   //! Set pointer myLightPrograms to active lighting programs set from myMapOfLightPrograms
   Standard_EXPORT void switchLightPrograms();
 
-  //! Prepare standard GLSL program for Anaglyph image.
-  Standard_EXPORT Standard_Boolean prepareStdProgramAnaglyph();
+  //! Prepare standard GLSL program for stereoscopic image.
+  Standard_EXPORT Standard_Boolean prepareStdProgramStereo (Handle(OpenGl_ShaderProgram)& theProgram,
+                                                            const Graphic3d_StereoMode    theStereoMode);
 
 protected:
 
@@ -383,7 +391,7 @@ protected:
   Handle(OpenGl_ShaderProgram)       myBlitProgram;        //!< standard program for FBO blit emulation
   OpenGl_MapOfShaderPrograms         myMapOfLightPrograms; //!< map of lighting programs depending on shading model and lights configuration
 
-  Handle(OpenGl_ShaderProgram)       myAnaglyphProgram;    //!< standard program for Anaglyph image
+  Handle(OpenGl_ShaderProgram)       myStereoPrograms[Graphic3d_StereoMode_NB]; //!< standard stereo programs
 
   OpenGl_Context*                    myContext;            //!< OpenGL context