MCPcopy Create free account
hub / github.com/Kitware/VTK / PreDraw

Method PreDraw

Rendering/OpenGL2/vtkOpenGLLowMemoryCellTypeAgent.cxx:57–114  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

55
56//------------------------------------------------------------------------------
57void vtkOpenGLLowMemoryCellTypeAgent::PreDraw(
58 vtkRenderer* renderer, vtkActor* actor, vtkOpenGLLowMemoryPolyDataMapper* mapper) const
59{
60 if (!mapper)
61 {
62 return;
63 }
64 this->PreDrawInternal(renderer, actor, mapper);
65 if (actor->GetProperty()->GetRepresentation() == VTK_POINTS || this->InVertexVisibilityPass)
66 {
67 mapper->ElementType = vtkDrawTexturedElements::ElementShape::Point;
68 }
69 // wacky backwards compatibility with old VTK lighting
70 // soooo there are many factors that determine if a primitive is lit or not.
71 // three that mix in a complex way are representation POINT, Interpolation FLAT
72 // and having normals or not.
73 bool needLighting = false;
74 if (actor->GetProperty()->GetRepresentation() == VTK_POINTS)
75 {
76 needLighting =
77 (actor->GetProperty()->GetInterpolation() != VTK_FLAT && mapper->HasPointNormals);
78 }
79 else // wireframe or surface rep
80 {
81 bool isTrisOrStrips = (this->NumberOfPointsPerPrimitive >= 3);
82 needLighting = (isTrisOrStrips ||
83 (!isTrisOrStrips && actor->GetProperty()->GetInterpolation() != VTK_FLAT &&
84 mapper->HasPointNormals));
85 }
86 if (actor->GetProperty()->GetRenderLinesAsTubes() && actor->GetProperty()->GetLineWidth() > 1.0)
87 {
88 needLighting = true;
89 }
90 if (actor->GetProperty()->GetRenderPointsAsSpheres() &&
91 mapper->ElementType == vtkDrawTexturedElements::ElementShape::Point)
92 {
93 needLighting = true;
94 }
95 mapper->ShaderProgram->SetUniformi("enable_lights", needLighting);
96 mapper->ShaderProgram->SetUniformi("vertex_pass", this->InVertexVisibilityPass);
97 switch (mapper->ElementType)
98 {
99 case vtkDrawTexturedElements::ElementShape::Point:
100 mapper->ShaderProgram->SetUniformi("primitiveSize", 1);
101 break;
102 case vtkDrawTexturedElements::ElementShape::Line:
103 mapper->ShaderProgram->SetUniformi("primitiveSize", 2);
104 break;
105 case vtkDrawTexturedElements::ElementShape::Triangle:
106 default:
107 mapper->ShaderProgram->SetUniformi("primitiveSize", 3);
108 break;
109 }
110 mapper->ShaderProgram->SetUniformf("pointSize",
111 mapper->PointPicking ? ::GetPointPickingPrimitiveSize(mapper->ElementType)
112 : actor->GetProperty()->GetPointSize());
113 mapper->vtkDrawTexturedElements::PreDraw(renderer, actor, mapper);
114}

Callers

nothing calls this directly

Calls 7

GetRepresentationMethod · 0.80
PreDrawInternalMethod · 0.45
GetPropertyMethod · 0.45
GetInterpolationMethod · 0.45
SetUniformiMethod · 0.45
SetUniformfMethod · 0.45

Tested by

no test coverage detected