Commit d1bc40f6 authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri 💬
Browse files

Clear all custom shader code in clear shader API

This change ensures that all shader customizations including whole
shader replacements are cleared when the clear methods are called.
parent 8f4ec2da
......@@ -265,6 +265,21 @@ void vtkOpenGLPolyDataMapper::ClearShaderReplacement(
void vtkOpenGLPolyDataMapper::ClearAllShaderReplacements(
vtkShader::Type shaderType)
{
// First clear all shader code
if ((shaderType == vtkShader::Vertex) && this->VertexShaderCode)
{
this->SetVertexShaderCode(nullptr);
}
else if ((shaderType == vtkShader::Fragment) && this->FragmentShaderCode)
{
this->SetFragmentShaderCode(nullptr);
}
else if ((shaderType == vtkShader::Geometry) && this->GeometryShaderCode)
{
this->SetGeometryShaderCode(nullptr);
}
// Now clear custom tag replacements
std::map<const vtkShader::ReplacementSpec,
vtkShader::ReplacementValue>::iterator rIter;
for (rIter = this->UserShaderReplacements.begin();
......@@ -284,6 +299,9 @@ void vtkOpenGLPolyDataMapper::ClearAllShaderReplacements(
//-----------------------------------------------------------------------------
void vtkOpenGLPolyDataMapper::ClearAllShaderReplacements()
{
this->SetVertexShaderCode(nullptr);
this->SetFragmentShaderCode(nullptr);
this->SetGeometryShaderCode(nullptr);
this->UserShaderReplacements.clear();
}
......
......@@ -3052,6 +3052,17 @@ void vtkOpenGLGPUVolumeRayCastMapper::ClearShaderReplacement(
void vtkOpenGLGPUVolumeRayCastMapper::ClearAllShaderReplacements(
vtkShader::Type shaderType)
{
// First clear all shader code
if ((shaderType == vtkShader::Vertex) && this->VertexShaderCode)
{
this->SetVertexShaderCode(nullptr);
}
else if ((shaderType == vtkShader::Fragment) && this->FragmentShaderCode)
{
this->SetFragmentShaderCode(nullptr);
}
// Now clear custom tag replacements
std::map<const vtkShader::ReplacementSpec,
vtkShader::ReplacementValue>::iterator rIter;
for (rIter = this->UserShaderReplacements.begin();
......@@ -3071,6 +3082,8 @@ void vtkOpenGLGPUVolumeRayCastMapper::ClearAllShaderReplacements(
//-----------------------------------------------------------------------------
void vtkOpenGLGPUVolumeRayCastMapper::ClearAllShaderReplacements()
{
this->SetVertexShaderCode(nullptr);
this->SetFragmentShaderCode(nullptr);
this->UserShaderReplacements.clear();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment