VTK  9.0.1
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 
104  vtkGetMacro(Repeat, vtkTypeBool);
105  vtkSetMacro(Repeat, vtkTypeBool);
106  vtkBooleanMacro(Repeat, vtkTypeBool);
108 
110 
116  vtkGetMacro(EdgeClamp, vtkTypeBool);
117  vtkSetMacro(EdgeClamp, vtkTypeBool);
118  vtkBooleanMacro(EdgeClamp, vtkTypeBool);
120 
122 
125  vtkGetMacro(Interpolate, vtkTypeBool);
126  vtkSetMacro(Interpolate, vtkTypeBool);
127  vtkBooleanMacro(Interpolate, vtkTypeBool);
129 
131 
134  vtkGetMacro(Mipmap, bool);
135  vtkSetMacro(Mipmap, bool);
136  vtkBooleanMacro(Mipmap, bool);
138 
140 
146  vtkSetMacro(MaximumAnisotropicFiltering, float);
147  vtkGetMacro(MaximumAnisotropicFiltering, float);
149 
151 
155  vtkSetMacro(Quality, int);
156  vtkGetMacro(Quality, int);
157  void SetQualityToDefault() { this->SetQuality(VTK_TEXTURE_QUALITY_DEFAULT); }
158  void SetQualityTo16Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_16BIT); }
159  void SetQualityTo32Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
161 
163 
173  vtkSetMacro(ColorMode, int);
174  vtkGetMacro(ColorMode, int);
175  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
176  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
179 
185 
187 
191  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
193 
195 
198  vtkGetObjectMacro(MappedScalars, vtkUnsignedCharArray);
200 
204  unsigned char* MapScalarsToColors(vtkDataArray* scalars);
205 
207 
211  void SetTransform(vtkTransform* transform);
212  vtkGetObjectMacro(Transform, vtkTransform);
214 
220  {
221  VTK_TEXTURE_BLENDING_MODE_NONE = 0,
227  VTK_TEXTURE_BLENDING_MODE_SUBTRACT
228  };
229 
231 
235  vtkGetMacro(BlendingMode, int);
236  vtkSetMacro(BlendingMode, int);
238 
240 
244  vtkGetMacro(PremultipliedAlpha, bool);
245  vtkSetMacro(PremultipliedAlpha, bool);
246  vtkBooleanMacro(PremultipliedAlpha, bool);
248 
250 
257  vtkGetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
258  vtkSetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
259  vtkBooleanMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
261 
268  virtual int IsTranslucent();
269 
273  virtual int GetTextureUnit() { return 0; }
274 
276 
282  vtkGetMacro(CubeMap, bool);
283  vtkBooleanMacro(CubeMap, bool);
284  void SetCubeMap(bool val);
286 
288 
294  vtkGetMacro(UseSRGBColorSpace, bool);
295  vtkSetMacro(UseSRGBColorSpace, bool);
296  vtkBooleanMacro(UseSRGBColorSpace, bool);
298 
299 protected:
301  ~vtkTexture() override;
302 
303  // A texture is a sink, so there is no need to do anything.
304  // This definition avoids a warning when doing Update() on a vtkTexture object.
305  void ExecuteData(vtkDataObject*) override {}
306 
307  bool Mipmap;
312  int Quality;
317 
320  // this is to duplicated the previous behavior of SelfCreatedLookUpTable
323  bool CubeMap;
325 
326  // the result of HasTranslucentPolygonalGeometry is cached
329 
330 private:
331  vtkTexture(const vtkTexture&) = delete;
332  void operator=(const vtkTexture&) = delete;
333 };
334 
335 #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:42
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract specification for renderers
Definition: vtkRenderer.h:59
Superclass for mapping scalar values to colors.
handles properties associated with a texture map
Definition: vtkTexture.h:66
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()
Definition: vtkTexture.h:157
int ColorMode
Definition: vtkTexture.h:313
vtkTypeBool EdgeClamp
Definition: vtkTexture.h:310
void SetColorModeToDirectScalars()
Definition: vtkTexture.h:177
vtkUnsignedCharArray * MappedScalars
Definition: vtkTexture.h:315
void SetQualityTo16Bit()
Definition: vtkTexture.h:158
vtkTypeBool RestrictPowerOf2ImageSmaller
Definition: vtkTexture.h:319
virtual void Load(vtkRenderer *)
Abstract interface to renderer.
Definition: vtkTexture.h:97
bool UseSRGBColorSpace
Definition: vtkTexture.h:324
int SelfAdjustingTableRange
Definition: vtkTexture.h:321
vtkTypeBool Interpolate
Definition: vtkTexture.h:311
int BlendingMode
Definition: vtkTexture.h:318
float MaximumAnisotropicFiltering
Definition: vtkTexture.h:308
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:220
@ VTK_TEXTURE_BLENDING_MODE_MODULATE
Definition: vtkTexture.h:223
@ VTK_TEXTURE_BLENDING_MODE_ADD
Definition: vtkTexture.h:224
@ VTK_TEXTURE_BLENDING_MODE_REPLACE
Definition: vtkTexture.h:222
@ VTK_TEXTURE_BLENDING_MODE_INTERPOLATE
Definition: vtkTexture.h:226
@ VTK_TEXTURE_BLENDING_MODE_ADD_SIGNED
Definition: vtkTexture.h:225
void SetTransform(vtkTransform *transform)
Set a transform on the texture which allows one to scale, rotate and translate the texture.
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this texture.
Definition: vtkTexture.h:90
vtkTransform * Transform
Definition: vtkTexture.h:316
void SetQualityTo32Bit()
Definition: vtkTexture.h:159
vtkTypeBool Repeat
Definition: vtkTexture.h:309
bool CubeMap
Definition: vtkTexture.h:323
bool PremultipliedAlpha
Definition: vtkTexture.h:322
vtkImageData * GetInput()
Get the input as a vtkImageData object.
unsigned char * MapScalarsToColors(vtkDataArray *scalars)
Map scalar values into color scalars.
void SetCubeMap(bool val)
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:328
void SetLookupTable(vtkScalarsToColors *)
Specify the lookup table to convert scalars if necessary.
vtkTimeStamp TranslucentComputationTime
Definition: vtkTexture.h:327
void ExecuteData(vtkDataObject *) override
This method is the old style execute method, provided for the sake of backwards compatibility with ol...
Definition: vtkTexture.h:305
virtual int GetTextureUnit()
Return the texture unit used for this texture.
Definition: vtkTexture.h:273
void SetColorModeToDefault()
Definition: vtkTexture.h:175
bool Mipmap
Definition: vtkTexture.h:307
void SetColorModeToMapScalars()
Definition: vtkTexture.h:176
vtkScalarsToColors * LookupTable
Definition: vtkTexture.h:314
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:35
@ 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