0024381: Visualization, TKOpenGl - revise matrices stack and usage of temporary matrices
[occt.git] / src / OpenGl / OpenGl_Context.cxx
index 786fcde..247c189 100644 (file)
   #include <GL/glx.h> // glXGetProcAddress()
 #endif
 
-// GL_NVX_gpu_memory_info
-#ifndef GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
-  enum
-  {
-    GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX         = 0x9047,
-    GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX   = 0x9048,
-    GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX = 0x9049,
-    GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX           = 0x904A,
-    GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX           = 0x904B
-  };
-#endif
-
 IMPLEMENT_STANDARD_HANDLE (OpenGl_Context, Standard_Transient)
 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Context, Standard_Transient)
 
@@ -527,7 +515,7 @@ Standard_Boolean OpenGl_Context::CheckExtension (const char* theExtName) const
 {
   if (theExtName  == NULL)
   {
-#ifdef OPENGL_DEB
+#ifdef OCCT_DEBUG
     std::cerr << "CheckExtension called with NULL string!\n";
 #endif
     return Standard_False;
@@ -1022,7 +1010,7 @@ void OpenGl_Context::init()
     {
       // setup default callback
       arbDbg->glDebugMessageCallbackARB (debugCallbackWrap, this);
-    #ifdef DEB
+    #ifdef OCCT_DEBUG
       glEnable (GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
     #endif
     }
@@ -2225,3 +2213,85 @@ Standard_Boolean OpenGl_Context::SetGlNormalizeEnabled (Standard_Boolean isEnabl
 
   return anOldGlNormalize;
 }
+
+// =======================================================================
+// function : ApplyModelWorldMatrix
+// purpose  :
+// =======================================================================
+void OpenGl_Context::ApplyModelWorldMatrix()
+{
+#if !defined(GL_ES_VERSION_2_0)
+  if (core11 != NULL)
+  {
+    core11->glMatrixMode (GL_MODELVIEW);
+    core11->glLoadMatrixf (ModelWorldState.Current());
+  }
+#endif
+
+  if (!myShaderManager->IsEmpty())
+  {
+    myShaderManager->UpdateModelWorldStateTo (ModelWorldState.Current());
+  }
+}
+
+// =======================================================================
+// function : ApplyWorldViewMatrix
+// purpose  :
+// =======================================================================
+void OpenGl_Context::ApplyWorldViewMatrix()
+{
+#if !defined(GL_ES_VERSION_2_0)
+  if (core11 != NULL)
+  {
+    core11->glMatrixMode (GL_MODELVIEW);
+    core11->glLoadMatrixf (WorldViewState.Current());
+  }
+#endif
+
+  if (!myShaderManager->IsEmpty())
+  {
+    myShaderManager->UpdateWorldViewStateTo (WorldViewState.Current());
+  }
+}
+
+// =======================================================================
+// function : ApplyModelViewMatrix
+// purpose  :
+// =======================================================================
+void OpenGl_Context::ApplyModelViewMatrix()
+{
+#if !defined(GL_ES_VERSION_2_0)
+  if (core11 != NULL)
+  {
+    OpenGl_Mat4 aModelView = WorldViewState.Current() * ModelWorldState.Current();
+    core11->glMatrixMode (GL_MODELVIEW);
+    core11->glLoadMatrixf (aModelView.GetData());
+  }
+#endif
+
+  if (!myShaderManager->IsEmpty())
+  {
+    myShaderManager->UpdateModelWorldStateTo (ModelWorldState.Current());
+    myShaderManager->UpdateWorldViewStateTo (WorldViewState.Current());
+  }
+}
+
+// =======================================================================
+// function : ApplyProjectionMatrix
+// purpose  :
+// =======================================================================
+void OpenGl_Context::ApplyProjectionMatrix()
+{
+#if !defined(GL_ES_VERSION_2_0)
+  if (core11 != NULL)
+  {
+    core11->glMatrixMode (GL_PROJECTION);
+    core11->glLoadMatrixf (ProjectionState.Current().GetData());
+  }
+#endif
+
+  if (!myShaderManager->IsEmpty())
+  {
+    myShaderManager->UpdateProjectionStateTo (ProjectionState.Current());
+  }
+}