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 
104  static vtkTextureObject* New();
105  vtkTypeMacro(vtkTextureObject, vtkObject);
106  void PrintSelf(ostream& os, vtkIndent indent);
107 
109 
115  void SetContext(vtkRenderWindow*);
116  vtkRenderWindow* GetContext();
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 
180  void SendParameters();
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 
287  vtkPixelBufferObject* Download();
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:
615  ~vtkTextureObject();
616 
620  bool LoadRequiredExtensions(vtkRenderWindow *renWin);
621 
625  void CreateTexture();
626 
630  void DestroyTexture();
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::DepthTextureCompare
bool DepthTextureCompare
Definition: vtkTextureObject.h:666
vtkTextureObject::Intensity
Definition: vtkTextureObject.h:65
vtkTextureObject::Equal
Definition: vtkTextureObject.h:54
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:41
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:35
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
Definition: vtkTextureObject.h:55
vtkTextureObject::MagnificationFilter
int MagnificationFilter
Definition: vtkTextureObject.h:655
vtkTextureObject::Float32
Definition: vtkTextureObject.h:100
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:59
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
Definition: vtkTextureObject.h:66
vtkTextureObject::LinearMipmapNearest
Definition: vtkTextureObject.h:88
vtkTextureObject::GetLinearMagnification
bool GetLinearMagnification()
Definition: vtkTextureObject.h:417
vtkTextureObject::Context
vtkWeakPointer< vtkRenderWindow > Context
Definition: vtkTextureObject.h:642
vtkTextureObject::Fixed32
Definition: vtkTextureObject.h:99
vtkTextureObject::MaxLevel
int MaxLevel
Definition: vtkTextureObject.h:663
vtkTextureObject::AlwaysTrue
Definition: vtkTextureObject.h:56
vtkTextureObject::NearestMipmapLinear
Definition: vtkTextureObject.h:87
vtkTextureObject::Priority
float Priority
Definition: vtkTextureObject.h:659
vtkTextureObject::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
Definition: vtkTextureObject.h:86
vtkX3D::height
Definition: vtkX3D.h:254
vtkTextureObject::Linear
Definition: vtkTextureObject.h:85
vtkTextureObject::Components
int Components
Definition: vtkTextureObject.h:640
vtkTextureObject::ClampToBorder
Definition: vtkTextureObject.h:76
vtkTextureObject::RequireTextureInteger
bool RequireTextureInteger
Definition: vtkTextureObject.h:644
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkTextureObject
abstracts an OpenGL texture object.
Definition: vtkTextureObject.h:43
vtkTextureObject::Width
unsigned int Width
Definition: vtkTextureObject.h:633
vtkTextureObject::LinearMipmapLinear
Definition: vtkTextureObject.h:89
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkWeakPointer.h
vtkTextureObject::MirroredRepeat
Definition: vtkTextureObject.h:77
vtkObject.h
vtkTextureObject::MaxLOD
float MaxLOD
Definition: vtkTextureObject.h:661
vtkTextureObject::ClampToEdge
Definition: vtkTextureObject.h:74
vtkTextureObject::Fixed24
Definition: vtkTextureObject.h:98
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkTextureObject::Gequal
Definition: vtkTextureObject.h:51
vtkTextureObject::Never
Definition: vtkTextureObject.h:57
vtkTextureObject::Less
Definition: vtkTextureObject.h:52
vtkTextureObject::SupportsTextureFloat
bool SupportsTextureFloat
Definition: vtkTextureObject.h:647
vtkTextureObject::WrapS
int WrapS
Definition: vtkTextureObject.h:651
vtkTextureObject::Handle
unsigned int Handle
Definition: vtkTextureObject.h:643
vtkTextureObject::AutoParameters
int AutoParameters
Definition: vtkTextureObject.h:672
vtkTextureObject::Height
unsigned int Height
Definition: vtkTextureObject.h:634
vtkTextureObject::Fixed16
Definition: vtkTextureObject.h:97
vtkTextureObject::Format
unsigned int Format
Definition: vtkTextureObject.h:638
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:41
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:86
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::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:43
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
Definition: vtkTextureObject.h:53