]> OCCT Git - occt.git/commitdiff
0032732: Visualization, TKOpenGl - do not include system headers within OpenGl_GlFunc...
authorkgv <kgv@opencascade.com>
Wed, 15 Dec 2021 13:47:25 +0000 (16:47 +0300)
committersmoskvin <smoskvin@opencascade.com>
Fri, 17 Dec 2021 14:43:29 +0000 (17:43 +0300)
dox/upgrade/upgrade.md
src/D3DHost/D3DHost_FrameBuffer.cxx
src/OpenGl/OpenGl_Caps.cxx
src/OpenGl/OpenGl_Context.cxx
src/OpenGl/OpenGl_Context_1.mm
src/OpenGl/OpenGl_GlFunctions.hxx
src/OpenGl/OpenGl_GlTypes.hxx
src/OpenGl/OpenGl_GraphicDriver.cxx
src/OpenGl/OpenGl_SceneGeometry.cxx
src/OpenGl/OpenGl_Window.cxx
src/OpenGl/OpenGl_Window_1.mm

index 40616dd49123503966695a6dc13f924aa0d88a21..5caa102205a9a83e76f63a2f368146b2f77fb455 100644 (file)
@@ -7,6 +7,8 @@ Upgrade from older OCCT versions  {#occt__upgrade}
 
 This document provides technical details on changes made in particular versions of OCCT. It can help to upgrade user applications based on previous versions of OCCT to newer ones.
 
+@ref upgrade_occt770 "SEEK TO THE LAST CHAPTER (UPGRADE TO 7.7.0)"
+
 @subsection upgrade_intro_precautions Precautions
 
 Back-up your code before the upgrade.
@@ -24,7 +26,6 @@ The automatic upgrade tool is provided as is, without warranty of any kind, and
 It is your responsibility to ensure that the changes you made in your code are correct. 
 When you upgrade the code by an automatic script, make sure to carefully review the introduced changes at each step before committing them.
 
-
 @section upgrade_65 Upgrade to OCCT 6.5.0
 
 Porting of user applications from an earlier OCCT version to version 6.5 requires taking into account the following major changes:
@@ -2321,3 +2322,10 @@ aValidateEdge.Process();
 `Prs3d_Drawer` getters no more implicitly create "default" aspects.
 If specific property has not been set before to this drawer instance nor to linked drawer instance, then NULL property will be returned.
 Make sure to set property beforehand or to call `SetOwn*` / `SetupOwn*` methods to derive from defaults.
+
+@subsection upgrade_occt770_opengl OpenGL functions
+
+Applications extending OCCT 3D Viewer and calling OpenGL functions directly (like @c @::glEnable(), e.g. using global namespace) might be affected by changes in `OpenGl_GlFunctions.hxx`.
+This header, as well as `OpenGl_GlCore20.hxx` and similar, no more include system OpenGL / OpenGL ES headers to define function table.
+Application code calling OpenGL functions directly should be changed to either use `OpenGl_Context::core11fwd` (as designed)
+or to include system OpenGL headers in advance (with help of `OpenGl_GlNative.hxx`).
index a077d9718ca67a494a533657a1d33d2b0f17a6a7..209f57b04d25a4b25d4ca1f23e41c979019ff2d8 100644 (file)
@@ -56,7 +56,6 @@ D3DHost_FrameBuffer::~D3DHost_FrameBuffer()
 // =======================================================================
 void D3DHost_FrameBuffer::Release (OpenGl_Context* theCtx)
 {
-#if !defined(GL_ES_VERSION_2_0)
   if (myGlD3dDevice != NULL)
   {
     const OpenGl_GlFunctions* aFuncs = (theCtx != NULL && theCtx->IsValid())
@@ -77,7 +76,6 @@ void D3DHost_FrameBuffer::Release (OpenGl_Context* theCtx)
     }
     myGlD3dDevice = NULL;
   }
-#endif
 
   if (myD3dSurf != NULL)
   {
@@ -146,7 +144,7 @@ Standard_Boolean D3DHost_FrameBuffer::InitD3dInterop (const Handle(OpenGl_Contex
                                                       const Standard_Integer        theDepthFormat)
 {
   Release (theCtx.operator->());
-#if !defined(GL_ES_VERSION_2_0)
+
   myDepthFormat = theDepthFormat;
   myVPSizeX = theSizeX;
   myVPSizeY = theSizeY;
@@ -207,14 +205,6 @@ Standard_Boolean D3DHost_FrameBuffer::InitD3dInterop (const Handle(OpenGl_Contex
 
   myD3dFallback = Standard_False;
   return Standard_True;
-#else
-  (void )theD3DDevice;
-  (void )theIsD3dEx;
-  (void )theSizeX;
-  (void )theSizeY;
-  (void )theDepthFormat;
-  return Standard_False;
-#endif
 }
 
 // =======================================================================
@@ -223,10 +213,6 @@ Standard_Boolean D3DHost_FrameBuffer::InitD3dInterop (const Handle(OpenGl_Contex
 // =======================================================================
 Standard_Boolean D3DHost_FrameBuffer::registerD3dBuffer (const Handle(OpenGl_Context)& theCtx)
 {
-#if defined(GL_ES_VERSION_2_0)
-  (void )theCtx;
-  return Standard_False;
-#else
   const OpenGl_GlFunctions* aFuncs = theCtx->Functions();
   if (myGlD3dSurf != NULL)
   {
@@ -264,7 +250,6 @@ Standard_Boolean D3DHost_FrameBuffer::registerD3dBuffer (const Handle(OpenGl_Con
   }
 
   return Standard_True;
-#endif
 }
 
 // =======================================================================
@@ -292,35 +277,15 @@ void D3DHost_FrameBuffer::BindBuffer (const Handle(OpenGl_Context)& theCtx)
   const OpenGl_TextureFormat aDepthFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, myDepthFormat);
   if (myDepthStencilTexture->IsValid())
   {
-  #ifdef GL_DEPTH_STENCIL_ATTACHMENT
     theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
                                             myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
-  #else
-    theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
-                                            myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
-    if (aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL)
-    {
-      theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
-                                              myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
-    }
-  #endif
   }
   if (theCtx->arbFBO->glCheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
   {
     if (myDepthStencilTexture->IsValid())
     {
-    #ifdef GL_DEPTH_STENCIL_ATTACHMENT
       theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
                                               myDepthStencilTexture->GetTarget(), 0, 0);
-    #else
-      theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
-                                              myDepthStencilTexture->GetTarget(), 0, 0);
-      if (aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL)
-      {
-        theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
-                                                myDepthStencilTexture->GetTarget(), 0, 0);
-      }
-    #endif
     }
     if (theCtx->arbFBO->glCheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
     {
@@ -353,16 +318,12 @@ void D3DHost_FrameBuffer::LockSurface (const Handle(OpenGl_Context)& theCtx)
     return;
   }
 
-#if !defined(GL_ES_VERSION_2_0)
   const OpenGl_GlFunctions* aFuncs = theCtx->Functions();
   if (!aFuncs->wglDXLockObjectsNV (myGlD3dDevice, 1, &myGlD3dSurf))
   {
     theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
                          "D3DHost_FrameBuffer::LockSurface(), lock failed!");
   }
-#else
-  (void )theCtx;
-#endif
 }
 
 // =======================================================================
@@ -416,8 +377,6 @@ void D3DHost_FrameBuffer::UnlockSurface (const Handle(OpenGl_Context)& theCtx)
     return;
   }
 
-#if !defined(GL_ES_VERSION_2_0)
   const OpenGl_GlFunctions* aFuncs = theCtx->Functions();
   aFuncs->wglDXUnlockObjectsNV (myGlD3dDevice, 1, &myGlD3dSurf);
-#endif
 }
index 28169e84b01e80031b24cbcbc8a116a8e0b79a7b..cc72994b89a8605f3df52747edb20b07b60b1849 100755 (executable)
@@ -15,8 +15,6 @@
 
 #include <OpenGl_Caps.hxx>
 
-#include <OpenGl_GlCore20.hxx>
-
 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Caps,Standard_Transient)
 
 // =======================================================================
@@ -40,11 +38,7 @@ OpenGl_Caps::OpenGl_Caps()
   contextDebug      (Standard_False),
   contextSyncDebug  (Standard_False),
   contextNoAccel    (Standard_False),
-#if !defined(GL_ES_VERSION_2_0)
   contextCompatible (Standard_True),
-#else
-  contextCompatible (Standard_False),
-#endif
   contextNoExtensions (Standard_False),
   contextMajorVersionUpper (-1),
   contextMinorVersionUpper (-1),
index fbb1caf34dce0bcaac457624063b843953a98f1f..dc38571ef1644ba0874dee906b74ad75666162d6 100644 (file)
@@ -2533,9 +2533,7 @@ void OpenGl_Context::SetPointSpriteOrigin()
   if (myPointSpriteOrig != aNewState)
   {
     myPointSpriteOrig = aNewState;
-  #if !defined(GL_ES_VERSION_2_0)
     core15fwd->glPointParameteri (GL_POINT_SPRITE_COORD_ORIGIN, aNewState);
-  #endif
   }
 }
 
index cd82bbf95546c73263787c327888f582c3a3148a..f55953d700ecd9ee075272092729fd3ef78ae61c 100644 (file)
@@ -90,11 +90,11 @@ void OpenGl_Context::SwapBuffers()
     return;
   }
 
-  ::glBindRenderbuffer (GL_RENDERBUFFER, myDefaultFbo->ColorRenderBuffer());
+  myFuncs->glBindRenderbuffer (GL_RENDERBUFFER, myDefaultFbo->ColorRenderBuffer());
   [myGContext presentRenderbuffer: GL_RENDERBUFFER];
   //::glBindRenderbuffer (GL_RENDERBUFFER, 0);
 #else
-  glFinish();
+  core11fwd->glFinish();
   [myGContext flushBuffer];
 #endif
 }
index 8b4e4a6badc5e7e955b3289886c818c2a8b7fd06..4308080845c6fd9df0758a1ffef0a77050c455b3 100644 (file)
@@ -16,8 +16,6 @@
 #ifndef OpenGl_GlFunctions_HeaderFile
 #define OpenGl_GlFunctions_HeaderFile
 
-#include <OpenGl_GlNative.hxx>
-
 #include <Standard_Macro.hxx>
 #include <Standard_TypeDef.hxx>
 
index 1de86a6131baf4a88feeadb791e188052bc291cf..165a3678480ba7d18aa64efb0d7be626d2bccbf2 100644 (file)
 #ifndef OpenGl_GlTypes_HeaderFile
 #define OpenGl_GlTypes_HeaderFile
 
+// required for correct APIENTRY definition
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
+  #define WIN32_LEAN_AND_MEAN
+  #include <windows.h>
+#endif
+
+#if defined(__APPLE__)
+  #import <TargetConditionals.h>
+#endif
+
+#ifndef APIENTRY
+  #define APIENTRY
+#endif
+#ifndef APIENTRYP
+  #define APIENTRYP APIENTRY *
+#endif
+#ifndef GLAPI
+  #define GLAPI extern
+#endif
+
+#ifndef GL_APICALL
+  #define GL_APICALL GLAPI
+#endif
+
+// exclude modern definitions and system-provided glext.h, should be defined before gl.h inclusion
+#ifndef GL_GLEXT_LEGACY
+  #define GL_GLEXT_LEGACY
+#endif
+#ifndef GLX_GLXEXT_LEGACY
+  #define GLX_GLXEXT_LEGACY
+#endif
+
 #include <OpenGl_khrplatform.h>
 
 typedef khronos_int8_t   GLbyte;
index 3535cda0edf405a353f6fc634e35a280aa354060..b39fd6c199d84c01aaaa126c8beb18cb014b6d11 100644 (file)
@@ -173,6 +173,9 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnectio
   myEglDisplay = (Aspect_Display )EGL_NO_DISPLAY;
   myEglContext = (Aspect_RenderingContext )EGL_NO_CONTEXT;
 #endif
+#if defined(OpenGl_USE_GLES2)
+  myCaps->contextCompatible = false;
+#endif
 
 #if defined(HAVE_XLIB)
   if (myDisplayConnection.IsNull())
index 070f6ae8aeec4d5ac081500c0764a8bca6102632..a09e4c09390bd2e5a268a30b6add102f60329597 100644 (file)
@@ -388,7 +388,6 @@ Standard_Boolean OpenGl_RaytraceGeometry::AcquireTextures (const Handle(OpenGl_C
     return Standard_True;
   }
 
-#if !defined(GL_ES_VERSION_2_0)
   Standard_Integer aTexIter = 0;
   for (NCollection_Vector<Handle(OpenGl_Texture)>::Iterator aTexSrcIter (myTextures); aTexSrcIter.More(); aTexSrcIter.Next(), ++aTexIter)
   {
@@ -425,7 +424,6 @@ Standard_Boolean OpenGl_RaytraceGeometry::AcquireTextures (const Handle(OpenGl_C
       return Standard_False;
     }
   }
-#endif
 
   return Standard_True;
 }
@@ -441,7 +439,6 @@ Standard_Boolean OpenGl_RaytraceGeometry::ReleaseTextures (const Handle(OpenGl_C
     return Standard_True;
   }
 
-#if !defined(GL_ES_VERSION_2_0)
   for (size_t aTexIter = 0; aTexIter < myTextureHandles.size(); ++aTexIter)
   {
     theContext->arbTexBindless->glMakeTextureHandleNonResidentARB (myTextureHandles[aTexIter]);
@@ -453,7 +450,6 @@ Standard_Boolean OpenGl_RaytraceGeometry::ReleaseTextures (const Handle(OpenGl_C
       return Standard_False;
     }
   }
-#endif
 
   return Standard_True;
 }
@@ -499,7 +495,6 @@ Standard_Boolean OpenGl_RaytraceGeometry::UpdateTextureHandles (const Handle(Ope
   myTextureHandles.clear();
   myTextureHandles.resize (myTextures.Size());
 
-#if !defined(GL_ES_VERSION_2_0)
   Standard_Integer aTexIter = 0;
   for (NCollection_Vector<Handle(OpenGl_Texture)>::Iterator aTexSrcIter (myTextures); aTexSrcIter.More(); aTexSrcIter.Next(), ++aTexIter)
   {
@@ -524,7 +519,6 @@ Standard_Boolean OpenGl_RaytraceGeometry::UpdateTextureHandles (const Handle(Ope
       return Standard_False;
     }
   }
-#endif
 
   return Standard_True;
 }
index 711fa1a243f54822955d41f473c3f1061811f07f..788aa3553eab6eabef601e468e94a7c4e4feaf2b 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
+#if defined(_WIN32)
+  #include <windows.h>
+#endif
+
 #include <OpenGl_GlCore12.hxx>
 
 #include <OpenGl_Context.hxx>
index 49108d4f2b76ce9cbed2ee15f2badb5fe6a6a102..af552243a5401ddd8a76645715a6f39223dfe75b 100644 (file)
@@ -326,12 +326,12 @@ void OpenGl_Window::Init()
     EAGLContext* aGLCtx      = myGlContext->myGContext;
     CAEAGLLayer* anEaglLayer = (CAEAGLLayer* )myUIView.layer;
     GLuint aWinRBColor = 0;
-    ::glGenRenderbuffers (1, &aWinRBColor);
-    ::glBindRenderbuffer (GL_RENDERBUFFER, aWinRBColor);
+    myGlContext->Functions()->glGenRenderbuffers (1, &aWinRBColor);
+    myGlContext->Functions()->glBindRenderbuffer (GL_RENDERBUFFER, aWinRBColor);
     [aGLCtx renderbufferStorage: GL_RENDERBUFFER fromDrawable: anEaglLayer];
-    ::glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH,  &myWidth);
-    ::glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &myHeight);
-    ::glBindRenderbuffer (GL_RENDERBUFFER, 0);
+    myGlContext->Functions()->glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH,  &myWidth);
+    myGlContext->Functions()->glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &myHeight);
+    myGlContext->Functions()->glBindRenderbuffer (GL_RENDERBUFFER, 0);
 
     if (!aDefFbo->InitWithRB (myGlContext, Graphic3d_Vec2i (myWidth, myHeight), GL_RGBA8, GL_DEPTH24_STENCIL8, aWinRBColor))
     {
@@ -380,16 +380,17 @@ Standard_ENABLE_DEPRECATION_WARNINGS
   myHeightPt = Standard_Integer(aBounds.size.height);
 #endif
 
-  ::glDisable (GL_DITHER);
-  ::glDisable (GL_SCISSOR_TEST);
-  ::glViewport (0, 0, myWidth, myHeight);
-#if !defined(GL_ES_VERSION_2_0)
-  ::glDrawBuffer (GL_BACK);
-  if (myGlContext->core11ffp != NULL)
+  myGlContext->core11fwd->glDisable (GL_DITHER);
+  myGlContext->core11fwd->glDisable (GL_SCISSOR_TEST);
+  myGlContext->core11fwd->glViewport (0, 0, myWidth, myHeight);
+  if (myGlContext->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
   {
-    ::glMatrixMode (GL_MODELVIEW);
+    myGlContext->core11fwd->glDrawBuffer (GL_BACK);
+    if (myGlContext->core11ffp != NULL)
+    {
+      myGlContext->core11ffp->glMatrixMode (GL_MODELVIEW);
+    }
   }
-#endif
 }
 
 // =======================================================================