0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / OpenGl / OpenGl_ShaderManager.cxx
index 257843c..d94768d 100644 (file)
@@ -83,7 +83,7 @@ const char THE_FUNC_pointLight[] =
   EOL"  vec3 aLight = occLight_Position (theId).xyz;"
   EOL"  if (occLight_IsHeadlight (theId) == 0)"
   EOL"  {"
-  EOL"    aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 1.0));"
+  EOL"    aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 1.0));"
   EOL"  }"
   EOL"  aLight -= thePoint;"
   EOL
@@ -121,8 +121,8 @@ const char THE_FUNC_spotLight[] =
   EOL"  vec3 aSpotDir = occLight_SpotDirection (theId).xyz;"
   EOL"  if (occLight_IsHeadlight (theId) == 0)"
   EOL"  {"
-  EOL"    aLight   = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight,   1.0));"
-  EOL"    aSpotDir = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aSpotDir, 0.0));"
+  EOL"    aLight   = vec3 (occWorldViewMatrix * vec4 (aLight,   1.0));"
+  EOL"    aSpotDir = vec3 (occWorldViewMatrix * vec4 (aSpotDir, 0.0));"
   EOL"  }"
   EOL"  aLight -= thePoint;"
   EOL
@@ -171,7 +171,7 @@ const char THE_FUNC_directionalLight[] =
   EOL"  vec3 aLight = normalize (occLight_Position (theId).xyz);"
   EOL"  if (occLight_IsHeadlight (theId) == 0)"
   EOL"  {"
-  EOL"    aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 0.0));"
+  EOL"    aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 0.0));"
   EOL"  }"
   EOL
   EOL"  vec3 aHalf = normalize (aLight + theView);"
@@ -200,7 +200,7 @@ const char THE_FUNC_directionalLightFirst[] =
   EOL"  vec3 aLight = normalize (occLightSources[1].xyz);"
   EOL"  if (occLight_IsHeadlight (0) == 0)"
   EOL"  {"
-  EOL"    aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 0.0));"
+  EOL"    aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 0.0));"
   EOL"  }"
   EOL
   EOL"  vec3 aHalf = normalize (aLight + theView);"
@@ -767,30 +767,21 @@ void OpenGl_ShaderManager::PushClippingState (const Handle(OpenGl_ShaderProgram)
     return;
   }
 
-  GLint aPlanesNb = 0;
-  for (Graphic3d_SequenceOfHClipPlane::Iterator anIter (myContext->Clipping().Planes());
-       anIter.More(); anIter.Next())
-  {
-    const Handle(Graphic3d_ClipPlane)& aPlane = anIter.Value();
-    if (!myContext->Clipping().IsEnabled (aPlane))
-    {
-      continue;
-    }
-
-    ++aPlanesNb;
-  }
-  if (aPlanesNb < 1)
+  const GLint aNbPlanes = Min (myContext->Clipping().NbClippingOrCappingOn(), THE_MAX_CLIP_PLANES);
+  theProgram->SetUniform (myContext,
+                          theProgram->GetStateLocation (OpenGl_OCC_CLIP_PLANE_COUNT),
+                          aNbPlanes);
+  if (aNbPlanes < 1)
   {
     return;
   }
 
   OpenGl_Vec4 anEquations[THE_MAX_CLIP_PLANES];
   GLuint aPlaneId = 0;
-  for (Graphic3d_SequenceOfHClipPlane::Iterator anIter (myContext->Clipping().Planes());
-       anIter.More(); anIter.Next())
+  for (OpenGl_ClippingIterator aPlaneIter (myContext->Clipping()); aPlaneIter.More(); aPlaneIter.Next())
   {
-    const Handle(Graphic3d_ClipPlane)& aPlane = anIter.Value();
-    if (!myContext->Clipping().IsEnabled (aPlane))
+    const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIter.Value();
+    if (aPlaneIter.IsDisabled())
     {
       continue;
     }
@@ -810,9 +801,6 @@ void OpenGl_ShaderManager::PushClippingState (const Handle(OpenGl_ShaderProgram)
     ++aPlaneId;
   }
 
-  theProgram->SetUniform (myContext,
-                          theProgram->GetStateLocation (OpenGl_OCC_CLIP_PLANE_COUNT),
-                          aPlanesNb);
   theProgram->SetUniform (myContext, aLocEquations, THE_MAX_CLIP_PLANES, anEquations);
 }
 
@@ -913,6 +901,11 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFboBlit()
   {
     aProgramSrc->SetHeader ("#version 300 es");
   }
+  else if (myContext->extFragDepth)
+  {
+    aProgramSrc->SetHeader ("#extension GL_EXT_frag_depth : enable"
+                         EOL"#define gl_FragDepth gl_FragDepthEXT");
+  }
   else
   {
     // there is no way to draw into depth buffer
@@ -1586,8 +1579,8 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramStereo (Handle(OpenGl_Sh
           EOL"uniform mat4 uMultL;"
           EOL"uniform mat4 uMultR;"
           EOL
-          EOL"vec4 THE_POW_UP   = vec4 (2.2, 2.2, 2.2, 1.0);"
-          EOL"vec4 THE_POW_DOWN = 1.0 / THE_POW_UP;"
+          EOL"const vec4 THE_POW_UP   =       vec4 (2.2, 2.2, 2.2, 1.0);"
+          EOL"const vec4 THE_POW_DOWN = 1.0 / vec4 (2.2, 2.2, 2.2, 1.0);"
           EOL
           EOL"THE_SHADER_IN vec2 TexCoord;"
           EOL