VTK  9.3.0
vtkTexture.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
46 #ifndef vtkTexture_h
47 #define vtkTexture_h
48 
49 #include "vtkImageAlgorithm.h"
50 #include "vtkRenderingCoreModule.h" // For export macro
51 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_*
52 
53 VTK_ABI_NAMESPACE_BEGIN
54 class vtkImageData;
55 class vtkScalarsToColors;
56 class vtkRenderer;
58 class vtkWindow;
59 class vtkDataArray;
60 class vtkTransform;
61 
62 #define VTK_TEXTURE_QUALITY_DEFAULT 0
63 #define VTK_TEXTURE_QUALITY_16BIT 16
64 #define VTK_TEXTURE_QUALITY_32BIT 32
65 
66 class VTKRENDERINGCORE_EXPORT vtkTexture : public vtkImageAlgorithm
67 {
68 public:
69  static vtkTexture* New();
70  vtkTypeMacro(vtkTexture, vtkImageAlgorithm);
71  void PrintSelf(ostream& os, vtkIndent indent) override;
72 
78  virtual void Render(vtkRenderer* ren);
79 
84  virtual void PostRender(vtkRenderer*) {}
85 
92 
98  virtual void Load(vtkRenderer*) {}
99 
101 
104  vtkGetMacro(Interpolate, vtkTypeBool);
105  vtkSetMacro(Interpolate, vtkTypeBool);
106  vtkBooleanMacro(Interpolate, vtkTypeBool);
108 
110 
113  vtkGetMacro(Mipmap, bool);
114  vtkSetMacro(Mipmap, bool);
115  vtkBooleanMacro(Mipmap, bool);
117 
119 
125  vtkSetMacro(MaximumAnisotropicFiltering, float);
126  vtkGetMacro(MaximumAnisotropicFiltering, float);
128 
130 
134  vtkSetMacro(Quality, int);
135  vtkGetMacro(Quality, int);
136  void SetQualityToDefault() { this->SetQuality(VTK_TEXTURE_QUALITY_DEFAULT); }
137  void SetQualityTo16Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_16BIT); }
138  void SetQualityTo32Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
140 
142 
152  vtkSetMacro(ColorMode, int);
153  vtkGetMacro(ColorMode, int);
154  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
155  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
158 
164 
166 
170  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
172 
174 
177  vtkGetObjectMacro(MappedScalars, vtkUnsignedCharArray);
179 
183  unsigned char* MapScalarsToColors(vtkDataArray* scalars);
184 
186 
190  void SetTransform(vtkTransform* transform);
191  vtkGetObjectMacro(Transform, vtkTransform);
193 
199  {
200  VTK_TEXTURE_BLENDING_MODE_NONE = 0,
206  VTK_TEXTURE_BLENDING_MODE_SUBTRACT
207  };
208 
210 
214  vtkGetMacro(BlendingMode, int);
215  vtkSetMacro(BlendingMode, int);
217 
219 
223  vtkGetMacro(PremultipliedAlpha, bool);
224  vtkSetMacro(PremultipliedAlpha, bool);
225  vtkBooleanMacro(PremultipliedAlpha, bool);
227 
229 
236  vtkGetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
237  vtkSetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
238  vtkBooleanMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
240 
247  virtual int IsTranslucent();
248 
252  virtual int GetTextureUnit() { return 0; }
253 
255 
261  vtkGetMacro(CubeMap, bool);
262  vtkBooleanMacro(CubeMap, bool);
263  void SetCubeMap(bool val);
265 
267 
273  vtkGetMacro(UseSRGBColorSpace, bool);
274  vtkSetMacro(UseSRGBColorSpace, bool);
275  vtkBooleanMacro(UseSRGBColorSpace, bool);
277 
279 
287  vtkSetVector4Macro(BorderColor, float);
288  vtkGetVector4Macro(BorderColor, float);
290 
291  enum
292  {
293  ClampToEdge = 0,
297  NumberOfWrapModes
298  };
299 
301 
314  vtkGetMacro(Wrap, int);
315  vtkSetClampMacro(Wrap, int, ClampToEdge, ClampToBorder);
317 
319 
323  virtual void SetRepeat(vtkTypeBool r) { this->SetWrap(r ? Repeat : ClampToEdge); }
324  virtual vtkTypeBool GetRepeat() { return (this->GetWrap() == Repeat); }
325  virtual void RepeatOn() { this->SetRepeat(true); }
326  virtual void RepeatOff() { this->SetRepeat(false); }
327  virtual void SetEdgeClamp(vtkTypeBool)
328  { /* This wasn't doing anything before. */
329  }
330  virtual vtkTypeBool GetEdgeClamp() { return (this->GetWrap() == ClampToEdge); }
331  virtual void EdgeClampOn() { this->SetEdgeClamp(true); }
332  virtual void EdgeClampOff() { this->SetEdgeClamp(false); }
334 
335 protected:
337  ~vtkTexture() override;
338 
339  // A texture is a sink, so there is no need to do anything.
340  // This definition avoids a warning when doing Update() on a vtkTexture object.
341  void ExecuteData(vtkDataObject*) override {}
342 
343  bool Mipmap;
345  int Wrap;
346  float BorderColor[4];
348  int Quality;
353 
356  // this is to duplicated the previous behavior of SelfCreatedLookUpTable
359  bool CubeMap;
361 
362  // the result of HasTranslucentPolygonalGeometry is cached
365 
366 private:
367  vtkTexture(const vtkTexture&) = delete;
368  void operator=(const vtkTexture&) = delete;
369 };
370 
371 VTK_ABI_NAMESPACE_END
372 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
general representation of visualization data
Definition: vtkDataObject.h:64
Generic algorithm superclass for image algs.
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
a simple class to control print indentation
Definition: vtkIndent.h:38
abstract specification for renderers
Definition: vtkRenderer.h:71
Superclass for mapping scalar values to colors.
handles properties associated with a texture map
Definition: vtkTexture.h:67
virtual vtkTypeBool GetRepeat()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:324
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:136
int ColorMode
Definition: vtkTexture.h:349
virtual void RepeatOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:326
void SetColorModeToDirectScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:156
@ MirroredRepeat
Definition: vtkTexture.h:295
vtkUnsignedCharArray * MappedScalars
Definition: vtkTexture.h:351
void SetQualityTo16Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:137
vtkTypeBool RestrictPowerOf2ImageSmaller
Definition: vtkTexture.h:355
virtual void Load(vtkRenderer *)
Abstract interface to renderer.
Definition: vtkTexture.h:98
bool UseSRGBColorSpace
Definition: vtkTexture.h:360
virtual void SetRepeat(vtkTypeBool r)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:323
int SelfAdjustingTableRange
Definition: vtkTexture.h:357
vtkTypeBool Interpolate
Definition: vtkTexture.h:347
int BlendingMode
Definition: vtkTexture.h:354
float MaximumAnisotropicFiltering
Definition: vtkTexture.h:344
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:199
@ VTK_TEXTURE_BLENDING_MODE_MODULATE
Definition: vtkTexture.h:202
@ VTK_TEXTURE_BLENDING_MODE_ADD
Definition: vtkTexture.h:203
@ VTK_TEXTURE_BLENDING_MODE_REPLACE
Definition: vtkTexture.h:201
@ VTK_TEXTURE_BLENDING_MODE_INTERPOLATE
Definition: vtkTexture.h:205
@ VTK_TEXTURE_BLENDING_MODE_ADD_SIGNED
Definition: vtkTexture.h:204
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:332
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this texture.
Definition: vtkTexture.h:91
vtkTransform * Transform
Definition: vtkTexture.h:352
void SetQualityTo32Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:138
bool CubeMap
Definition: vtkTexture.h:359
virtual vtkTypeBool GetEdgeClamp()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:330
virtual void EdgeClampOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:331
bool PremultipliedAlpha
Definition: vtkTexture.h:358
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:325
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:84
int TranslucentCachedResult
Definition: vtkTexture.h:364
void SetLookupTable(vtkScalarsToColors *)
Specify the lookup table to convert scalars if necessary.
vtkTimeStamp TranslucentComputationTime
Definition: vtkTexture.h:363
void ExecuteData(vtkDataObject *) override
This method is the old style execute method, provided for the sake of backwards compatibility with ol...
Definition: vtkTexture.h:341
virtual int GetTextureUnit()
Return the texture unit used for this texture.
Definition: vtkTexture.h:252
void SetColorModeToDefault()
Default: ColorModeToDefault.
Definition: vtkTexture.h:154
bool Mipmap
Definition: vtkTexture.h:343
void SetColorModeToMapScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:155
virtual void SetEdgeClamp(vtkTypeBool)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:327
vtkScalarsToColors * LookupTable
Definition: vtkTexture.h:350
record modification and/or execution time
Definition: vtkTimeStamp.h:34
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
@ Transform
Definition: vtkX3D.h:41
int vtkTypeBool
Definition: vtkABI.h:64
#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:62
#define VTK_TEXTURE_QUALITY_32BIT
Definition: vtkTexture.h:64
#define VTK_TEXTURE_QUALITY_16BIT
Definition: vtkTexture.h:63