0030643: Visualization, Ray-Tracing - shader compilation errors are not properly...
authorkgv <kgv@opencascade.com>
Tue, 9 Apr 2019 13:25:29 +0000 (16:25 +0300)
committerapn <apn@opencascade.com>
Wed, 10 Apr 2019 12:33:55 +0000 (15:33 +0300)
OpenGl_View::initShader() now uses OpenGl_ShaderObject::LoadAndCompile().

src/OpenGl/OpenGl_View_Raytrace.cxx

index 35013cd..05b495b 100644 (file)
@@ -1194,71 +1194,20 @@ Handle(OpenGl_ShaderObject) OpenGl_View::initShader (const GLenum
                                                      const Handle(OpenGl_Context)& theGlContext)
 {
   Handle(OpenGl_ShaderObject) aShader = new OpenGl_ShaderObject (theType);
-
   if (!aShader->Create (theGlContext))
   {
-    const TCollection_ExtendedString aMessage = TCollection_ExtendedString ("Error: Failed to create ") +
-      (theType == GL_VERTEX_SHADER ? "vertex" : "fragment") + " shader object";
-
-    theGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
-      GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMessage);
-
-    aShader->Release (theGlContext.operator->());
-
+    theGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
+                               TCollection_ExtendedString ("Error: Failed to create ") +
+                               (theType == GL_VERTEX_SHADER ? "vertex" : "fragment") + " shader object");
+    aShader->Release (theGlContext.get());
     return Handle(OpenGl_ShaderObject)();
   }
 
-  if (!aShader->LoadSource (theGlContext, theSource.Source()))
+  if (!aShader->LoadAndCompile (theGlContext, "", theSource.Source()))
   {
-    const TCollection_ExtendedString aMessage = TCollection_ExtendedString ("Error: Failed to set ") +
-      (theType == GL_VERTEX_SHADER ? "vertex" : "fragment") + " shader source";
-
-    theGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
-      GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMessage);
-
-    aShader->Release (theGlContext.operator->());
-
-    return Handle(OpenGl_ShaderObject)();
-  }
-
-  TCollection_AsciiString aBuildLog;
-
-  if (!aShader->Compile (theGlContext))
-  {
-    aShader->FetchInfoLog (theGlContext, aBuildLog);
-
-    const TCollection_ExtendedString aMessage = TCollection_ExtendedString ("Error: Failed to compile ") +
-      (theType == GL_VERTEX_SHADER ? "vertex" : "fragment") + " shader object:\n" + aBuildLog;
-
-    theGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
-      GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMessage);
-
-    aShader->Release (theGlContext.operator->());
-
-#ifdef RAY_TRACE_PRINT_INFO
-    std::cout << "Shader build log:\n" << aBuildLog << "\n";
-#endif
-
+    aShader->Release (theGlContext.get());
     return Handle(OpenGl_ShaderObject)();
   }
-  else if (theGlContext->caps->glslWarnings)
-  {
-    aShader->FetchInfoLog (theGlContext, aBuildLog);
-
-    if (!aBuildLog.IsEmpty() && !aBuildLog.IsEqual ("No errors.\n"))
-    {
-      const TCollection_ExtendedString aMessage = TCollection_ExtendedString (theType == GL_VERTEX_SHADER ?
-        "Vertex" : "Fragment") + " shader was compiled with following warnings:\n" + aBuildLog;
-
-      theGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
-        GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_LOW, aMessage);
-    }
-
-#ifdef RAY_TRACE_PRINT_INFO
-    std::cout << "Shader build log:\n" << aBuildLog << "\n";
-#endif
-  }
-
   return aShader;
 }