VTK  9.1.0
vtkTexture.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTexture.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
155 #ifndef vtkTexture_h
156 #define vtkTexture_h
157 
158 #include "vtkImageAlgorithm.h"
159 #include "vtkRenderingCoreModule.h" // For export macro
160 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_*
161 
162 class vtkImageData;
163 class vtkScalarsToColors;
164 class vtkRenderer;
166 class vtkWindow;
167 class vtkDataArray;
168 class vtkTransform;
169 
170 #define VTK_TEXTURE_QUALITY_DEFAULT 0
171 #define VTK_TEXTURE_QUALITY_16BIT 16
172 #define VTK_TEXTURE_QUALITY_32BIT 32
173 
174 class VTKRENDERINGCORE_EXPORT vtkTexture : public vtkImageAlgorithm
175 {
176 public:
177  static vtkTexture* New();
179  void PrintSelf(ostream& os, vtkIndent indent) override;
180 
186  virtual void Render(vtkRenderer* ren);
187 
192  virtual void PostRender(vtkRenderer*) {}
193 
200 
206  virtual void Load(vtkRenderer*) {}
207 
209 
212  vtkGetMacro(Interpolate, vtkTypeBool);
213  vtkSetMacro(Interpolate, vtkTypeBool);
214  vtkBooleanMacro(Interpolate, vtkTypeBool);
216 
218 
221  vtkGetMacro(Mipmap, bool);
222  vtkSetMacro(Mipmap, bool);
223  vtkBooleanMacro(Mipmap, bool);
225 
227 
233  vtkSetMacro(MaximumAnisotropicFiltering, float);
234  vtkGetMacro(MaximumAnisotropicFiltering, float);
236 
238 
242  vtkSetMacro(Quality, int);
243  vtkGetMacro(Quality, int);
244  void SetQualityToDefault() { this->SetQuality(VTK_TEXTURE_QUALITY_DEFAULT); }
245  void SetQualityTo16Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_16BIT); }
246  void SetQualityTo32Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
248 
250 
260  vtkSetMacro(ColorMode, int);
261  vtkGetMacro(ColorMode, int);
262  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
263  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
266 
272 
274 
278  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
280 
282 
285  vtkGetObjectMacro(MappedScalars, vtkUnsignedCharArray);
287 
291  unsigned char* MapScalarsToColors(vtkDataArray* scalars);
292 
294 
298  void SetTransform(vtkTransform* transform);
299  vtkGetObjectMacro(Transform, vtkTransform);
301 
307  {
308  VTK_TEXTURE_BLENDING_MODE_NONE = 0,
314  VTK_TEXTURE_BLENDING_MODE_SUBTRACT
315  };
316 
318 
322  vtkGetMacro(BlendingMode, int);
323  vtkSetMacro(BlendingMode, int);
325 
327 
331  vtkGetMacro(PremultipliedAlpha, bool);
332  vtkSetMacro(PremultipliedAlpha, bool);
333  vtkBooleanMacro(PremultipliedAlpha, bool);
335 
337 
344  vtkGetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
345  vtkSetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
346  vtkBooleanMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
348 
355  virtual int IsTranslucent();
356 
360  virtual int GetTextureUnit() { return 0; }
361 
363 
369  vtkGetMacro(CubeMap, bool);
370  vtkBooleanMacro(CubeMap, bool);
371  void SetCubeMap(bool val);
373 
375 
381  vtkGetMacro(UseSRGBColorSpace, bool);
382  vtkSetMacro(UseSRGBColorSpace, bool);
383  vtkBooleanMacro(UseSRGBColorSpace, bool);
385 
387 
395  vtkSetVector4Macro(BorderColor, float);
396  vtkGetVector4Macro(BorderColor, float);
398 
399  enum
400  {
401  ClampToEdge = 0,
405  NumberOfWrapModes
406  };
407 
409 
422  vtkGetMacro(Wrap, int);
423  vtkSetClampMacro(Wrap, int, ClampToEdge, ClampToBorder);
425 
427 
431  virtual void SetRepeat(vtkTypeBool r) { this->SetWrap(r ? Repeat : ClampToEdge); }
432  virtual vtkTypeBool GetRepeat() { return (this->GetWrap() == Repeat); }
433  virtual void RepeatOn() { this->SetRepeat(true); }
434  virtual void RepeatOff() { this->SetRepeat(false); }
435  virtual void SetEdgeClamp(vtkTypeBool)
436  { /* This wasn't doing anything before. */
437  }
438  virtual vtkTypeBool GetEdgeClamp() { return (this->GetWrap() == ClampToEdge); }
439  virtual void EdgeClampOn() { this->SetEdgeClamp(true); }
440  virtual void EdgeClampOff() { this->SetEdgeClamp(false); }
442 
443 protected:
445  ~vtkTexture() override;
446 
447  // A texture is a sink, so there is no need to do anything.
448  // This definition avoids a warning when doing Update() on a vtkTexture object.
449  void ExecuteData(vtkDataObject*) override {}
450 
451  bool Mipmap;
453  int Wrap;
454  float BorderColor[4];
456  int Quality;
461 
464  // this is to duplicated the previous behavior of SelfCreatedLookUpTable
467  bool CubeMap;
469 
470  // the result of HasTranslucentPolygonalGeometry is cached
473 
474 private:
475  vtkTexture(const vtkTexture&) = delete;
476  void operator=(const vtkTexture&) = delete;
477 };
478 
479 #endif
vtkTexture::VTK_TEXTURE_BLENDING_MODE_ADD_SIGNED
@ VTK_TEXTURE_BLENDING_MODE_ADD_SIGNED
Definition: vtkTexture.h:312
vtkTexture::VTK_TEXTURE_BLENDING_MODE_ADD
@ VTK_TEXTURE_BLENDING_MODE_ADD
Definition: vtkTexture.h:311
vtkTexture::SelfAdjustingTableRange
int SelfAdjustingTableRange
Definition: vtkTexture.h:465
vtkTexture::Wrap
int Wrap
Definition: vtkTexture.h:453
VTK_COLOR_MODE_MAP_SCALARS
#define VTK_COLOR_MODE_MAP_SCALARS
Definition: vtkSystemIncludes.h:90
vtkTexture::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTexture::EdgeClampOn
virtual void EdgeClampOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:439
vtkTexture::ColorMode
int ColorMode
Definition: vtkTexture.h:457
vtkTexture::vtkTexture
vtkTexture()
vtkTexture::SetColorModeToDefault
void SetColorModeToDefault()
Default: ColorModeToDefault.
Definition: vtkTexture.h:262
vtkTexture::Interpolate
vtkTypeBool Interpolate
Definition: vtkTexture.h:455
vtkTexture::RestrictPowerOf2ImageSmaller
vtkTypeBool RestrictPowerOf2ImageSmaller
Definition: vtkTexture.h:463
vtkTexture::Render
virtual void Render(vtkRenderer *ren)
Renders a texture map.
vtkTexture::ExecuteData
void ExecuteData(vtkDataObject *) override
This method is the old style execute method, provided for the sake of backwards compatibility with ol...
Definition: vtkTexture.h:449
vtkTexture::TranslucentComputationTime
vtkTimeStamp TranslucentComputationTime
Definition: vtkTexture.h:471
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:52
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:145
vtkImageAlgorithm.h
vtkTexture::Quality
int Quality
Definition: vtkTexture.h:456
vtkTexture::MapScalarsToColors
unsigned char * MapScalarsToColors(vtkDataArray *scalars)
Map scalar values into color scalars.
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:57
vtkTexture::MappedScalars
vtkUnsignedCharArray * MappedScalars
Definition: vtkTexture.h:459
vtkTexture::SetQualityTo32Bit
void SetQualityTo32Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:246
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
vtkX3D::Transform
@ Transform
Definition: vtkX3D.h:47
vtkTexture::SetColorModeToDirectScalars
void SetColorModeToDirectScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:264
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
vtkTexture::BlendingMode
int BlendingMode
Definition: vtkTexture.h:462
vtkTexture::EdgeClampOff
virtual void EdgeClampOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:440
VTK_TEXTURE_QUALITY_DEFAULT
#define VTK_TEXTURE_QUALITY_DEFAULT
Definition: vtkTexture.h:170
vtkTexture
handles properties associated with a texture map
Definition: vtkTexture.h:175
vtkTexture::SetCubeMap
void SetCubeMap(bool val)
Is this texture a cube map, if so it needs 6 inputs one for each side of the cube.
vtkTexture::SetColorModeToMapScalars
void SetColorModeToMapScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:263
vtkTexture::Repeat
@ Repeat
Definition: vtkTexture.h:402
vtkTexture::MaximumAnisotropicFiltering
float MaximumAnisotropicFiltering
Definition: vtkTexture.h:452
vtkTexture::SetQualityTo16Bit
void SetQualityTo16Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:245
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:157
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkTexture::RepeatOn
virtual void RepeatOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:433
vtkTexture::VTKTextureBlendingMode
VTKTextureBlendingMode
Used to specify how the texture will blend its RGB and Alpha values with other textures and the fragm...
Definition: vtkTexture.h:307
vtkTexture::GetRepeat
virtual vtkTypeBool GetRepeat()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:432
vtkTexture::SetLookupTable
void SetLookupTable(vtkScalarsToColors *)
Specify the lookup table to convert scalars if necessary.
vtkTexture::PremultipliedAlpha
bool PremultipliedAlpha
Definition: vtkTexture.h:466
vtkTexture::SetTransform
void SetTransform(vtkTransform *transform)
Set a transform on the texture which allows one to scale, rotate and translate the texture.
vtkTexture::SetEdgeClamp
virtual void SetEdgeClamp(vtkTypeBool)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:435
vtkTexture::RepeatOff
virtual void RepeatOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:434
vtkTexture::PostRender
virtual void PostRender(vtkRenderer *)
Cleans up after the texture rendering to restore the state of the graphics context.
Definition: vtkTexture.h:192
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:109
vtkTexture::Load
virtual void Load(vtkRenderer *)
Abstract interface to renderer.
Definition: vtkTexture.h:206
vtkTexture::VTK_TEXTURE_BLENDING_MODE_INTERPOLATE
@ VTK_TEXTURE_BLENDING_MODE_INTERPOLATE
Definition: vtkTexture.h:313
vtkTexture::SetRepeat
virtual void SetRepeat(vtkTypeBool r)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:431
vtkTexture::~vtkTexture
~vtkTexture() override
vtkTexture::Transform
vtkTransform * Transform
Definition: vtkTexture.h:460
vtkTexture::UseSRGBColorSpace
bool UseSRGBColorSpace
Definition: vtkTexture.h:468
vtkTexture::TranslucentCachedResult
int TranslucentCachedResult
Definition: vtkTexture.h:472
VTK_COLOR_MODE_DEFAULT
#define VTK_COLOR_MODE_DEFAULT
Definition: vtkSystemIncludes.h:89
vtkTexture::GetInput
vtkImageData * GetInput()
Get the input as a vtkImageData object.
VTK_TEXTURE_QUALITY_32BIT
#define VTK_TEXTURE_QUALITY_32BIT
Definition: vtkTexture.h:172
vtkTexture::LookupTable
vtkScalarsToColors * LookupTable
Definition: vtkTexture.h:458
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:182
vtkTexture::New
static vtkTexture * New()
VTK_COLOR_MODE_DIRECT_SCALARS
#define VTK_COLOR_MODE_DIRECT_SCALARS
Definition: vtkSystemIncludes.h:91
vtkTexture::GetEdgeClamp
virtual vtkTypeBool GetEdgeClamp()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:438
vtkTexture::Mipmap
bool Mipmap
Definition: vtkTexture.h:451
vtkTexture::IsTranslucent
virtual int IsTranslucent()
Is this Texture Translucent? returns false (0) if the texture is either fully opaque or has only full...
vtkTexture::GetTextureUnit
virtual int GetTextureUnit()
Return the texture unit used for this texture.
Definition: vtkTexture.h:360
vtkTexture::MirroredRepeat
@ MirroredRepeat
Definition: vtkTexture.h:403
vtkTexture::VTK_TEXTURE_BLENDING_MODE_REPLACE
@ VTK_TEXTURE_BLENDING_MODE_REPLACE
Definition: vtkTexture.h:309
vtkTexture::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this texture.
Definition: vtkTexture.h:199
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:169
vtkTexture::CubeMap
bool CubeMap
Definition: vtkTexture.h:467
vtkTexture::ClampToBorder
@ ClampToBorder
Definition: vtkTexture.h:404
vtkTexture::VTK_TEXTURE_BLENDING_MODE_MODULATE
@ VTK_TEXTURE_BLENDING_MODE_MODULATE
Definition: vtkTexture.h:310
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkTexture::SetQualityToDefault
void SetQualityToDefault()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:244
vtkSystemIncludes.h
VTK_TEXTURE_QUALITY_16BIT
#define VTK_TEXTURE_QUALITY_16BIT
Definition: vtkTexture.h:171