VTK
vtkTextureObject.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTextureObject.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 =========================================================================*/
29 #ifndef vtkTextureObject_h
30 #define vtkTextureObject_h
31 
32 #include "vtkRenderingOpenGLModule.h" // For export macro
33 #include "vtkObject.h"
34 #include "vtkWeakPointer.h" // for render context
35 
36 class vtkFloatArray;
37 class vtkTextureObject;
38 class vtkRenderWindow;
42 
43 class VTKRENDERINGOPENGL_EXPORT vtkTextureObject : public vtkObject
44 {
45 public:
46 
47  // DepthTextureCompareFunction values.
48  enum
49  {
50  Lequal=0, // r=R<=Dt ? 1.0 : 0.0
51  Gequal, // r=R>=Dt ? 1.0 : 0.0
52  Less, // r=R<D_t ? 1.0 : 0.0
53  Greater, // r=R>Dt ? 1.0 : 0.0
54  Equal, // r=R==Dt ? 1.0 : 0.0
55  NotEqual, // r=R!=Dt ? 1.0 : 0.0
56  AlwaysTrue, // r=1.0 // WARNING "Always" is macro defined in X11/X.h...
57  Never, // r=0.0
58  NumberOfDepthTextureCompareFunctions
59  };
60 
61  // DepthTextureMode values.
62  enum
63  {
64  Luminance=0, // (R,G,B,A)=(r,r,r,1)
65  Intensity, // (R,G,B,A)=(r,r,r,r)
66  Alpha, // (R,G,B,A)=(0,0,0,r)
67  NumberOfDepthTextureModes
68  };
69 
70  // Wrap values.
71  enum
72  {
73  Clamp=0,
78  NumberOfWrapModes
79  };
80 
81  // MinificationFilter values.
82  enum
83  {
84  Nearest=0,
90  NumberOfMinificationModes
91  };
92 
93  // Internal depth format
94  enum
95  {
96  Native=0, // will try to match with the depth buffer format.
101  NumberOfDepthFormats
102  };
103 
105  vtkTypeMacro(vtkTextureObject, vtkObject);
106  void PrintSelf(ostream& os, vtkIndent indent);
107 
109 
118 
120 
124  vtkGetMacro(Width, unsigned int);
125  vtkGetMacro(Height, unsigned int);
126  vtkGetMacro(Depth, unsigned int);
127  vtkGetMacro(Components, int);
128  unsigned int GetTuples()
129  { return this->Width*this->Height*this->Depth; }
131 
132  vtkGetMacro(NumberOfDimensions, int);
133 
135 
138  vtkGetMacro(Target, unsigned int);
140 
142 
145  vtkGetMacro(Handle, unsigned int);
147 
149 
154  void Bind();
155  void UnBind();
157 
159 
162  void Activate(unsigned int texUnit);
163  void Deactivate(unsigned int texUnit);
165 
166 
171  bool IsBound();
172 
174 
181  vtkSetMacro(AutoParameters, int);
182  vtkGetMacro(AutoParameters, int);
184 
195  bool Create1D(int numComps,
197  bool shaderSupportsTextureInt);
198 
205  bool Create2D(unsigned int width, unsigned int height, int numComps,
207  bool shaderSupportsTextureInt);
208 
213  bool CreateDepth(unsigned int width,
214  unsigned int height,
215  int internalFormat,
216  vtkPixelBufferObject *pbo);
217 
222  bool CreateDepthFromRaw(unsigned int width,
223  unsigned int height,
224  int internalFormat,
225  int rawType,
226  void *raw);
227 
231  bool AllocateDepth(unsigned int width, unsigned int height,
232  int internalFormat);
233 
238  bool Allocate1D(unsigned int width, int numComps, int vtkType);
239 
244  bool Allocate2D(unsigned int width, unsigned int height, int numComps,
245  int vtkType);
246 
251  bool Allocate3D(unsigned int width, unsigned int height,
252  unsigned int depth, int numComps,
253  int vtkType);
254 
255 
262  bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
263  int numComps, vtkPixelBufferObject *pbo,
264  bool shaderSupportsTextureInt);
265 
266 
268 
273  bool Create2D(unsigned int width, unsigned int height, int numComps,
274  int vtktype,
275  bool shaderSupportsTextureInt);
276  bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
277  int numComps, int vtktype,
278  bool shaderSupportsTextureInt);
280 
288 
292  int GetDataType();
293 
294  unsigned int GetInternalFormat(int vtktype, int numComps,
295  bool shaderSupportsTextureInt);
296  unsigned int GetFormat(int vtktype, int numComps,
297  bool shaderSupportsTextureInt);
298 
300 
306  vtkSetMacro(RequireDepthBufferFloat, bool);
307  vtkGetMacro(RequireDepthBufferFloat, bool);
308  vtkGetMacro(SupportsDepthBufferFloat, bool);
310 
312 
318  vtkSetMacro(RequireTextureFloat, bool);
319  vtkGetMacro(RequireTextureFloat, bool);
320  vtkGetMacro(SupportsTextureFloat, bool);
322 
324 
330  vtkSetMacro(RequireTextureInteger, bool);
331  vtkGetMacro(RequireTextureInteger, bool);
332  vtkGetMacro(SupportsTextureInteger, bool);
334 
336 
346  vtkGetMacro(WrapS, int);
347  vtkSetMacro(WrapS, int);
349 
351 
361  vtkGetMacro(WrapT, int);
362  vtkSetMacro(WrapT, int);
364 
366 
376  vtkGetMacro(WrapR, int);
377  vtkSetMacro(WrapR, int);
379 
381 
394  vtkGetMacro(MinificationFilter, int);
395  vtkSetMacro(MinificationFilter, int);
397 
399 
406  vtkGetMacro(MagnificationFilter, int);
407  vtkSetMacro(MagnificationFilter, int);
409 
414  void SetLinearMagnification(bool val)
415  { this->SetMagnificationFilter(val?Linear:Nearest); }
416 
418  { return this->MagnificationFilter==Linear; }
419 
421 
426  vtkSetVector4Macro(BorderColor, float);
427  vtkGetVector4Macro(BorderColor, float);
429 
431 
436  vtkSetMacro(Priority, float);
437  vtkGetMacro(Priority, float);
439 
441 
445  vtkSetMacro(MinLOD, float);
446  vtkGetMacro(MinLOD, float);
448 
450 
454  vtkSetMacro(MaxLOD, float);
455  vtkGetMacro(MaxLOD, float);
457 
459 
464  vtkSetMacro(BaseLevel, int);
465  vtkGetMacro(BaseLevel, int);
467 
469 
474  vtkSetMacro(MaxLevel, int);
475  vtkGetMacro(MaxLevel, int);
477 
479 
489  vtkGetMacro(DepthTextureCompare, bool);
490  vtkSetMacro(DepthTextureCompare, bool);
492 
494 
514  vtkGetMacro(DepthTextureCompareFunction, int);
515  vtkSetMacro(DepthTextureCompareFunction, int);
517 
519 
528  vtkGetMacro(DepthTextureMode, int);
529  vtkSetMacro(DepthTextureMode, int);
531 
533 
538  vtkGetMacro(GenerateMipmap, bool);
539  vtkSetMacro(GenerateMipmap, bool);
541 
547  static bool IsSupported(
548  vtkRenderWindow* renWin,
549  bool requireTexFloat,
550  bool requireDepthFloat,
551  bool requireTexInt);
552 
556  static bool IsSupported(vtkRenderWindow* renWin)
557  { return vtkTextureObject::IsSupported(renWin, false, false, false); }
558 
585  void CopyToFrameBuffer(int srcXmin,
586  int srcYmin,
587  int srcXmax,
588  int srcYmax,
589  int dstXmin,
590  int dstYmin,
591  int width,
592  int height);
593 
594 
606  void CopyFromFrameBuffer(int srcXmin,
607  int srcYmin,
608  int dstXmin,
609  int dstYmin,
610  int width,
611  int height);
612 
613 protected:
616 
621 
626 
631 
633  unsigned int Width;
634  unsigned int Height;
635  unsigned int Depth;
636 
637  unsigned int Target; // GLenum
638  unsigned int Format; // GLenum
639  unsigned int Type; // GLenum
641 
643  unsigned int Handle;
650 
651  int WrapS;
652  int WrapT;
653  int WrapR;
657  float BorderColor[4];
658 
659  float Priority;
660  float MinLOD;
661  float MaxLOD;
663  int MaxLevel;
664 
665 
669 
671 
674 
675 private:
676  vtkTextureObject(const vtkTextureObject&) VTK_DELETE_FUNCTION;
677  void operator=(const vtkTextureObject&) VTK_DELETE_FUNCTION;
678 
679 };
680 
681 #endif
vtkTextureObject::Allocate2D
bool Allocate2D(unsigned int width, unsigned int height, int numComps, int vtkType)
Create a 2D color texture but does not initialize its values.
vtkTextureObject::DepthTextureCompare
bool DepthTextureCompare
Definition: vtkTextureObject.h:666
vtkTextureObject::Intensity
@ Intensity
Definition: vtkTextureObject.h:65
vtkTextureObject::Equal
@ Equal
Definition: vtkTextureObject.h:54
vtkTextureObject::Create1D
bool Create1D(int numComps, vtkPixelBufferObject *pbo, bool shaderSupportsTextureInt)
Create a 1D texture using the PBO.
vtkTextureObject::Create3D
bool Create3D(unsigned int width, unsigned int height, unsigned int depth, int numComps, int vtktype, bool shaderSupportsTextureInt)
vtkTextureObject::Depth
unsigned int Depth
Definition: vtkTextureObject.h:635
vtkTextureObject::IsSupported
static bool IsSupported(vtkRenderWindow *renWin)
Check for feature support, without any optional features.
Definition: vtkTextureObject.h:556
vtkTextureObject::NumberOfDimensions
int NumberOfDimensions
Definition: vtkTextureObject.h:632
vtkTextureObject::LinearMagnification
bool LinearMagnification
Definition: vtkTextureObject.h:656
vtkTextureObject::SendParametersTime
vtkTimeStamp SendParametersTime
Definition: vtkTextureObject.h:673
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:42
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:36
vtkTextureObject::Download
vtkPixelBufferObject * Download()
This is used to download raw data from the texture into a pixel bufer.
vtkTextureObject::RequireTextureFloat
bool RequireTextureFloat
Definition: vtkTextureObject.h:646
vtkTextureObject::Target
unsigned int Target
Definition: vtkTextureObject.h:637
vtkTextureObject::WrapR
int WrapR
Definition: vtkTextureObject.h:653
vtkTextureObject::NotEqual
@ NotEqual
Definition: vtkTextureObject.h:55
vtkTextureObject::MagnificationFilter
int MagnificationFilter
Definition: vtkTextureObject.h:655
vtkTextureObject::Float32
@ Float32
Definition: vtkTextureObject.h:100
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkTextureObject::GenerateMipmap
bool GenerateMipmap
Definition: vtkTextureObject.h:670
vtkTextureObject::SupportsTextureInteger
bool SupportsTextureInteger
Definition: vtkTextureObject.h:645
vtkTextureObject::SupportsDepthBufferFloat
bool SupportsDepthBufferFloat
Definition: vtkTextureObject.h:649
vtkTextureObject::Alpha
@ Alpha
Definition: vtkTextureObject.h:66
vtkTextureObject::GetFormat
unsigned int GetFormat(int vtktype, int numComps, bool shaderSupportsTextureInt)
vtkTextureObject::AllocateDepth
bool AllocateDepth(unsigned int width, unsigned int height, int internalFormat)
Create a 2D depth texture but does not initialize its values.
vtkTextureObject::LinearMipmapNearest
@ LinearMipmapNearest
Definition: vtkTextureObject.h:88
vtkTextureObject::Activate
void Activate(unsigned int texUnit)
Set the active tex unit and bind (using our bind).
vtkTextureObject::GetLinearMagnification
bool GetLinearMagnification()
Definition: vtkTextureObject.h:417
vtkTextureObject::vtkTextureObject
vtkTextureObject()
vtkTextureObject::Context
vtkWeakPointer< vtkRenderWindow > Context
Definition: vtkTextureObject.h:642
vtkTextureObject::Fixed32
@ Fixed32
Definition: vtkTextureObject.h:99
vtkTextureObject::MaxLevel
int MaxLevel
Definition: vtkTextureObject.h:663
vtkTextureObject::CreateDepth
bool CreateDepth(unsigned int width, unsigned int height, int internalFormat, vtkPixelBufferObject *pbo)
Create a 2D depth texture using a PBO.
vtkTextureObject::GetInternalFormat
unsigned int GetInternalFormat(int vtktype, int numComps, bool shaderSupportsTextureInt)
vtkTextureObject::AlwaysTrue
@ AlwaysTrue
Definition: vtkTextureObject.h:56
vtkTextureObject::NearestMipmapLinear
@ NearestMipmapLinear
Definition: vtkTextureObject.h:87
vtkTextureObject::Priority
float Priority
Definition: vtkTextureObject.h:659
vtkTextureObject::Repeat
@ Repeat
Definition: vtkTextureObject.h:75
vtkTextureObject::MinificationFilter
int MinificationFilter
Definition: vtkTextureObject.h:654
vtkTextureObject::GetTuples
unsigned int GetTuples()
Definition: vtkTextureObject.h:128
vtkTextureObject::RequireDepthBufferFloat
bool RequireDepthBufferFloat
Definition: vtkTextureObject.h:648
vtkOpenGLExtensionManager
Interface class for querying and using OpenGL extensions.
vtkTextureObject::NearestMipmapNearest
@ NearestMipmapNearest
Definition: vtkTextureObject.h:86
vtkTextureObject::CreateTexture
void CreateTexture()
Creates a texture handle if not already created.
vtkX3D::height
@ height
Definition: vtkX3D.h:254
vtkTextureObject::SetContext
void SetContext(vtkRenderWindow *)
Get/Set the context.
vtkTextureObject::Linear
@ Linear
Definition: vtkTextureObject.h:85
vtkTextureObject::LoadRequiredExtensions
bool LoadRequiredExtensions(vtkRenderWindow *renWin)
Load all necessary extensions.
vtkTextureObject::Components
int Components
Definition: vtkTextureObject.h:640
vtkTextureObject::ClampToBorder
@ ClampToBorder
Definition: vtkTextureObject.h:76
vtkTextureObject::RequireTextureInteger
bool RequireTextureInteger
Definition: vtkTextureObject.h:644
vtkTextureObject::Create2D
bool Create2D(unsigned int width, unsigned int height, int numComps, int vtktype, bool shaderSupportsTextureInt)
Create texture without uploading any data.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkTextureObject
abstracts an OpenGL texture object.
Definition: vtkTextureObject.h:44
vtkTextureObject::~vtkTextureObject
~vtkTextureObject()
vtkTextureObject::New
static vtkTextureObject * New()
vtkTextureObject::Width
unsigned int Width
Definition: vtkTextureObject.h:633
vtkTextureObject::CopyFromFrameBuffer
void CopyFromFrameBuffer(int srcXmin, int srcYmin, int dstXmin, int dstYmin, int width, int height)
Copy a sub-part of a logical buffer of the framebuffer (color or depth) to the texture object.
vtkTextureObject::LinearMipmapLinear
@ LinearMipmapLinear
Definition: vtkTextureObject.h:89
vtkTextureObject::Create3D
bool Create3D(unsigned int width, unsigned int height, unsigned int depth, int numComps, vtkPixelBufferObject *pbo, bool shaderSupportsTextureInt)
Create a 3D texture using the PBO.
vtkWeakPointer.h
vtkTextureObject::CopyToFrameBuffer
void CopyToFrameBuffer(int srcXmin, int srcYmin, int srcXmax, int srcYmax, int dstXmin, int dstYmin, int width, int height)
Copy a sub-part of the texture (src) in the current framebuffer at location (dstXmin,...
vtkTextureObject::Deactivate
void Deactivate(unsigned int texUnit)
vtkTextureObject::Allocate1D
bool Allocate1D(unsigned int width, int numComps, int vtkType)
Create a 1D color texture but does not initialize its values.
vtkTextureObject::MirroredRepeat
@ MirroredRepeat
Definition: vtkTextureObject.h:77
vtkObject.h
vtkTextureObject::MaxLOD
float MaxLOD
Definition: vtkTextureObject.h:661
vtkTextureObject::ClampToEdge
@ ClampToEdge
Definition: vtkTextureObject.h:74
vtkTextureObject::SendParameters
void SendParameters()
Send all the texture object parameters to the hardware if not done yet.
vtkTextureObject::Fixed24
@ Fixed24
Definition: vtkTextureObject.h:98
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkTextureObject::GetContext
vtkRenderWindow * GetContext()
vtkTextureObject::Gequal
@ Gequal
Definition: vtkTextureObject.h:51
vtkTextureObject::Allocate3D
bool Allocate3D(unsigned int width, unsigned int height, unsigned int depth, int numComps, int vtkType)
Create a 3D color texture but does not initialize its values.
vtkTextureObject::Never
@ Never
Definition: vtkTextureObject.h:57
vtkTextureObject::GetDataType
int GetDataType()
Get the data type for the texture as a vtk type int i.e.
vtkTextureObject::Create2D
bool Create2D(unsigned int width, unsigned int height, int numComps, vtkPixelBufferObject *pbo, bool shaderSupportsTextureInt)
Create a 2D texture using the PBO.
vtkTextureObject::Less
@ Less
Definition: vtkTextureObject.h:52
vtkTextureObject::SupportsTextureFloat
bool SupportsTextureFloat
Definition: vtkTextureObject.h:647
vtkTextureObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkTextureObject::WrapS
int WrapS
Definition: vtkTextureObject.h:651
vtkTextureObject::Handle
unsigned int Handle
Definition: vtkTextureObject.h:643
vtkTextureObject::IsBound
bool IsBound()
Tells if the texture object is bound to the active texture image unit.
vtkTextureObject::AutoParameters
int AutoParameters
Definition: vtkTextureObject.h:672
vtkTextureObject::Height
unsigned int Height
Definition: vtkTextureObject.h:634
vtkTextureObject::Fixed16
@ Fixed16
Definition: vtkTextureObject.h:97
vtkTextureObject::CreateDepthFromRaw
bool CreateDepthFromRaw(unsigned int width, unsigned int height, int internalFormat, int rawType, void *raw)
Create a 2D depth texture using a raw pointer.
vtkTextureObject::Format
unsigned int Format
Definition: vtkTextureObject.h:638
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:42
vtkTextureObject::Bind
void Bind()
Activate the texture.
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:87
vtkTextureObject::UnBind
void UnBind()
vtkTextureObject::WrapT
int WrapT
Definition: vtkTextureObject.h:652
vtkTextureObject::SetLinearMagnification
void SetLinearMagnification(bool val)
Tells if the magnification mode is linear (true) or nearest (false).
Definition: vtkTextureObject.h:414
vtkTextureObject::DestroyTexture
void DestroyTexture()
Destroy the texture.
vtkTextureObject::DepthTextureCompareFunction
int DepthTextureCompareFunction
Definition: vtkTextureObject.h:667
vtkTextureObject::DepthTextureMode
int DepthTextureMode
Definition: vtkTextureObject.h:668
vtkTextureObject::BaseLevel
int BaseLevel
Definition: vtkTextureObject.h:662
vtkTextureObject::Type
unsigned int Type
Definition: vtkTextureObject.h:639
vtkPixelBufferObject
abstracts an OpenGL pixel buffer object.
Definition: vtkPixelBufferObject.h:44
vtkWeakPointer< vtkRenderWindow >
vtkTextureObject::IsSupported
static bool IsSupported(vtkRenderWindow *renWin, bool requireTexFloat, bool requireDepthFloat, bool requireTexInt)
Returns if the context supports the required extensions.
vtkTextureObject::MinLOD
float MinLOD
Definition: vtkTextureObject.h:660
vtkTextureObject::Greater
@ Greater
Definition: vtkTextureObject.h:53