0031597: Visualization, TKOpenGl - allow disabling Alpha component writes within...
[occt.git] / src / OpenGl / OpenGl_Context.cxx
index 257f8d4..53fb914 100644 (file)
@@ -4609,17 +4609,29 @@ void OpenGl_Context::DisableFeatures() const
 #endif
 }
 
+// =======================================================================
+// function : SetColorMaskRGBA
+// purpose  :
+// =======================================================================
+void OpenGl_Context::SetColorMaskRGBA (const NCollection_Vec4<bool>& theVal)
+{
+  glColorMask (theVal.r() ? GL_TRUE : GL_FALSE,
+               theVal.g() ? GL_TRUE : GL_FALSE,
+               theVal.b() ? GL_TRUE : GL_FALSE,
+               theVal.a() ? GL_TRUE : GL_FALSE);
+  myColorMask = theVal;
+}
+
 // =======================================================================
 // function : SetColorMask
 // purpose  :
 // =======================================================================
 bool OpenGl_Context::SetColorMask (bool theToWriteColor)
 {
+  const bool anOldValue = myColorMask.r();
+  myColorMask.SetValues (theToWriteColor, theToWriteColor, theToWriteColor, caps->buffersOpaqueAlpha ? false : theToWriteColor);
   const GLboolean toWrite = theToWriteColor ? GL_TRUE : GL_FALSE;
-  glColorMask (toWrite, toWrite, toWrite, toWrite);
-
-  const bool anOldValue = myColorMask;
-  myColorMask = theToWriteColor;
+  glColorMask (toWrite, toWrite, toWrite, myColorMask.a() ? GL_TRUE : GL_FALSE);
   return anOldValue;
 }