VTK  9.3.20240425
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
153VTK_ABI_NAMESPACE_BEGIN
154class vtkImageData;
156class vtkRenderer;
158class vtkWindow;
159class vtkDataArray;
160class vtkTransform;
161
162#define VTK_TEXTURE_QUALITY_DEFAULT 0
163#define VTK_TEXTURE_QUALITY_16BIT 16
164#define VTK_TEXTURE_QUALITY_32BIT 32
165
166class VTKRENDERINGCORE_EXPORT vtkTexture : public vtkImageAlgorithm
167{
168public:
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);
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); }
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); }
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
435protected:
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];
453
456 // this is to duplicated the previous behavior of SelfCreatedLookUpTable
461
462 // the result of HasTranslucentPolygonalGeometry is cached
465
466private:
467 vtkTexture(const vtkTexture&) = delete;
468 void operator=(const vtkTexture&) = delete;
469};
470
471VTK_ABI_NAMESPACE_END
472#endif
abstract superclass for arrays of numeric data
general representation of visualization data
Generic algorithm superclass for image algs.
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:108
abstract specification for renderers
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
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:236
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
static vtkTexture * New()
int BlendingMode
Definition vtkTexture.h:454
float MaximumAnisotropicFiltering
Definition vtkTexture.h:444
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: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
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
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
void SetColorModeToMapScalars()
Default: ColorModeToDefault.
Definition vtkTexture.h:255
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
describes linear transformations via a 4x4 matrix
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
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