VTK  9.3.20240418
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
146 #ifndef vtkTexture_h
147 #define vtkTexture_h
148 
149 #include "vtkImageAlgorithm.h"
150 #include "vtkRenderingCoreModule.h" // For export macro
151 #include "vtkSystemIncludes.h" // For VTK_COLOR_MODE_*
152 
153 VTK_ABI_NAMESPACE_BEGIN
154 class vtkImageData;
155 class vtkScalarsToColors;
156 class vtkRenderer;
158 class vtkWindow;
159 class vtkDataArray;
160 class vtkTransform;
161 
162 #define VTK_TEXTURE_QUALITY_DEFAULT 0
163 #define VTK_TEXTURE_QUALITY_16BIT 16
164 #define VTK_TEXTURE_QUALITY_32BIT 32
165 
166 class VTKRENDERINGCORE_EXPORT vtkTexture : public vtkImageAlgorithm
167 {
168 public:
169  static vtkTexture* New();
171  void PrintSelf(ostream& os, vtkIndent indent) override;
172 
178  virtual void Render(vtkRenderer* ren);
179 
184  virtual void PostRender(vtkRenderer*) {}
185 
192 
198  virtual void Load(vtkRenderer*) {}
199 
201 
204  vtkGetMacro(Interpolate, vtkTypeBool);
205  vtkSetMacro(Interpolate, vtkTypeBool);
206  vtkBooleanMacro(Interpolate, vtkTypeBool);
208 
210 
213  vtkGetMacro(Mipmap, bool);
214  vtkSetMacro(Mipmap, bool);
215  vtkBooleanMacro(Mipmap, bool);
217 
219 
225  vtkSetMacro(MaximumAnisotropicFiltering, float);
226  vtkGetMacro(MaximumAnisotropicFiltering, float);
228 
230 
234  vtkSetMacro(Quality, int);
235  vtkGetMacro(Quality, int);
236  void SetQualityToDefault() { this->SetQuality(VTK_TEXTURE_QUALITY_DEFAULT); }
237  void SetQualityTo16Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_16BIT); }
238  void SetQualityTo32Bit() { this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
240 
242 
252  vtkSetMacro(ColorMode, int);
253  vtkGetMacro(ColorMode, int);
254  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
255  void SetColorModeToMapScalars() { this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
258 
264 
266 
270  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
272 
274 
277  vtkGetObjectMacro(MappedScalars, vtkUnsignedCharArray);
279 
283  unsigned char* MapScalarsToColors(vtkDataArray* scalars);
284 
286 
290  void SetTransform(vtkTransform* transform);
291  vtkGetObjectMacro(Transform, vtkTransform);
293 
299  {
300  VTK_TEXTURE_BLENDING_MODE_NONE = 0,
306  VTK_TEXTURE_BLENDING_MODE_SUBTRACT
307  };
308 
310 
314  vtkGetMacro(BlendingMode, int);
315  vtkSetMacro(BlendingMode, int);
317 
319 
323  vtkGetMacro(PremultipliedAlpha, bool);
324  vtkSetMacro(PremultipliedAlpha, bool);
325  vtkBooleanMacro(PremultipliedAlpha, bool);
327 
329 
336  vtkGetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
337  vtkSetMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
338  vtkBooleanMacro(RestrictPowerOf2ImageSmaller, vtkTypeBool);
340 
347  virtual int IsTranslucent();
348 
352  virtual int GetTextureUnit() { return 0; }
353 
355 
361  vtkGetMacro(CubeMap, bool);
362  vtkBooleanMacro(CubeMap, bool);
363  void SetCubeMap(bool val);
365 
367 
373  vtkGetMacro(UseSRGBColorSpace, bool);
374  vtkSetMacro(UseSRGBColorSpace, bool);
375  vtkBooleanMacro(UseSRGBColorSpace, bool);
377 
379 
387  vtkSetVector4Macro(BorderColor, float);
388  vtkGetVector4Macro(BorderColor, float);
390 
391  enum
392  {
393  ClampToEdge = 0,
397  NumberOfWrapModes
398  };
399 
401 
414  vtkGetMacro(Wrap, int);
415  vtkSetClampMacro(Wrap, int, ClampToEdge, ClampToBorder);
417 
419 
423  virtual void SetRepeat(vtkTypeBool r) { this->SetWrap(r ? Repeat : ClampToEdge); }
424  virtual vtkTypeBool GetRepeat() { return (this->GetWrap() == Repeat); }
425  virtual void RepeatOn() { this->SetRepeat(true); }
426  virtual void RepeatOff() { this->SetRepeat(false); }
427  virtual void SetEdgeClamp(vtkTypeBool)
428  { /* This wasn't doing anything before. */
429  }
430  virtual vtkTypeBool GetEdgeClamp() { return (this->GetWrap() == ClampToEdge); }
431  virtual void EdgeClampOn() { this->SetEdgeClamp(true); }
432  virtual void EdgeClampOff() { this->SetEdgeClamp(false); }
434 
435 protected:
437  ~vtkTexture() override;
438 
439  // A texture is a sink, so there is no need to do anything.
440  // This definition avoids a warning when doing Update() on a vtkTexture object.
441  void ExecuteData(vtkDataObject*) override {}
442 
443  bool Mipmap;
445  int Wrap;
446  float BorderColor[4];
448  int Quality;
453 
456  // this is to duplicated the previous behavior of SelfCreatedLookUpTable
459  bool CubeMap;
461 
462  // the result of HasTranslucentPolygonalGeometry is cached
465 
466 private:
467  vtkTexture(const vtkTexture&) = delete;
468  void operator=(const vtkTexture&) = delete;
469 };
470 
471 VTK_ABI_NAMESPACE_END
472 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:155
general representation of visualization data
Generic algorithm superclass for image algs.
topologically and geometrically regular array of data
Definition: vtkImageData.h:156
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract specification for renderers
Definition: vtkRenderer.h:172
Superclass for mapping scalar values to colors.
handles properties associated with a texture map
Definition: vtkTexture.h:167
virtual vtkTypeBool GetRepeat()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:424
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:236
int ColorMode
Definition: vtkTexture.h:449
virtual void RepeatOff()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:426
void SetColorModeToDirectScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:256
vtkUnsignedCharArray * MappedScalars
Definition: vtkTexture.h:451
void SetQualityTo16Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:237
vtkTypeBool RestrictPowerOf2ImageSmaller
Definition: vtkTexture.h:455
virtual void Load(vtkRenderer *)
Abstract interface to renderer.
Definition: vtkTexture.h:198
bool UseSRGBColorSpace
Definition: vtkTexture.h:460
virtual void SetRepeat(vtkTypeBool r)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:423
int SelfAdjustingTableRange
Definition: vtkTexture.h:457
vtkTypeBool Interpolate
Definition: vtkTexture.h:447
int BlendingMode
Definition: vtkTexture.h:454
float MaximumAnisotropicFiltering
Definition: vtkTexture.h:444
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:299
@ VTK_TEXTURE_BLENDING_MODE_MODULATE
Definition: vtkTexture.h:302
@ VTK_TEXTURE_BLENDING_MODE_ADD
Definition: vtkTexture.h:303
@ VTK_TEXTURE_BLENDING_MODE_REPLACE
Definition: vtkTexture.h:301
@ VTK_TEXTURE_BLENDING_MODE_INTERPOLATE
Definition: vtkTexture.h:305
@ VTK_TEXTURE_BLENDING_MODE_ADD_SIGNED
Definition: vtkTexture.h:304
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:432
virtual void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this texture.
Definition: vtkTexture.h:191
vtkTransform * Transform
Definition: vtkTexture.h:452
void SetQualityTo32Bit()
Force texture quality to 16-bit or 32-bit.
Definition: vtkTexture.h:238
bool CubeMap
Definition: vtkTexture.h:459
virtual vtkTypeBool GetEdgeClamp()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:430
virtual void EdgeClampOn()
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:431
bool PremultipliedAlpha
Definition: vtkTexture.h:458
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:425
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:184
int TranslucentCachedResult
Definition: vtkTexture.h:464
void SetLookupTable(vtkScalarsToColors *)
Specify the lookup table to convert scalars if necessary.
vtkTimeStamp TranslucentComputationTime
Definition: vtkTexture.h:463
void ExecuteData(vtkDataObject *) override
This method is the old style execute method, provided for the sake of backwards compatibility with ol...
Definition: vtkTexture.h:441
virtual int GetTextureUnit()
Return the texture unit used for this texture.
Definition: vtkTexture.h:352
void SetColorModeToDefault()
Default: ColorModeToDefault.
Definition: vtkTexture.h:254
bool Mipmap
Definition: vtkTexture.h:443
void SetColorModeToMapScalars()
Default: ColorModeToDefault.
Definition: vtkTexture.h:255
@ MirroredRepeat
Definition: vtkTexture.h:395
virtual void SetEdgeClamp(vtkTypeBool)
Convenience functions to maintain backwards compatibility.
Definition: vtkTexture.h:427
vtkScalarsToColors * LookupTable
Definition: vtkTexture.h:450
record modification and/or execution time
Definition: vtkTimeStamp.h:44
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:160
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition: vtkWindow.h:48
@ 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:162
#define VTK_TEXTURE_QUALITY_32BIT
Definition: vtkTexture.h:164
#define VTK_TEXTURE_QUALITY_16BIT
Definition: vtkTexture.h:163