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

Method SynchronizeGLLights

Rendering/External/vtkExternalOpenGLRenderer.cxx:78–296  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

76
77//------------------------------------------------------------------------------
78void vtkExternalOpenGLRenderer::SynchronizeGLLights()
79{
80 // Lights
81 // Query lights existing in the external context
82 // and tweak them based on vtkExternalLight objects added by the user
83 GLenum curLight;
84 for (curLight = GL_LIGHT0; curLight < GL_LIGHT0 + MAX_LIGHTS; curLight++)
85 {
86 GLboolean status;
87 glGetBooleanv(curLight, &status);
88
89 int l_ind = static_cast<int>(curLight - GL_LIGHT0);
90 bool light_created = false;
91 vtkLight* light = vtkLight::SafeDownCast(this->GetLights()->GetItemAsObject(l_ind));
92 if (light)
93 {
94 if (!status)
95 {
96 // This is the case when we have a VTK light in the scene but no
97 // external light corresponding to that index in the context.
98 // In this case, we remove the VTK light as well.
99 light->SwitchOff();
100 this->RemoveLight(light);
101
102 // No need to go forward
103 continue;
104 }
105 }
106 else
107 {
108 // No matching light found in the VTK light collection
109 if (status)
110 {
111 // Create a new light only if one is present in the external context
112 light = vtkLight::New();
113 // Headlight because VTK will apply transform matrices
114 light->SetLightTypeToHeadlight();
115 light_created = true;
116 }
117 else
118 {
119 // No need to go forward as this light is not being used
120 continue;
121 }
122 }
123
124 // Find out if there is an external light object associated with this
125 // light index.
126 vtkCollectionSimpleIterator sit;
127 vtkExternalLight* eLight;
128 vtkExternalLight* curExtLight = nullptr;
129 for (this->ExternalLights->InitTraversal(sit);
130 (eLight = vtkExternalLight::SafeDownCast(this->ExternalLights->GetNextLight(sit)));)
131 {
132 if (eLight && (static_cast<GLenum>(eLight->GetLightIndex()) == curLight))
133 {
134 curExtLight = eLight;
135 break;

Callers 1

RenderMethod · 0.95

Calls 15

GetItemAsObjectMethod · 0.80
RemoveLightMethod · 0.80
GetNextLightMethod · 0.80
SetIntensityMethod · 0.80
SetAmbientColorMethod · 0.80
SetDiffuseColorMethod · 0.80
SetSpecularColorMethod · 0.80
SetPositionalMethod · 0.80
SetAttenuationValuesMethod · 0.80
AddLightMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50

Tested by

no test coverage detected