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=========================================================================*/
55#ifndef vtkTexture_h
56#define vtkTexture_h
57
58#include "vtkImageAlgorithm.h"
59#include "vtkRenderingCoreModule.h" // For export macro
60#include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_*
61
62class vtkImageData;
64class vtkRenderer;
66class vtkWindow;
67class vtkDataArray;
68class vtkTransform;
69
70#define VTK_TEXTURE_QUALITY_DEFAULT 0
71#define VTK_TEXTURE_QUALITY_16BIT 16
72#define VTK_TEXTURE_QUALITY_32BIT 32
73
74class VTKRENDERINGCORE_EXPORT vtkTexture : public vtkImageAlgorithm
75{
76public:
77 static vtkTexture* New();
79 void PrintSelf(ostream& os, vtkIndent indent) override;
80
86 virtual void Render(vtkRenderer* ren);
87
92 virtual void PostRender(vtkRenderer*) {}
93
100
106 virtual void Load(vtkRenderer*) {}
107
109
112 vtkGetMacro(Interpolate, vtkTypeBool);
113 vtkSetMacro(Interpolate, vtkTypeBool);
114 vtkBooleanMacro(Interpolate, vtkTypeBool);
116
118
121 vtkGetMacro(Mipmap, bool);
122 vtkSetMacro(Mipmap, bool);
123 vtkBooleanMacro(Mipmap, bool);
125
127
133 vtkSetMacro(MaximumAnisotropicFiltering, float);
134 vtkGetMacro(MaximumAnisotropicFiltering, float);
136
138
142 vtkSetMacro(Quality, int);
143 vtkGetMacro(Quality, int);
145 void SetQualityTo16Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_16BIT); }
146 void SetQualityTo32Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
148
150
160 vtkSetMacro(ColorMode, int);
161 vtkGetMacro(ColorMode, int);
162 void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
166
172
174
178 vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
180
182
185 vtkGetObjectMacro(MappedScalars, vtkUnsignedCharArray);
187
191 unsigned char* MapScalarsToColors(vtkDataArray* scalars);
192
194
198 void SetTransform(vtkTransform* transform);
199 vtkGetObjectMacro(Transform, vtkTransform);
201
207 {
208 VTK_TEXTURE_BLENDING_MODE_NONE = 0,
214 VTK_TEXTURE_BLENDING_MODE_SUBTRACT
215 };
216
218
222 vtkGetMacro(BlendingMode, int);
223 vtkSetMacro(BlendingMode, int);
225
227
231 vtkGetMacro(PremultipliedAlpha, bool);
232 vtkSetMacro(PremultipliedAlpha, bool);
233 vtkBooleanMacro(PremultipliedAlpha, bool);
235
237
244 vtkGetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
245 vtkSetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
246 vtkBooleanMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
248
255 virtual int IsTranslucent();
256
260 virtual int GetTextureUnit() { return 0; }
261
263
269 vtkGetMacro(CubeMap, bool);
270 vtkBooleanMacro(CubeMap, bool);
271 void SetCubeMap(bool val);
273
275
281 vtkGetMacro(UseSRGBColorSpace, bool);
282 vtkSetMacro(UseSRGBColorSpace, bool);
283 vtkBooleanMacro(UseSRGBColorSpace, bool);
285
287
295 vtkSetVector4Macro(BorderColor, float);
296 vtkGetVector4Macro(BorderColor, float);
298
299 enum
300 {
301 ClampToEdge = 0,
305 NumberOfWrapModes
306 };
307
309
322 vtkGetMacro(Wrap, int);
323 vtkSetClampMacro(Wrap, int, ClampToEdge, ClampToBorder);
325
327
331 virtual void SetRepeat(vtkTypeBool r) { this->SetWrap(r ? Repeat : ClampToEdge); }
332 virtual vtkTypeBool GetRepeat() { return (this->GetWrap() == Repeat); }
333 virtual void RepeatOn() { this->SetRepeat(true); }
334 virtual void RepeatOff() { this->SetRepeat(false); }
336 { /* This wasn't doing anything before. */
337 }
338 virtual vtkTypeBool GetEdgeClamp() { return (this->GetWrap() == ClampToEdge); }
339 virtual void EdgeClampOn() { this->SetEdgeClamp(true); }
340 virtual void EdgeClampOff() { this->SetEdgeClamp(false); }
342
343protected:
345 ~vtkTexture() override;
346
347 // A texture is a sink, so there is no need to do anything.
348 // This definition avoids a warning when doing Update() on a vtkTexture object.
349 void ExecuteData(vtkDataObject*) override {}
350
351 bool Mipmap;
353 int Wrap;
354 float BorderColor[4];
361
364 // this is to duplicated the previous behavior of SelfCreatedLookUpTable
369
370 // the result of HasTranslucentPolygonalGeometry is cached
373
374private:
375 vtkTexture(const vtkTexture&) = delete;
376 void operator=(const vtkTexture&) = delete;
377};
378
379#endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:59
general representation of visualization data
Definition: vtkDataObject.h:69
Generic algorithm superclass for image algs.
topologically and geometrically regular array of data
Definition: vtkImageData.h:57
a simple class to control print indentation
Definition: vtkIndent.h:43
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:75
virtual vtkTypeBool GetRepeat()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:332
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.
vtkImageData * GetInput()
Get the input as a vtkImageData object.
~vtkTexture() override
void SetQualityToDefault()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:144
int ColorMode
Definition: vtkTexture.h:357
@ MirroredRepeat
Definition: vtkTexture.h:303
virtual void RepeatOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:334
void SetColorModeToDirectScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:164
vtkUnsignedCharArray * MappedScalars
Definition: vtkTexture.h:359
void SetQualityTo16Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:145
vtkTypeBool RestrictPowerOf2ImageSmaller
Definition: vtkTexture.h:363
virtual void Load(vtkRenderer *)
Abstract interface to renderer.
Definition: vtkTexture.h:106
bool UseSRGBColorSpace
Definition: vtkTexture.h:368
virtual void SetRepeat(vtkTypeBool r)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:331
int SelfAdjustingTableRange
Definition: vtkTexture.h:365
vtkTypeBool Interpolate
Definition: vtkTexture.h:355
static vtkTexture * New()
int BlendingMode
Definition: vtkTexture.h:362
float MaximumAnisotropicFiltering
Definition: vtkTexture.h:352
unsigned char * MapScalarsToColors(vtkDataArray *scalars)
Map scalar values into color scalars.
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:207
@ VTK_TEXTURE_BLENDING_MODE_MODULATE
Definition: vtkTexture.h:210
@ VTK_TEXTURE_BLENDING_MODE_ADD
Definition: vtkTexture.h:211
@ VTK_TEXTURE_BLENDING_MODE_REPLACE
Definition: vtkTexture.h:209
@ VTK_TEXTURE_BLENDING_MODE_INTERPOLATE
Definition: vtkTexture.h:213
@ VTK_TEXTURE_BLENDING_MODE_ADD_SIGNED
Definition: vtkTexture.h:212
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:340
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this texture.
Definition: vtkTexture.h:99
vtkTransform * Transform
Definition: vtkTexture.h:360
void SetQualityTo32Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:146
bool CubeMap
Definition: vtkTexture.h:367
virtual vtkTypeBool GetEdgeClamp()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:338
virtual void EdgeClampOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:339
bool PremultipliedAlpha
Definition: vtkTexture.h:366
virtual void RepeatOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:333
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:92
int TranslucentCachedResult
Definition: vtkTexture.h:372
void SetLookupTable(vtkScalarsToColors *)
Specify the lookup table to convert scalars if necessary.
vtkTimeStamp TranslucentComputationTime
Definition: vtkTexture.h:371
void ExecuteData(vtkDataObject *) override
This method is the old style execute method, provided for the sake of backwards compatibility with ol...
Definition: vtkTexture.h:349
virtual int GetTextureUnit()
Return the texture unit used for this texture.
Definition: vtkTexture.h:260
void SetColorModeToDefault()
Default: ColorModeToDefault.
Definition: vtkTexture.h:162
bool Mipmap
Definition: vtkTexture.h:351
void SetColorModeToMapScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:163
virtual void SetEdgeClamp(vtkTypeBool)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:335
vtkScalarsToColors * LookupTable
Definition: vtkTexture.h:358
record modification and/or execution time
Definition: vtkTimeStamp.h:42
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:64
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition: vtkWindow.h:45
@ 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:70
#define VTK_TEXTURE_QUALITY_32BIT
Definition: vtkTexture.h:72
#define VTK_TEXTURE_QUALITY_16BIT
Definition: vtkTexture.h:71