VTK  9.2.6
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 =========================================================================*/
58 #ifndef vtkTexture_h
59 #define vtkTexture_h
60 
61 #include "vtkImageAlgorithm.h"
62 #include "vtkRenderingCoreModule.h" // For export macro
63 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_*
64 
65 class vtkImageData;
66 class vtkScalarsToColors;
67 class vtkRenderer;
69 class vtkWindow;
70 class vtkDataArray;
71 class vtkTransform;
72 
73 #define VTK_TEXTURE_QUALITY_DEFAULT 0
74 #define VTK_TEXTURE_QUALITY_16BIT 16
75 #define VTK_TEXTURE_QUALITY_32BIT 32
76 
77 class VTKRENDERINGCORE_EXPORT vtkTexture : public vtkImageAlgorithm
78 {
79 public:
80  static vtkTexture* New();
81  vtkTypeMacro(vtkTexture, vtkImageAlgorithm);
82  void PrintSelf(ostream& os, vtkIndent indent) override;
83 
89  virtual void Render(vtkRenderer* ren);
90 
95  virtual void PostRender(vtkRenderer*) {}
96 
103 
109  virtual void Load(vtkRenderer*) {}
110 
112 
115  vtkGetMacro(Interpolate, vtkTypeBool);
116  vtkSetMacro(Interpolate, vtkTypeBool);
117  vtkBooleanMacro(Interpolate, vtkTypeBool);
119 
121 
124  vtkGetMacro(Mipmap, bool);
125  vtkSetMacro(Mipmap, bool);
126  vtkBooleanMacro(Mipmap, bool);
128 
130 
136  vtkSetMacro(MaximumAnisotropicFiltering, float);
137  vtkGetMacro(MaximumAnisotropicFiltering, float);
139 
141 
145  vtkSetMacro(Quality, int);
146  vtkGetMacro(Quality, int);
147  void SetQualityToDefault() { this->SetQuality(VTK_TEXTURE_QUALITY_DEFAULT); }
148  void SetQualityTo16Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_16BIT); }
149  void SetQualityTo32Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
151 
153 
163  vtkSetMacro(ColorMode, int);
164  vtkGetMacro(ColorMode, int);
165  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
166  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
169 
175 
177 
181  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
183 
185 
188  vtkGetObjectMacro(MappedScalars, vtkUnsignedCharArray);
190 
194  unsigned char* MapScalarsToColors(vtkDataArray* scalars);
195 
197 
201  void SetTransform(vtkTransform* transform);
202  vtkGetObjectMacro(Transform, vtkTransform);
204 
210  {
211  VTK_TEXTURE_BLENDING_MODE_NONE = 0,
217  VTK_TEXTURE_BLENDING_MODE_SUBTRACT
218  };
219 
221 
225  vtkGetMacro(BlendingMode, int);
226  vtkSetMacro(BlendingMode, int);
228 
230 
234  vtkGetMacro(PremultipliedAlpha, bool);
235  vtkSetMacro(PremultipliedAlpha, bool);
236  vtkBooleanMacro(PremultipliedAlpha, bool);
238 
240 
247  vtkGetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
248  vtkSetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
249  vtkBooleanMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
251 
258  virtual int IsTranslucent();
259 
263  virtual int GetTextureUnit() { return 0; }
264 
266 
272  vtkGetMacro(CubeMap, bool);
273  vtkBooleanMacro(CubeMap, bool);
274  void SetCubeMap(bool val);
276 
278 
284  vtkGetMacro(UseSRGBColorSpace, bool);
285  vtkSetMacro(UseSRGBColorSpace, bool);
286  vtkBooleanMacro(UseSRGBColorSpace, bool);
288 
290 
298  vtkSetVector4Macro(BorderColor, float);
299  vtkGetVector4Macro(BorderColor, float);
301 
302  enum
303  {
304  ClampToEdge = 0,
308  NumberOfWrapModes
309  };
310 
312 
325  vtkGetMacro(Wrap, int);
326  vtkSetClampMacro(Wrap, int, ClampToEdge, ClampToBorder);
328 
330 
334  virtual void SetRepeat(vtkTypeBool r) { this->SetWrap(r ? Repeat : ClampToEdge); }
335  virtual vtkTypeBool GetRepeat() { return (this->GetWrap() == Repeat); }
336  virtual void RepeatOn() { this->SetRepeat(true); }
337  virtual void RepeatOff() { this->SetRepeat(false); }
338  virtual void SetEdgeClamp(vtkTypeBool)
339  { /* This wasn't doing anything before. */
340  }
341  virtual vtkTypeBool GetEdgeClamp() { return (this->GetWrap() == ClampToEdge); }
342  virtual void EdgeClampOn() { this->SetEdgeClamp(true); }
343  virtual void EdgeClampOff() { this->SetEdgeClamp(false); }
345 
346 protected:
348  ~vtkTexture() override;
349 
350  // A texture is a sink, so there is no need to do anything.
351  // This definition avoids a warning when doing Update() on a vtkTexture object.
352  void ExecuteData(vtkDataObject*) override {}
353 
354  bool Mipmap;
356  int Wrap;
357  float BorderColor[4];
359  int Quality;
364 
367  // this is to duplicated the previous behavior of SelfCreatedLookUpTable
370  bool CubeMap;
372 
373  // the result of HasTranslucentPolygonalGeometry is cached
376 
377 private:
378  vtkTexture(const vtkTexture&) = delete;
379  void operator=(const vtkTexture&) = delete;
380 };
381 
382 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:65
general representation of visualization data
Definition: vtkDataObject.h:75
Generic algorithm superclass for image algs.
topologically and geometrically regular array of data
Definition: vtkImageData.h:63
a simple class to control print indentation
Definition: vtkIndent.h:49
abstract specification for renderers
Definition: vtkRenderer.h:82
Superclass for mapping scalar values to colors.
handles properties associated with a texture map
Definition: vtkTexture.h:78
virtual vtkTypeBool GetRepeat()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:335
@ MirroredRepeat
Definition: vtkTexture.h:306
static vtkTexture * New()
virtual void Render(vtkRenderer *ren)
Renders a texture map.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
~vtkTexture() override
void SetQualityToDefault()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:147
int ColorMode
Definition: vtkTexture.h:360
virtual void RepeatOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:337
void SetColorModeToDirectScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:167
vtkUnsignedCharArray * MappedScalars
Definition: vtkTexture.h:362
void SetQualityTo16Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:148
vtkTypeBool RestrictPowerOf2ImageSmaller
Definition: vtkTexture.h:366
virtual void Load(vtkRenderer *)
Abstract interface to renderer.
Definition: vtkTexture.h:109
bool UseSRGBColorSpace
Definition: vtkTexture.h:371
virtual void SetRepeat(vtkTypeBool r)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:334
int SelfAdjustingTableRange
Definition: vtkTexture.h:368
vtkTypeBool Interpolate
Definition: vtkTexture.h:358
int BlendingMode
Definition: vtkTexture.h:365
float MaximumAnisotropicFiltering
Definition: vtkTexture.h:355
virtual int IsTranslucent()
Is this Texture Translucent? returns false (0) if the texture is either fully opaque or has only full...
VTKTextureBlendingMode
Used to specify how the texture will blend its RGB and Alpha values with other textures and the fragm...
Definition: vtkTexture.h:210
@ VTK_TEXTURE_BLENDING_MODE_MODULATE
Definition: vtkTexture.h:213
@ VTK_TEXTURE_BLENDING_MODE_ADD
Definition: vtkTexture.h:214
@ VTK_TEXTURE_BLENDING_MODE_REPLACE
Definition: vtkTexture.h:212
@ VTK_TEXTURE_BLENDING_MODE_INTERPOLATE
Definition: vtkTexture.h:216
@ VTK_TEXTURE_BLENDING_MODE_ADD_SIGNED
Definition: vtkTexture.h:215
void SetTransform(vtkTransform *transform)
Set a transform on the texture which allows one to scale, rotate and translate the texture.
virtual void EdgeClampOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:343
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this texture.
Definition: vtkTexture.h:102
vtkTransform * Transform
Definition: vtkTexture.h:363
void SetQualityTo32Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:149
bool CubeMap
Definition: vtkTexture.h:370
virtual vtkTypeBool GetEdgeClamp()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:341
virtual void EdgeClampOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:342
bool PremultipliedAlpha
Definition: vtkTexture.h:369
vtkImageData * GetInput()
Get the input as a vtkImageData object.
unsigned char * MapScalarsToColors(vtkDataArray *scalars)
Map scalar values into color scalars.
virtual void RepeatOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:336
void SetCubeMap(bool val)
Is this texture a cube map, if so it needs 6 inputs one for each side of the cube.
virtual void PostRender(vtkRenderer *)
Cleans up after the texture rendering to restore the state of the graphics context.
Definition: vtkTexture.h:95
int TranslucentCachedResult
Definition: vtkTexture.h:375
void SetLookupTable(vtkScalarsToColors *)
Specify the lookup table to convert scalars if necessary.
vtkTimeStamp TranslucentComputationTime
Definition: vtkTexture.h:374
void ExecuteData(vtkDataObject *) override
This method is the old style execute method, provided for the sake of backwards compatibility with ol...
Definition: vtkTexture.h:352
virtual int GetTextureUnit()
Return the texture unit used for this texture.
Definition: vtkTexture.h:263
void SetColorModeToDefault()
Default: ColorModeToDefault.
Definition: vtkTexture.h:165
bool Mipmap
Definition: vtkTexture.h:354
void SetColorModeToMapScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:166
virtual void SetEdgeClamp(vtkTypeBool)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:338
vtkScalarsToColors * LookupTable
Definition: vtkTexture.h:361
record modification and/or execution time
Definition: vtkTimeStamp.h:45
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:70
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition: vtkWindow.h:48
@ Transform
Definition: vtkX3D.h:47
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_COLOR_MODE_MAP_SCALARS
#define VTK_COLOR_MODE_DEFAULT
#define VTK_COLOR_MODE_DIRECT_SCALARS
#define VTK_TEXTURE_QUALITY_DEFAULT
Definition: vtkTexture.h:73
#define VTK_TEXTURE_QUALITY_32BIT
Definition: vtkTexture.h:75
#define VTK_TEXTURE_QUALITY_16BIT
Definition: vtkTexture.h:74