Skip to content
Snippets Groups Projects
Commit 897a852b authored by Cory Quammen's avatar Cory Quammen Committed by Mathieu Westphal (Kitware)
Browse files

vtkOpenGLProjectedTetrahedraMapper: move shader binding

Move binding of the shader program needed for the projected
tetrahedra rendering algorithm closer to where it is needed.
This makes it less likely to interfere with other shader
programs that may be used in the algorithm.
parent 269b7b03
No related branches found
No related tags found
No related merge requests found
......@@ -338,32 +338,6 @@ void vtkOpenGLProjectedTetrahedraMapper::Render(vtkRenderer* renderer, vtkVolume
vtkUnstructuredGridBase* input = this->GetInput();
vtkVolumeProperty* property = volume->GetProperty();
// has something changed that would require us to recreate the shader?
if (!this->Tris.Program)
{
// build the shader source code
std::string VSSource = vtkglProjectedTetrahedraVS;
std::string FSSource = vtkglProjectedTetrahedraFS;
std::string GSSource;
// compile and bind it if needed
vtkShaderProgram* newShader = renWin->GetShaderCache()->ReadyShaderProgram(
VSSource.c_str(), FSSource.c_str(), GSSource.c_str());
// if the shader changed reinitialize the VAO
if (newShader != this->Tris.Program)
{
this->Tris.Program = newShader;
this->Tris.VAO->ShaderProgramChanged(); // reset the VAO as the shader has changed
}
this->Tris.ShaderSourceTime.Modified();
}
else
{
renWin->GetShaderCache()->ReadyShaderProgram(this->Tris.Program);
}
// Check to see if input changed.
if ((this->InputAnalyzedTime < this->MTime) || (this->InputAnalyzedTime < input->GetMTime()))
{
......@@ -548,6 +522,32 @@ void vtkOpenGLProjectedTetrahedraMapper::ProjectTetrahedra(
vtkOpenGLCheckErrorMacro("failed at glBlitFramebuffer");
}
// has something changed that would require us to recreate the shader?
if (!this->Tris.Program)
{
// build the shader source code
std::string VSSource = vtkglProjectedTetrahedraVS;
std::string FSSource = vtkglProjectedTetrahedraFS;
std::string GSSource;
// compile and bind it if needed
vtkShaderProgram* newShader = window->GetShaderCache()->ReadyShaderProgram(
VSSource.c_str(), FSSource.c_str(), GSSource.c_str());
// if the shader changed reinitialize the VAO
if (newShader != this->Tris.Program)
{
this->Tris.Program = newShader;
this->Tris.VAO->ShaderProgramChanged(); // reset the VAO as the shader has changed
}
this->Tris.ShaderSourceTime.Modified();
}
else
{
window->GetShaderCache()->ReadyShaderProgram(this->Tris.Program);
}
// TODO:
// There are some caching optimizations that could be used
// here to skip various expensive operations (eg sorting
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment