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

Method RenderTexturedPolygon

Rendering/OpenGL2/vtkOpenGLImageSliceMapper.cxx:201–320  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Load the given image extent into a texture and render it

Source from the content-addressed store, hash-verified

199//------------------------------------------------------------------------------
200// Load the given image extent into a texture and render it
201void vtkOpenGLImageSliceMapper::RenderTexturedPolygon(
202 vtkRenderer* ren, vtkImageProperty* property, vtkImageData* input, int extent[6], bool recursive)
203{
204 // get the previous texture load time
205 vtkMTimeType loadTime = this->LoadTime.GetMTime();
206
207 // the render window, needed for state information
208 vtkOpenGLRenderWindow* renWin = static_cast<vtkOpenGLRenderWindow*>(ren->GetRenderWindow());
209
210 bool reuseTexture = true;
211
212 // if context has changed, verify context capabilities
213 if (renWin != this->RenderWindow || renWin->GetContextCreationTime() > loadTime)
214 {
215 this->RenderWindow = renWin;
216 reuseTexture = false;
217 }
218
219 vtkOpenGLClearErrorMacro();
220
221 // get information about the image
222 int xdim, ydim; // orientation of texture wrt input image
223 vtkImageSliceMapper::GetDimensionIndices(this->Orientation, xdim, ydim);
224
225 // verify that the orientation and slice has not changed
226 bool orientationChanged = (this->Orientation != this->LastOrientation);
227 this->LastOrientation = this->Orientation;
228 bool sliceChanged = (this->SliceNumber != this->LastSliceNumber);
229 this->LastSliceNumber = this->SliceNumber;
230
231 // get the mtime of the property, including the lookup table
232 vtkMTimeType propertyMTime = 0;
233 if (property)
234 {
235 propertyMTime = property->GetMTime();
236 if (!this->PassColorData)
237 {
238 vtkScalarsToColors* table = property->GetLookupTable();
239 if (table)
240 {
241 vtkMTimeType mtime = table->GetMTime();
242 propertyMTime = std::max(mtime, propertyMTime);
243 }
244 }
245 }
246
247 // need to reload the texture
248 if (this->Superclass::GetMTime() > loadTime || propertyMTime > loadTime ||
249 input->GetMTime() > loadTime || orientationChanged || sliceChanged || recursive)
250 {
251 // get the data to load as a texture
252 int xsize = this->TextureSize[0];
253 int ysize = this->TextureSize[1];
254 int bytesPerPixel = this->TextureBytesPerPixel;
255
256 // whether to try to use the input data directly as the texture
257 bool reuseData = true;
258

Callers 1

Calls 15

RenderPolygonMethod · 0.95
RenderBackgroundMethod · 0.95
MakeTextureDataMethod · 0.80
SetScalarsMethod · 0.80
DeleteMethod · 0.65
maxFunction · 0.50
NewFunction · 0.50
GetMTimeMethod · 0.45
GetRenderWindowMethod · 0.45
GetLookupTableMethod · 0.45
SetExtentMethod · 0.45

Tested by

no test coverage detected