]> OCCT Git - occt.git/commitdiff
0032150: Visualization, TKOpenGl - ignore OpenGl_Caps::ffpEnable when FFP is unavailable
authorkgv <kgv@opencascade.com>
Sat, 20 Feb 2021 17:58:33 +0000 (20:58 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 24 Feb 2021 17:59:43 +0000 (20:59 +0300)
OpenGl_Workspace::Activate() now implicitly disables OpenGl_Caps::ffpEnable when it is unsupported.
OpenGl_AspectsSprite::build() now ignores OpenGl_Caps::pntSpritesDisable when Display Lists are unsupported.

src/OpenGl/OpenGl_AspectsSprite.cxx
src/OpenGl/OpenGl_Context.cxx
src/OpenGl/OpenGl_GlFunctions.cxx
src/OpenGl/OpenGl_TextureFormat.cxx
src/OpenGl/OpenGl_Workspace.cxx

index f991381a8980a761477093331eedee88fb9ea6fb..568a642c1fb1962a6c3782cb7dd23fb8df50324a 100644 (file)
@@ -253,9 +253,8 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
     return;
   }
 
-  if (!theCtx.IsNull()
-   &&  theCtx->core20fwd != NULL
-   && !theCtx->caps->pntSpritesDisable)
+  if (theCtx->core20fwd != NULL
+   && (!theCtx->caps->pntSpritesDisable || theCtx->core11 == NULL))
   {
     // Creating texture resource for using it with point sprites
     Handle(Image_PixMap) anImage = aNewMarkerImage->GetImage();
@@ -273,7 +272,7 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
       }
     }
   }
-  else
+  else if (theCtx->core11 != NULL)
   {
   #if !defined(GL_ES_VERSION_2_0)
     // Creating list with bitmap for using it in compatibility mode
index c649bd9e2b4853ed63a428a0b8011546574f5c50..a580583644083fa8c6055d79e52bba6fd0cc93a9 100644 (file)
@@ -2579,7 +2579,9 @@ void OpenGl_Context::SetLineStipple (const Standard_ShortReal theFactor,
 // =======================================================================
 void OpenGl_Context::SetLineWidth (const Standard_ShortReal theWidth)
 {
+#if !defined(GL_ES_VERSION_2_0)
   if (core11 != NULL)
+#endif
   {
     // glLineWidth() is still defined within Core Profile, but has no effect with values != 1.0f
     core11fwd->glLineWidth (theWidth * myLineWidthScale);
index aaec5276cd787ae96b9a4dbc4fee9eb677a83e5a..216aa3197ec18b7b698684312d9c3244cb7d7f85 100644 (file)
 void OpenGl_GlFunctions::load (OpenGl_Context& theCtx,
                                Standard_Boolean theIsCoreProfile)
 {
+#if defined(GL_ES_VERSION_2_0)
+  (void )theIsCoreProfile;
+  theCtx.core11 = NULL;
+#else
   const bool isCoreProfile = theIsCoreProfile;
   theCtx.core11 = !isCoreProfile ? (OpenGl_GlCore11* )this : NULL;
+#endif
   theCtx.core11fwd  = (OpenGl_GlCore11Fwd* )this;
   theCtx.core15     = NULL;
   theCtx.core15fwd  = NULL;
index be055ae72d2b87a887f091d3a7ec540959453e8f..b9ad0f03a66c3e33b32ae1baa1740f970e1a0de7 100644 (file)
@@ -123,12 +123,17 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
 {
   OpenGl_TextureFormat aFormat;
   aFormat.SetImageFormat (theFormat);
+#if defined(GL_ES_VERSION_2_0)
+  const bool useRedRedAlpha = false;
+#else
+  const bool useRedRedAlpha = (theCtx->core11 == NULL);
+#endif
   switch (theFormat)
   {
     case Image_Format_GrayF:
     {
       aFormat.SetNbComponents (1);
-      if (theCtx->core11 == NULL)
+      if (useRedRedAlpha)
       {
         aFormat.SetInternalFormat (theCtx->arbTexFloat ? GL_R32F : GL_R8);
         aFormat.SetPixelFormat (GL_RED);
@@ -148,7 +153,7 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
     case Image_Format_AlphaF:
     {
       aFormat.SetNbComponents (1);
-      if (theCtx->core11 == NULL)
+      if (useRedRedAlpha)
       {
         aFormat.SetInternalFormat (theCtx->arbTexFloat ? GL_R32F : GL_R8);
         aFormat.SetPixelFormat (GL_RED);
@@ -382,7 +387,7 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
     case Image_Format_Gray:
     {
       aFormat.SetNbComponents (1);
-      if (theCtx->core11 == NULL)
+      if (useRedRedAlpha)
       {
         aFormat.SetInternalFormat (GL_R8);
         aFormat.SetPixelFormat (GL_RED);
@@ -402,7 +407,7 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
     case Image_Format_Alpha:
     {
       aFormat.SetNbComponents (1);
-      if (theCtx->core11 == NULL)
+      if (useRedRedAlpha)
       {
         aFormat.SetInternalFormat (GL_R8);
         aFormat.SetPixelFormat (GL_RED);
index d720ec245109c6e6a9caf376cc1220c211c0ac01..bfe72a42785ef58b3c0789f81ae8553ab8fb7708 100644 (file)
@@ -168,6 +168,19 @@ Standard_Boolean OpenGl_Workspace::Activate()
   ViewMatrix_applied      = &myDefaultMatrix;
   StructureMatrix_applied = &myDefaultMatrix;
 
+  if (myGlContext->core11 == NULL)
+  {
+    if (myGlContext->caps->ffpEnable)
+    {
+    #if defined(GL_ES_VERSION_2_0)
+      Message::SendWarning ("Warning: FFP is unsupported by OpenGL ES");
+    #else
+      Message::SendWarning ("Warning: FFP is unsupported by OpenGL Core Profile");
+    #endif
+      myGlContext->caps->ffpEnable = false;
+    }
+  }
+
   ResetAppliedAspect();
 
   // reset state for safety