From 67c12d80204843ec61fbd064ccf0c427c1fc297a Mon Sep 17 00:00:00 2001 From: kgv Date: Thu, 9 Jul 2015 14:25:31 +0300 Subject: [PATCH] 0026404: Visualization, Ray Tracing - use solid background color when gradient color is disabled Test-case for issue #26404 --- src/OpenGl/OpenGl_View_Raytrace.cxx | 14 +++++++++++++- tests/bugs/vis/bug26404 | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 tests/bugs/vis/bug26404 diff --git a/src/OpenGl/OpenGl_View_Raytrace.cxx b/src/OpenGl/OpenGl_View_Raytrace.cxx index d5923c59f7..cf34ca2a21 100644 --- a/src/OpenGl/OpenGl_View_Raytrace.cxx +++ b/src/OpenGl/OpenGl_View_Raytrace.cxx @@ -2263,13 +2263,25 @@ Standard_Boolean OpenGl_View::setUniformState (const Graphic3d_CView& the } // Set background colors (only gradient background supported) - if (myBgGradientArray != NULL) + if (myBgGradientArray != NULL + && myBgGradientArray->IsDefined()) { theProgram->SetUniform (theGlContext, myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], myBgGradientArray->GradientColor (0)); theProgram->SetUniform (theGlContext, myUniformLocations[theProgramId][OpenGl_RT_uBackColorBot], myBgGradientArray->GradientColor (1)); } + else + { + const OpenGl_Vec4 aBackColor (theCView.DefWindow.Background.r, + theCView.DefWindow.Background.g, + theCView.DefWindow.Background.b, + 1.0f); + theProgram->SetUniform (theGlContext, + myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], aBackColor); + theProgram->SetUniform (theGlContext, + myUniformLocations[theProgramId][OpenGl_RT_uBackColorBot], aBackColor); + } theProgram->SetUniform (theGlContext, myUniformLocations[theProgramId][OpenGl_RT_uSphereMapForBack], theCView.RenderParams.UseEnvironmentMapBackground ? 1 : 0); diff --git a/tests/bugs/vis/bug26404 b/tests/bugs/vis/bug26404 new file mode 100644 index 0000000000..62f56d955c --- /dev/null +++ b/tests/bugs/vis/bug26404 @@ -0,0 +1,27 @@ +puts "========" +puts "OCC26404" +puts "========" +puts "" +########################################################################################### +# Visualization, Ray Tracing - use solid background color when gradient color is disabled +########################################################################################### + +box b 1 2 3 +vinit View1 +vclear +vaxo +vsetdispmode 1 +vsetcolorbg 10 10 10 +vdisplay b +vfit +vraytrace 1 +set bug_info_1 [vreadpixel 50 50 rgb name] +if {$bug_info_1 != "GRAY8"} { + puts "ERROR: OCC26404 is reproduced. Background color is invalid (case #1)." +} +vsetgradientbg 255 0 0 0 0 255 1 +vsetgradientbg 255 0 0 0 0 255 0 +set bug_info_2 [vreadpixel 50 50 rgb name] +if {$bug_info_2 != "GRAY8"} { + puts "ERROR: OCC26404 is reproduced. Background color is invalid (case #2)." +} -- 2.20.1