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 =========================================================================*/
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 class vtkImageData;
54 class vtkScalarsToColors;
55 class vtkRenderer;
57 class vtkWindow;
58 class vtkDataArray;
59 class vtkTransform;
60 
61 #define VTK_TEXTURE_QUALITY_DEFAULT 0
62 #define VTK_TEXTURE_QUALITY_16BIT 16
63 #define VTK_TEXTURE_QUALITY_32BIT 32
64 
65 class VTKRENDERINGCORE_EXPORT vtkTexture : public vtkImageAlgorithm
66 {
67 public:
68  static vtkTexture* New();
69  vtkTypeMacro(vtkTexture, vtkImageAlgorithm);
70  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
77  virtual void Render(vtkRenderer* ren);
78 
83  virtual void PostRender(vtkRenderer*) {}
84 
91 
97  virtual void Load(vtkRenderer*) {}
98 
100 
103  vtkGetMacro(Interpolate, vtkTypeBool);
104  vtkSetMacro(Interpolate, vtkTypeBool);
105  vtkBooleanMacro(Interpolate, vtkTypeBool);
107 
109 
112  vtkGetMacro(Mipmap, bool);
113  vtkSetMacro(Mipmap, bool);
114  vtkBooleanMacro(Mipmap, bool);
116 
118 
124  vtkSetMacro(MaximumAnisotropicFiltering, float);
125  vtkGetMacro(MaximumAnisotropicFiltering, float);
127 
129 
133  vtkSetMacro(Quality, int);
134  vtkGetMacro(Quality, int);
135  void SetQualityToDefault() { this->SetQuality(VTK_TEXTURE_QUALITY_DEFAULT); }
136  void SetQualityTo16Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_16BIT); }
137  void SetQualityTo32Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
139 
141 
151  vtkSetMacro(ColorMode, int);
152  vtkGetMacro(ColorMode, int);
153  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
154  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
157 
163 
165 
169  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
171 
173 
176  vtkGetObjectMacro(MappedScalars, vtkUnsignedCharArray);
178 
182  unsigned char* MapScalarsToColors(vtkDataArray* scalars);
183 
185 
189  void SetTransform(vtkTransform* transform);
190  vtkGetObjectMacro(Transform, vtkTransform);
192 
198  {
199  VTK_TEXTURE_BLENDING_MODE_NONE = 0,
205  VTK_TEXTURE_BLENDING_MODE_SUBTRACT
206  };
207 
209 
213  vtkGetMacro(BlendingMode, int);
214  vtkSetMacro(BlendingMode, int);
216 
218 
222  vtkGetMacro(PremultipliedAlpha, bool);
223  vtkSetMacro(PremultipliedAlpha, bool);
224  vtkBooleanMacro(PremultipliedAlpha, bool);
226 
228 
235  vtkGetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
236  vtkSetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
237  vtkBooleanMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
239 
246  virtual int IsTranslucent();
247 
251  virtual int GetTextureUnit() { return 0; }
252 
254 
260  vtkGetMacro(CubeMap, bool);
261  vtkBooleanMacro(CubeMap, bool);
262  void SetCubeMap(bool val);
264 
266 
272  vtkGetMacro(UseSRGBColorSpace, bool);
273  vtkSetMacro(UseSRGBColorSpace, bool);
274  vtkBooleanMacro(UseSRGBColorSpace, bool);
276 
278 
286  vtkSetVector4Macro(BorderColor, float);
287  vtkGetVector4Macro(BorderColor, float);
289 
290  enum
291  {
292  ClampToEdge = 0,
296  NumberOfWrapModes
297  };
298 
300 
313  vtkGetMacro(Wrap, int);
314  vtkSetClampMacro(Wrap, int, ClampToEdge, ClampToBorder);
316 
318 
322  virtual void SetRepeat(vtkTypeBool r) { this->SetWrap(r ? Repeat : ClampToEdge); }
323  virtual vtkTypeBool GetRepeat() { return (this->GetWrap() == Repeat); }
324  virtual void RepeatOn() { this->SetRepeat(true); }
325  virtual void RepeatOff() { this->SetRepeat(false); }
326  virtual void SetEdgeClamp(vtkTypeBool)
327  { /* This wasn't doing anything before. */
328  }
329  virtual vtkTypeBool GetEdgeClamp() { return (this->GetWrap() == ClampToEdge); }
330  virtual void EdgeClampOn() { this->SetEdgeClamp(true); }
331  virtual void EdgeClampOff() { this->SetEdgeClamp(false); }
333 
334 protected:
336  ~vtkTexture() override;
337 
338  // A texture is a sink, so there is no need to do anything.
339  // This definition avoids a warning when doing Update() on a vtkTexture object.
340  void ExecuteData(vtkDataObject*) override {}
341 
342  bool Mipmap;
344  int Wrap;
345  float BorderColor[4];
347  int Quality;
352 
355  // this is to duplicated the previous behavior of SelfCreatedLookUpTable
358  bool CubeMap;
360 
361  // the result of HasTranslucentPolygonalGeometry is cached
364 
365 private:
366  vtkTexture(const vtkTexture&) = delete;
367  void operator=(const vtkTexture&) = delete;
368 };
369 
370 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
general representation of visualization data
Definition: vtkDataObject.h:60
Generic algorithm superclass for image algs.
topologically and geometrically regular array of data
Definition: vtkImageData.h:48
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract specification for renderers
Definition: vtkRenderer.h:73
Superclass for mapping scalar values to colors.
handles properties associated with a texture map
Definition: vtkTexture.h:66
virtual vtkTypeBool GetRepeat()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:323
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:135
int ColorMode
Definition: vtkTexture.h:348
@ MirroredRepeat
Definition: vtkTexture.h:294
virtual void RepeatOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:325
void SetColorModeToDirectScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:155
vtkUnsignedCharArray * MappedScalars
Definition: vtkTexture.h:350
void SetQualityTo16Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:136
vtkTypeBool RestrictPowerOf2ImageSmaller
Definition: vtkTexture.h:354
virtual void Load(vtkRenderer *)
Abstract interface to renderer.
Definition: vtkTexture.h:97
bool UseSRGBColorSpace
Definition: vtkTexture.h:359
virtual void SetRepeat(vtkTypeBool r)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:322
int SelfAdjustingTableRange
Definition: vtkTexture.h:356
vtkTypeBool Interpolate
Definition: vtkTexture.h:346
int BlendingMode
Definition: vtkTexture.h:353
float MaximumAnisotropicFiltering
Definition: vtkTexture.h:343
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:198
@ VTK_TEXTURE_BLENDING_MODE_MODULATE
Definition: vtkTexture.h:201
@ VTK_TEXTURE_BLENDING_MODE_ADD
Definition: vtkTexture.h:202
@ VTK_TEXTURE_BLENDING_MODE_REPLACE
Definition: vtkTexture.h:200
@ VTK_TEXTURE_BLENDING_MODE_INTERPOLATE
Definition: vtkTexture.h:204
@ VTK_TEXTURE_BLENDING_MODE_ADD_SIGNED
Definition: vtkTexture.h:203
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:331
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this texture.
Definition: vtkTexture.h:90
vtkTransform * Transform
Definition: vtkTexture.h:351
void SetQualityTo32Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:137
bool CubeMap
Definition: vtkTexture.h:358
virtual vtkTypeBool GetEdgeClamp()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:329
virtual void EdgeClampOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:330
bool PremultipliedAlpha
Definition: vtkTexture.h:357
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:324
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:83
int TranslucentCachedResult
Definition: vtkTexture.h:363
void SetLookupTable(vtkScalarsToColors *)
Specify the lookup table to convert scalars if necessary.
vtkTimeStamp TranslucentComputationTime
Definition: vtkTexture.h:362
void ExecuteData(vtkDataObject *) override
This method is the old style execute method, provided for the sake of backwards compatibility with ol...
Definition: vtkTexture.h:340
virtual int GetTextureUnit()
Return the texture unit used for this texture.
Definition: vtkTexture.h:251
void SetColorModeToDefault()
Default: ColorModeToDefault.
Definition: vtkTexture.h:153
bool Mipmap
Definition: vtkTexture.h:342
void SetColorModeToMapScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:154
virtual void SetEdgeClamp(vtkTypeBool)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:326
vtkScalarsToColors * LookupTable
Definition: vtkTexture.h:349
record modification and/or execution time
Definition: vtkTimeStamp.h:33
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
@ 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:61
#define VTK_TEXTURE_QUALITY_32BIT
Definition: vtkTexture.h:63
#define VTK_TEXTURE_QUALITY_16BIT
Definition: vtkTexture.h:62