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
37 #ifndef vtkTexture_h
38 #define vtkTexture_h
39 
40 #include "vtkImageAlgorithm.h"
41 #include "vtkRenderingCoreModule.h" // For export macro
42 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_*
43 
44 VTK_ABI_NAMESPACE_BEGIN
45 class vtkImageData;
46 class vtkScalarsToColors;
47 class vtkRenderer;
49 class vtkWindow;
50 class vtkDataArray;
51 class vtkTransform;
52 
53 #define VTK_TEXTURE_QUALITY_DEFAULT 0
54 #define VTK_TEXTURE_QUALITY_16BIT 16
55 #define VTK_TEXTURE_QUALITY_32BIT 32
56 
57 class VTKRENDERINGCORE_EXPORT vtkTexture : public vtkImageAlgorithm
58 {
59 public:
60  static vtkTexture* New();
61  vtkTypeMacro(vtkTexture, vtkImageAlgorithm);
62  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
69  virtual void Render(vtkRenderer* ren);
70 
75  virtual void PostRender(vtkRenderer*) {}
76 
83 
89  virtual void Load(vtkRenderer*) {}
90 
92 
95  vtkGetMacro(Interpolate, vtkTypeBool);
96  vtkSetMacro(Interpolate, vtkTypeBool);
97  vtkBooleanMacro(Interpolate, vtkTypeBool);
99 
101 
104  vtkGetMacro(Mipmap, bool);
105  vtkSetMacro(Mipmap, bool);
106  vtkBooleanMacro(Mipmap, bool);
108 
110 
116  vtkSetMacro(MaximumAnisotropicFiltering, float);
117  vtkGetMacro(MaximumAnisotropicFiltering, float);
119 
121 
125  vtkSetMacro(Quality, int);
126  vtkGetMacro(Quality, int);
127  void SetQualityToDefault() { this->SetQuality(VTK_TEXTURE_QUALITY_DEFAULT); }
128  void SetQualityTo16Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_16BIT); }
129  void SetQualityTo32Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
131 
133 
143  vtkSetMacro(ColorMode, int);
144  vtkGetMacro(ColorMode, int);
145  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
146  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
149 
155 
157 
161  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
163 
165 
168  vtkGetObjectMacro(MappedScalars, vtkUnsignedCharArray);
170 
174  unsigned char* MapScalarsToColors(vtkDataArray* scalars);
175 
177 
181  void SetTransform(vtkTransform* transform);
182  vtkGetObjectMacro(Transform, vtkTransform);
184 
190  {
191  VTK_TEXTURE_BLENDING_MODE_NONE = 0,
197  VTK_TEXTURE_BLENDING_MODE_SUBTRACT
198  };
199 
201 
205  vtkGetMacro(BlendingMode, int);
206  vtkSetMacro(BlendingMode, int);
208 
210 
214  vtkGetMacro(PremultipliedAlpha, bool);
215  vtkSetMacro(PremultipliedAlpha, bool);
216  vtkBooleanMacro(PremultipliedAlpha, bool);
218 
220 
227  vtkGetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
228  vtkSetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
229  vtkBooleanMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
231 
238  virtual int IsTranslucent();
239 
243  virtual int GetTextureUnit() { return 0; }
244 
246 
252  vtkGetMacro(CubeMap, bool);
253  vtkBooleanMacro(CubeMap, bool);
254  void SetCubeMap(bool val);
256 
258 
264  vtkGetMacro(UseSRGBColorSpace, bool);
265  vtkSetMacro(UseSRGBColorSpace, bool);
266  vtkBooleanMacro(UseSRGBColorSpace, bool);
268 
270 
278  vtkSetVector4Macro(BorderColor, float);
279  vtkGetVector4Macro(BorderColor, float);
281 
282  enum
283  {
284  ClampToEdge = 0,
288  NumberOfWrapModes
289  };
290 
292 
305  vtkGetMacro(Wrap, int);
306  vtkSetClampMacro(Wrap, int, ClampToEdge, ClampToBorder);
308 
310 
314  virtual void SetRepeat(vtkTypeBool r) { this->SetWrap(r ? Repeat : ClampToEdge); }
315  virtual vtkTypeBool GetRepeat() { return (this->GetWrap() == Repeat); }
316  virtual void RepeatOn() { this->SetRepeat(true); }
317  virtual void RepeatOff() { this->SetRepeat(false); }
318  virtual void SetEdgeClamp(vtkTypeBool)
319  { /* This wasn't doing anything before. */
320  }
321  virtual vtkTypeBool GetEdgeClamp() { return (this->GetWrap() == ClampToEdge); }
322  virtual void EdgeClampOn() { this->SetEdgeClamp(true); }
323  virtual void EdgeClampOff() { this->SetEdgeClamp(false); }
325 
326 protected:
328  ~vtkTexture() override;
329 
330  // A texture is a sink, so there is no need to do anything.
331  // This definition avoids a warning when doing Update() on a vtkTexture object.
332  void ExecuteData(vtkDataObject*) override {}
333 
334  bool Mipmap;
336  int Wrap;
337  float BorderColor[4];
339  int Quality;
344 
347  // this is to duplicated the previous behavior of SelfCreatedLookUpTable
350  bool CubeMap;
352 
353  // the result of HasTranslucentPolygonalGeometry is cached
356 
357 private:
358  vtkTexture(const vtkTexture&) = delete;
359  void operator=(const vtkTexture&) = delete;
360 };
361 
362 VTK_ABI_NAMESPACE_END
363 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:45
general representation of visualization data
Definition: vtkDataObject.h:55
Generic algorithm superclass for image algs.
topologically and geometrically regular array of data
Definition: vtkImageData.h:43
a simple class to control print indentation
Definition: vtkIndent.h:29
abstract specification for renderers
Definition: vtkRenderer.h:62
Superclass for mapping scalar values to colors.
handles properties associated with a texture map
Definition: vtkTexture.h:58
virtual vtkTypeBool GetRepeat()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:315
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:127
int ColorMode
Definition: vtkTexture.h:340
virtual void RepeatOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:317
void SetColorModeToDirectScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:147
@ MirroredRepeat
Definition: vtkTexture.h:286
vtkUnsignedCharArray * MappedScalars
Definition: vtkTexture.h:342
void SetQualityTo16Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:128
vtkTypeBool RestrictPowerOf2ImageSmaller
Definition: vtkTexture.h:346
virtual void Load(vtkRenderer *)
Abstract interface to renderer.
Definition: vtkTexture.h:89
bool UseSRGBColorSpace
Definition: vtkTexture.h:351
virtual void SetRepeat(vtkTypeBool r)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:314
int SelfAdjustingTableRange
Definition: vtkTexture.h:348
vtkTypeBool Interpolate
Definition: vtkTexture.h:338
int BlendingMode
Definition: vtkTexture.h:345
float MaximumAnisotropicFiltering
Definition: vtkTexture.h:335
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:190
@ VTK_TEXTURE_BLENDING_MODE_MODULATE
Definition: vtkTexture.h:193
@ VTK_TEXTURE_BLENDING_MODE_ADD
Definition: vtkTexture.h:194
@ VTK_TEXTURE_BLENDING_MODE_REPLACE
Definition: vtkTexture.h:192
@ VTK_TEXTURE_BLENDING_MODE_INTERPOLATE
Definition: vtkTexture.h:196
@ VTK_TEXTURE_BLENDING_MODE_ADD_SIGNED
Definition: vtkTexture.h:195
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:323
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this texture.
Definition: vtkTexture.h:82
vtkTransform * Transform
Definition: vtkTexture.h:343
void SetQualityTo32Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:129
bool CubeMap
Definition: vtkTexture.h:350
virtual vtkTypeBool GetEdgeClamp()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:321
virtual void EdgeClampOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:322
bool PremultipliedAlpha
Definition: vtkTexture.h:349
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:316
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:75
int TranslucentCachedResult
Definition: vtkTexture.h:355
void SetLookupTable(vtkScalarsToColors *)
Specify the lookup table to convert scalars if necessary.
vtkTimeStamp TranslucentComputationTime
Definition: vtkTexture.h:354
void ExecuteData(vtkDataObject *) override
This method is the old style execute method, provided for the sake of backwards compatibility with ol...
Definition: vtkTexture.h:332
virtual int GetTextureUnit()
Return the texture unit used for this texture.
Definition: vtkTexture.h:243
void SetColorModeToDefault()
Default: ColorModeToDefault.
Definition: vtkTexture.h:145
bool Mipmap
Definition: vtkTexture.h:334
void SetColorModeToMapScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:146
virtual void SetEdgeClamp(vtkTypeBool)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:318
vtkScalarsToColors * LookupTable
Definition: vtkTexture.h:341
record modification and/or execution time
Definition: vtkTimeStamp.h:25
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition: vtkWindow.h:28
@ 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:53
#define VTK_TEXTURE_QUALITY_32BIT
Definition: vtkTexture.h:55
#define VTK_TEXTURE_QUALITY_16BIT
Definition: vtkTexture.h:54