VTK  9.7.1
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 #include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
44 
45 VTK_ABI_NAMESPACE_BEGIN
46 class vtkImageData;
47 class vtkScalarsToColors;
48 class vtkRenderer;
50 class vtkWindow;
51 class vtkDataArray;
52 class vtkTransform;
53 
54 #define VTK_TEXTURE_QUALITY_DEFAULT 0
55 #define VTK_TEXTURE_QUALITY_16BIT 16
56 #define VTK_TEXTURE_QUALITY_32BIT 32
57 
58 class VTKRENDERINGCORE_EXPORT VTK_MARSHALMANUAL vtkTexture : public vtkImageAlgorithm
59 {
60 public:
61  static vtkTexture* New();
62  vtkTypeMacro(vtkTexture, vtkImageAlgorithm);
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
70  virtual void Render(vtkRenderer* ren);
71 
76  virtual void PostRender(vtkRenderer*) {}
77 
84 
90  virtual void Load(vtkRenderer*) {}
91 
93 
96  vtkGetMacro(Interpolate, vtkTypeBool);
97  vtkSetMacro(Interpolate, vtkTypeBool);
98  vtkBooleanMacro(Interpolate, vtkTypeBool);
100 
102 
105  vtkGetMacro(Mipmap, bool);
106  vtkSetMacro(Mipmap, bool);
107  vtkBooleanMacro(Mipmap, bool);
109 
111 
117  vtkSetMacro(MaximumAnisotropicFiltering, float);
118  vtkGetMacro(MaximumAnisotropicFiltering, float);
120 
122 
126  vtkSetMacro(Quality, int);
127  vtkGetMacro(Quality, int);
128  void SetQualityToDefault() { this->SetQuality(VTK_TEXTURE_QUALITY_DEFAULT); }
129  void SetQualityTo16Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_16BIT); }
130  void SetQualityTo32Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
132 
134 
144  vtkSetMacro(ColorMode, int);
145  vtkGetMacro(ColorMode, int);
146  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
147  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
150 
156 
158 
161  void SetLookupTable(vtkScalarsToColors*);
162  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
164 
166 
169  vtkGetObjectMacro(MappedScalars, vtkUnsignedCharArray);
171 
175  unsigned char* MapScalarsToColors(vtkDataArray* scalars);
176 
178 
182  void SetTransform(vtkTransform* transform);
183  vtkGetObjectMacro(Transform, vtkTransform);
185 
191  {
192  VTK_TEXTURE_BLENDING_MODE_NONE = 0,
198  VTK_TEXTURE_BLENDING_MODE_SUBTRACT
199  };
200 
202 
206  vtkGetMacro(BlendingMode, int);
207  vtkSetMacro(BlendingMode, int);
209 
211 
215  vtkGetMacro(PremultipliedAlpha, bool);
216  vtkSetMacro(PremultipliedAlpha, bool);
217  vtkBooleanMacro(PremultipliedAlpha, bool);
219 
221 
228  vtkGetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
229  vtkSetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
230  vtkBooleanMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
232 
239  virtual int IsTranslucent();
240 
244  virtual int GetTextureUnit() { return 0; }
245 
247 
253  vtkGetMacro(CubeMap, bool);
254  vtkBooleanMacro(CubeMap, bool);
255  void SetCubeMap(bool val);
257 
259 
265  vtkGetMacro(UseSRGBColorSpace, bool);
266  vtkSetMacro(UseSRGBColorSpace, bool);
267  vtkBooleanMacro(UseSRGBColorSpace, bool);
269 
271 
279  vtkSetVector4Macro(BorderColor, float);
280  vtkGetVector4Macro(BorderColor, float);
282 
283  enum
284  {
285  ClampToEdge = 0,
289  NumberOfWrapModes
290  };
291 
293 
306  vtkGetMacro(Wrap, int);
307  vtkSetClampMacro(Wrap, int, ClampToEdge, ClampToBorder);
309 
311 
315  virtual void SetRepeat(vtkTypeBool r) { this->SetWrap(r ? Repeat : ClampToEdge); }
316  virtual vtkTypeBool GetRepeat() { return (this->GetWrap() == Repeat); }
317  virtual void RepeatOn() { this->SetRepeat(true); }
318  virtual void RepeatOff() { this->SetRepeat(false); }
319  virtual void SetEdgeClamp(vtkTypeBool) { /* This wasn't doing anything before. */ }
320  virtual vtkTypeBool GetEdgeClamp() { return (this->GetWrap() == ClampToEdge); }
321  virtual void EdgeClampOn() { this->SetEdgeClamp(true); }
322  virtual void EdgeClampOff() { this->SetEdgeClamp(false); }
324 
325 protected:
326  vtkTexture();
327  ~vtkTexture() override;
328 
329  // A texture is a sink, so there is no need to do anything.
330  // This definition avoids a warning when doing Update() on a vtkTexture object.
331  void ExecuteData(vtkDataObject*) override {}
332 
333  bool Mipmap;
335  int Wrap;
336  float BorderColor[4];
338  int Quality;
343 
346  // this is to duplicated the previous behavior of SelfCreatedLookUpTable
349  bool CubeMap;
351 
352  // the result of HasTranslucentPolygonalGeometry is cached
355 
356 private:
357  vtkTexture(const vtkTexture&) = delete;
358  void operator=(const vtkTexture&) = delete;
359 };
360 
361 VTK_ABI_NAMESPACE_END
362 #endif
float MaximumAnisotropicFiltering
Definition: vtkTexture.h:334
#define VTK_COLOR_MODE_DIRECT_SCALARS
virtual void PostRender(vtkRenderer *)
Cleans up after the texture rendering to restore the state of the graphics context.
Definition: vtkTexture.h:76
VTKTextureBlendingMode
Used to specify how the texture will blend its RGB and Alpha values with other textures and the fragm...
Definition: vtkTexture.h:190
#define VTK_TEXTURE_QUALITY_16BIT
Definition: vtkTexture.h:55
void SetQualityTo16Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:129
void SetColorModeToDirectScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:148
virtual void SetRepeat(vtkTypeBool r)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:315
virtual void EdgeClampOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:322
record modification and/or execution time
Definition: vtkTimeStamp.h:24
vtkScalarsToColors * LookupTable
Definition: vtkTexture.h:340
int TranslucentCachedResult
Definition: vtkTexture.h:354
bool PremultipliedAlpha
Definition: vtkTexture.h:348
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this texture.
Definition: vtkTexture.h:83
vtkDataObject * GetInput()
Get a data object for one of the input port connections.
abstract specification for renderers
Definition: vtkRenderer.h:63
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
virtual void RepeatOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:317
virtual void EdgeClampOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:321
virtual void SetEdgeClamp(vtkTypeBool)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:319
int ColorMode
Definition: vtkTexture.h:339
virtual void Load(vtkRenderer *)
Abstract interface to renderer.
Definition: vtkTexture.h:90
#define VTK_TEXTURE_QUALITY_DEFAULT
Definition: vtkTexture.h:54
int vtkTypeBool
Definition: vtkABI.h:64
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
virtual void RepeatOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:318
#define VTK_COLOR_MODE_MAP_SCALARS
#define VTK_MARSHALMANUAL
bool CubeMap
Definition: vtkTexture.h:349
virtual vtkTypeBool GetEdgeClamp()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:320
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkTransform * Transform
Definition: vtkTexture.h:342
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkTimeStamp TranslucentComputationTime
Definition: vtkTexture.h:353
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
bool Mipmap
Definition: vtkTexture.h:333
handles properties associated with a texture map
Definition: vtkTexture.h:58
void SetQualityToDefault()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:128
#define VTK_COLOR_MODE_DEFAULT
void SetColorModeToMapScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:147
vtkUnsignedCharArray * MappedScalars
Definition: vtkTexture.h:341
dynamic, self-adjusting array of unsigned char
virtual int GetTextureUnit()
Return the texture unit used for this texture.
Definition: vtkTexture.h:244
int SelfAdjustingTableRange
Definition: vtkTexture.h:347
void SetQualityTo32Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:130
void ExecuteData(vtkDataObject *) override
This method is the old style execute method, provided for the sake of backwards compatibility with ol...
Definition: vtkTexture.h:331
vtkTypeBool RestrictPowerOf2ImageSmaller
Definition: vtkTexture.h:345
Generic algorithm superclass for image algs.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_TEXTURE_QUALITY_32BIT
Definition: vtkTexture.h:56
vtkTypeBool Interpolate
Definition: vtkTexture.h:337
general representation of visualization data
Definition: vtkDataObject.h:55
virtual vtkTypeBool GetRepeat()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:316
int BlendingMode
Definition: vtkTexture.h:344
void SetColorModeToDefault()
Default: ColorModeToDefault.
Definition: vtkTexture.h:146
bool UseSRGBColorSpace
Definition: vtkTexture.h:350