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) override;
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() override;
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&) = delete;
677  void operator=(const vtkTextureObject&) = delete;
678 
679 };
680 
681 #endif
OpenGL rendering window.
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
unsigned int Format
unsigned int Handle
unsigned int GetTuples()
Get the texture dimensions.
vtkWeakPointer< vtkRenderWindow > Context
record modification and/or execution time
Definition: vtkTimeStamp.h:35
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
static bool IsSupported(vtkRenderWindow *renWin, bool requireTexFloat, bool requireDepthFloat, bool requireTexInt)
Returns if the context supports the required extensions.
unsigned int Width
vtkTimeStamp SendParametersTime
unsigned int Target
a simple class to control print indentation
Definition: vtkIndent.h:39
void SetLinearMagnification(bool val)
Tells if the magnification mode is linear (true) or nearest (false).
unsigned int Depth
static bool IsSupported(vtkRenderWindow *renWin)
Check for feature support, without any optional features.
abstracts an OpenGL pixel buffer object.
Interface class for querying and using OpenGL extensions.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
abstracts an OpenGL texture object.
create a window for renderers to draw into
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
unsigned int Height