Commit 8676a995 authored by Simon Drouin's avatar Simon Drouin

Fixed to build with LEGACY_REMOVE ON.

parent eee31572
......@@ -21,6 +21,10 @@
*
* @sa
* vtkVolume vtkOpenGLUniform
*
* @par Thanks:
* Developed by Simon Drouin (sdrouin2@bwh.harvard.edu) at Brigham and Women's Hospital.
*
*/
#ifndef vtkShaderProperty_h
......
......@@ -23,6 +23,9 @@
*
* @sa
* vtkOpenGLUniforms vtkShaderProperty
*
* @par Thanks:
* Developed by Simon Drouin (sdrouin2@bwh.harvard.edu) at Brigham and Women's Hospital.
*/
#ifndef vtkUniforms_h
......
......@@ -28,6 +28,7 @@
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkShaderProgram.h"
#include "vtkShaderProperty.h"
#include "vtkSmartPointer.h"
#include "vtkTestUtilities.h"
#include "vtkTexture.h"
......@@ -86,17 +87,17 @@ int TestCubeMap(int argc, char *argv[])
actor->SetTexture(texture);
actor->SetMapper(mapper);
vtkShaderProperty * sp = actor->GetShaderProperty();
// Add new code in default VTK vertex shader
mapper->AddShaderReplacement(
vtkShader::Vertex,
sp->AddVertexShaderReplacement(
"//VTK::PositionVC::Dec", // replace the normal block
true, // before the standard replacements
"//VTK::PositionVC::Dec\n" // we still want the default
"out vec3 TexCoords;\n",
false // only do it once
);
mapper->AddShaderReplacement(
vtkShader::Vertex,
sp->AddVertexShaderReplacement(
"//VTK::PositionVC::Impl", // replace the normal block
true, // before the standard replacements
"//VTK::PositionVC::Impl\n" // we still want the default
......@@ -106,7 +107,7 @@ int TestCubeMap(int argc, char *argv[])
);
// Replace VTK fragment shader
mapper->SetFragmentShaderCode(
sp->SetFragmentShaderCode(
"//VTK::System::Dec\n" // always start with this line
"//VTK::Output::Dec\n" // always have this line in your FS
"in vec3 TexCoords;\n"
......
......@@ -29,6 +29,7 @@
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkShaderProgram.h"
#include "vtkShaderProperty.h"
#include "vtkSkybox.h"
#include "vtkSmartPointer.h"
#include "vtkTestUtilities.h"
......@@ -113,16 +114,15 @@ int TestCubeMap2(int argc, char *argv[])
actor->SetTexture(texture);
actor->SetMapper(mapper);
mapper->AddShaderReplacement(
vtkShader::Vertex,
vtkShaderProperty * sp = actor->GetShaderProperty();
sp->AddVertexShaderReplacement(
"//VTK::PositionVC::Dec", // replace
true, // before the standard replacements
"//VTK::PositionVC::Dec\n" // we still want the default
"out vec3 TexCoords;\n",
false // only do it once
);
mapper->AddShaderReplacement(
vtkShader::Vertex,
sp->AddVertexShaderReplacement(
"//VTK::PositionVC::Impl", // replace
true, // before the standard replacements
"//VTK::PositionVC::Impl\n" // we still want the default
......@@ -130,16 +130,14 @@ int TestCubeMap2(int argc, char *argv[])
"TexCoords.xyz = reflect(vertexMC.xyz - camPos, normalize(normalMC));\n",
false // only do it once
);
mapper->AddShaderReplacement(
vtkShader::Fragment,
sp->AddFragmentShaderReplacement(
"//VTK::Light::Dec", // replace
true, // before the standard replacements
"//VTK::Light::Dec\n" // we still want the default
"in vec3 TexCoords;\n",
false // only do it once
);
mapper->AddShaderReplacement(
vtkShader::Fragment,
sp->AddFragmentShaderReplacement(
"//VTK::Light::Impl", // replace
true, // before the standard replacements
" vec3 cubeColor = texture(actortexture, normalize(TexCoords)).xyz;\n"
......
......@@ -28,6 +28,7 @@
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkShaderProgram.h"
#include "vtkShaderProperty.h"
#include "vtkSkybox.h"
#include "vtkSmartPointer.h"
#include "vtkTestUtilities.h"
......@@ -93,16 +94,16 @@ int TestSphereMap(int argc, char *argv[])
actor->SetTexture(texture);
actor->SetMapper(mapper);
mapper->AddShaderReplacement(
vtkShader::Vertex,
vtkShaderProperty * sp = actor->GetShaderProperty();
sp->AddVertexShaderReplacement(
"//VTK::PositionVC::Dec", // replace
true, // before the standard replacements
"//VTK::PositionVC::Dec\n" // we still want the default
"out vec3 TexCoords;\n",
false // only do it once
);
mapper->AddShaderReplacement(
vtkShader::Vertex,
sp->AddVertexShaderReplacement(
"//VTK::PositionVC::Impl", // replace
true, // before the standard replacements
"//VTK::PositionVC::Impl\n" // we still want the default
......@@ -110,16 +111,14 @@ int TestSphereMap(int argc, char *argv[])
"TexCoords.xyz = reflect(vertexMC.xyz - camPos, normalize(normalMC));\n",
false // only do it once
);
mapper->AddShaderReplacement(
vtkShader::Fragment,
sp->AddFragmentShaderReplacement(
"//VTK::Light::Dec", // replace
true, // before the standard replacements
"//VTK::Light::Dec\n" // we still want the default
"in vec3 TexCoords;\n",
false // only do it once
);
mapper->AddShaderReplacement(
vtkShader::Fragment,
sp->AddFragmentShaderReplacement(
"//VTK::Light::Impl", // replace
true, // before the standard replacements
"//VTK::Light::Impl\n"
......
......@@ -21,6 +21,7 @@
#include "vtkNew.h"
#include "vtkProperty.h"
#include "vtkPolyDataNormals.h"
#include "vtkShaderProperty.h"
#include "vtkTriangleMeshPointNormals.h"
#include "vtkRegressionTestImage.h"
......@@ -74,46 +75,41 @@ int TestUserShader(int argc, char *argv[])
// Then we modify the fragment shader to set the diffuse color
// based on that normal. First lets modify the vertex
// shader
mapper->AddShaderReplacement(
vtkShader::Vertex,
vtkShaderProperty * sp = actor->GetShaderProperty();
sp->AddVertexShaderReplacement(
"//VTK::Normal::Dec", // replace the normal block
true, // before the standard replacements
"//VTK::Normal::Dec\n" // we still want the default
" out vec3 myNormalMCVSOutput;\n", //but we add this
false // only do it once
);
mapper->AddShaderReplacement(
vtkShader::Vertex,
sp->AddVertexShaderReplacement(
"//VTK::Normal::Impl", // replace the normal block
true, // before the standard replacements
"//VTK::Normal::Impl\n" // we still want the default
" myNormalMCVSOutput = normalMC;\n", //but we add this
false // only do it once
);
mapper->AddShaderReplacement(
vtkShader::Vertex,
sp->AddVertexShaderReplacement(
"//VTK::Color::Impl", // dummy replacement for testing clear method
true,
"VTK::Color::Impl\n",
false
);
mapper->ClearShaderReplacement(
vtkShader::Vertex, // clear our dummy replacement
sp->ClearVertexShaderReplacement(
"//VTK::Color::Impl",
true
);
// now modify the fragment shader
mapper->AddShaderReplacement(
vtkShader::Fragment, // in the fragment shader
sp->AddFragmentShaderReplacement(
"//VTK::Normal::Dec", // replace the normal block
true, // before the standard replacements
"//VTK::Normal::Dec\n" // we still want the default
" in vec3 myNormalMCVSOutput;\n", //but we add this
false // only do it once
);
mapper->AddShaderReplacement(
vtkShader::Fragment, // in the fragment shader
sp->AddFragmentShaderReplacement(
"//VTK::Normal::Impl", // replace the normal block
true, // before the standard replacements
"//VTK::Normal::Impl\n" // we still want the default calc
......
......@@ -25,6 +25,7 @@
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkShaderProgram.h"
#include "vtkShaderProperty.h"
#include "vtkTestUtilities.h"
#include "vtkTimerLog.h"
#include "vtkTriangleMeshPointNormals.h"
......@@ -122,13 +123,15 @@ int TestUserShader2(int argc, char *argv[])
actor->GetProperty()->SetSpecularPower(20.0);
actor->GetProperty()->SetOpacity(1.0);
vtkShaderProperty * sp = actor->GetShaderProperty();
// Clear all custom shader tag replacements
// The following code is mainly for regression testing as we do not have any
// custom shader replacements.
mapper->ClearAllShaderReplacements(vtkShader::Vertex);
mapper->ClearAllShaderReplacements(vtkShader::Fragment);
mapper->ClearAllShaderReplacements(vtkShader::Geometry);
mapper->ClearAllShaderReplacements();
sp->ClearAllVertexShaderReplacements();
sp->ClearAllFragmentShaderReplacements();
sp->ClearAllGeometryShaderReplacements();
sp->ClearAllShaderReplacements();
// Use our own hardcoded shader code. Generally this is a bad idea in a
// general purpose program as there are so many things VTK supports that
......@@ -136,7 +139,7 @@ int TestUserShader2(int argc, char *argv[])
// know what your data will be like it can be very useful. The mapper will set
// a bunch of uniforms regardless of if you are using them. But feel free to
// use them :-)
mapper->SetVertexShaderCode(
sp->SetVertexShaderCode(
"//VTK::System::Dec\n" // always start with this line
"in vec4 vertexMC;\n"
// use the default normal decl as the mapper
......@@ -153,7 +156,7 @@ int TestUserShader2(int argc, char *argv[])
" gl_Position = tmpPos*vec4(0.2+0.8*abs(tmpPos.x),0.2+0.8*abs(tmpPos.y),1.0,1.0);\n"
"}\n"
);
mapper->SetFragmentShaderCode(
sp->SetFragmentShaderCode(
"//VTK::System::Dec\n" // always start with this line
"//VTK::Output::Dec\n" // always have this line in your FS
"in vec3 normalVCVSOutput;\n"
......
......@@ -3166,9 +3166,11 @@ void vtkOpenGLPolyDataMapper::ShallowCopy(vtkAbstractMapper *mapper)
this->SetCompositeIdArrayName(m->GetCompositeIdArrayName());
this->SetProcessIdArrayName(m->GetProcessIdArrayName());
this->SetCellIdArrayName(m->GetCellIdArrayName());
#ifndef VTK_LEGACY_REMOVE
this->SetVertexShaderCode(m->GetVertexShaderCode());
this->SetGeometryShaderCode(m->GetGeometryShaderCode());
this->SetFragmentShaderCode(m->GetFragmentShaderCode());
#endif
}
// Now do superclass
......
......@@ -21,6 +21,10 @@
*
* @sa
* vtkShaderProperty vtkUniforms vtkOpenGLUniform
*
* @par Thanks:
* Developed by Simon Drouin (sdrouin2@bwh.harvard.edu) at Brigham and Women's Hospital.
*
*/
#ifndef vtkOpenGLShaderProperty_h
......
......@@ -27,6 +27,7 @@
#include "vtkOpenGLError.h"
#include "vtkRenderWindow.h"
#include "vtkShaderProgram.h"
#include "vtkOpenGLShaderProperty.h"
#include "vtkTexture.h"
#include <cmath>
......@@ -57,7 +58,8 @@ vtkOpenGLSkybox::vtkOpenGLSkybox()
this->SetMapper(this->CubeMapper);
this->OpenGLActor->SetMapper(this->CubeMapper);
this->CubeMapper->AddShaderReplacement(
vtkOpenGLShaderProperty * sp = vtkOpenGLShaderProperty::SafeDownCast(this->OpenGLActor->GetShaderProperty());
sp->AddShaderReplacement(
vtkShader::Vertex,
"//VTK::PositionVC::Dec", // replace
true, // before the standard replacements
......@@ -65,7 +67,7 @@ vtkOpenGLSkybox::vtkOpenGLSkybox()
"out vec3 TexCoords;\n",
false // only do it once
);
this->CubeMapper->AddShaderReplacement(
sp->AddShaderReplacement(
vtkShader::Vertex,
"//VTK::PositionVC::Impl", // replace
true, // before the standard replacements
......@@ -116,10 +118,11 @@ void vtkOpenGLSkybox::Render(vtkRenderer *ren, vtkMapper *mapper)
if (this->LastProjection != this->Projection)
{
vtkOpenGLShaderProperty * sp = vtkOpenGLShaderProperty::SafeDownCast(this->OpenGLActor->GetShaderProperty());
if (this->Projection == vtkSkybox::Cube)
{
// Replace VTK fragment shader
this->CubeMapper->SetFragmentShaderCode(
sp->SetFragmentShaderCode(
"//VTK::System::Dec\n" // always start with this line
"//VTK::Output::Dec\n" // always have this line in your FS
"in vec3 TexCoords;\n"
......@@ -133,7 +136,7 @@ void vtkOpenGLSkybox::Render(vtkRenderer *ren, vtkMapper *mapper)
if (this->Projection == vtkSkybox::Sphere)
{
// Replace VTK fragment shader
this->CubeMapper->SetFragmentShaderCode(
sp->SetFragmentShaderCode(
"//VTK::System::Dec\n" // always start with this line
"//VTK::Output::Dec\n" // always have this line in your FS
"in vec3 TexCoords;\n"
......@@ -155,7 +158,7 @@ void vtkOpenGLSkybox::Render(vtkRenderer *ren, vtkMapper *mapper)
if (this->Projection == vtkSkybox::StereoSphere)
{
// Replace VTK fragment shader
this->CubeMapper->SetFragmentShaderCode(
sp->SetFragmentShaderCode(
"//VTK::System::Dec\n" // always start with this line
"//VTK::Output::Dec\n" // always have this line in your FS
"in vec3 TexCoords;\n"
......@@ -178,7 +181,7 @@ void vtkOpenGLSkybox::Render(vtkRenderer *ren, vtkMapper *mapper)
if (this->Projection == vtkSkybox::Floor)
{
// Replace VTK fragment shader
this->CubeMapper->SetFragmentShaderCode(
sp->SetFragmentShaderCode(
"//VTK::System::Dec\n" // always start with this line
"//VTK::Output::Dec\n" // always have this line in your FS
"in vec3 TexCoords;\n"
......
......@@ -22,6 +22,9 @@
* The basic types of GLSL uniform variables supported by the class are the following: int, float,
* vec2i, vec3, vec4, mat3, mat4, int[], float[], vec2i[], vec3[], vec4[], mat4[]. All other
* types supported by Set* functions undergo the same type conversions implemented in vtkShaderProgram.
*
* @par Thanks:
* Developed by Simon Drouin (sdrouin2@bwh.harvard.edu) at Brigham and Women's Hospital.
*/
#ifndef vtkOpenGLUniforms_h
......
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