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 =========================================================================*/
26 #ifndef vtkTextureObject_h
27 #define vtkTextureObject_h
28 
29 #include "vtkRenderingOpenGLModule.h" // For export macro
30 #include "vtkObject.h"
31 #include "vtkWeakPointer.h" // for render context
32 
33 class vtkFloatArray;
34 class vtkTextureObject;
35 class vtkRenderWindow;
39 
40 class VTKRENDERINGOPENGL_EXPORT vtkTextureObject : public vtkObject
41 {
42 public:
43 
44  // DepthTextureCompareFunction values.
45  enum
46  {
47  Lequal=0, // r=R<=Dt ? 1.0 : 0.0
48  Gequal, // r=R>=Dt ? 1.0 : 0.0
49  Less, // r=R<D_t ? 1.0 : 0.0
50  Greater, // r=R>Dt ? 1.0 : 0.0
51  Equal, // r=R==Dt ? 1.0 : 0.0
52  NotEqual, // r=R!=Dt ? 1.0 : 0.0
53  AlwaysTrue, // r=1.0 // WARNING "Always" is macro defined in X11/X.h...
54  Never, // r=0.0
55  NumberOfDepthTextureCompareFunctions
56  };
57 
58  // DepthTextureMode values.
59  enum
60  {
61  Luminance=0, // (R,G,B,A)=(r,r,r,1)
62  Intensity, // (R,G,B,A)=(r,r,r,r)
63  Alpha, // (R,G,B,A)=(0,0,0,r)
64  NumberOfDepthTextureModes
65  };
66 
67  // Wrap values.
68  enum
69  {
70  Clamp=0,
75  NumberOfWrapModes
76  };
77 
78  // MinificationFilter values.
79  enum
80  {
81  Nearest=0,
87  NumberOfMinificationModes
88  };
89 
90  // Internal depth format
91  enum
92  {
93  Native=0, // will try to match with the depth buffer format.
98  NumberOfDepthFormats
99  };
100 
101  static vtkTextureObject* New();
102  vtkTypeMacro(vtkTextureObject, vtkObject);
103  void PrintSelf(ostream& os, vtkIndent indent);
104 
106 
112  void SetContext(vtkRenderWindow*);
113  vtkRenderWindow* GetContext();
115 
117 
121  vtkGetMacro(Width, unsigned int);
122  vtkGetMacro(Height, unsigned int);
123  vtkGetMacro(Depth, unsigned int);
124  vtkGetMacro(Components, int);
125  unsigned int GetTuples()
126  { return this->Width*this->Height*this->Depth; }
128 
129  vtkGetMacro(NumberOfDimensions, int);
130 
132 
135  vtkGetMacro(Target, unsigned int);
137 
139 
142  vtkGetMacro(Handle, unsigned int);
144 
146 
151  void Bind();
152  void UnBind();
154 
156 
159  void Activate(unsigned int texUnit);
160  void Deactivate(unsigned int texUnit);
162 
163 
168  bool IsBound();
169 
171 
177  void SendParameters();
178  vtkSetMacro(AutoParameters, int);
179  vtkGetMacro(AutoParameters, int);
181 
192  bool Create1D(int numComps,
194  bool shaderSupportsTextureInt);
195 
202  bool Create2D(unsigned int width, unsigned int height, int numComps,
204  bool shaderSupportsTextureInt);
205 
210  bool CreateDepth(unsigned int width,
211  unsigned int height,
212  int internalFormat,
213  vtkPixelBufferObject *pbo);
214 
219  bool CreateDepthFromRaw(unsigned int width,
220  unsigned int height,
221  int internalFormat,
222  int rawType,
223  void *raw);
224 
228  bool AllocateDepth(unsigned int width, unsigned int height,
229  int internalFormat);
230 
235  bool Allocate1D(unsigned int width, int numComps, int vtkType);
236 
241  bool Allocate2D(unsigned int width, unsigned int height, int numComps,
242  int vtkType);
243 
248  bool Allocate3D(unsigned int width, unsigned int height,
249  unsigned int depth, int numComps,
250  int vtkType);
251 
252 
259  bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
260  int numComps, vtkPixelBufferObject *pbo,
261  bool shaderSupportsTextureInt);
262 
263 
265 
270  bool Create2D(unsigned int width, unsigned int height, int numComps,
271  int vtktype,
272  bool shaderSupportsTextureInt);
273  bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
274  int numComps, int vtktype,
275  bool shaderSupportsTextureInt);
277 
284  vtkPixelBufferObject* Download();
285 
289  int GetDataType();
290 
291  unsigned int GetInternalFormat(int vtktype, int numComps,
292  bool shaderSupportsTextureInt);
293  unsigned int GetFormat(int vtktype, int numComps,
294  bool shaderSupportsTextureInt);
295 
297 
303  vtkSetMacro(RequireDepthBufferFloat, bool);
304  vtkGetMacro(RequireDepthBufferFloat, bool);
305  vtkGetMacro(SupportsDepthBufferFloat, bool);
307 
309 
315  vtkSetMacro(RequireTextureFloat, bool);
316  vtkGetMacro(RequireTextureFloat, bool);
317  vtkGetMacro(SupportsTextureFloat, bool);
319 
321 
327  vtkSetMacro(RequireTextureInteger, bool);
328  vtkGetMacro(RequireTextureInteger, bool);
329  vtkGetMacro(SupportsTextureInteger, bool);
331 
333 
343  vtkGetMacro(WrapS, int);
344  vtkSetMacro(WrapS, int);
346 
348 
358  vtkGetMacro(WrapT, int);
359  vtkSetMacro(WrapT, int);
361 
363 
373  vtkGetMacro(WrapR, int);
374  vtkSetMacro(WrapR, int);
376 
378 
391  vtkGetMacro(MinificationFilter, int);
392  vtkSetMacro(MinificationFilter, int);
394 
396 
403  vtkGetMacro(MagnificationFilter, int);
404  vtkSetMacro(MagnificationFilter, int);
406 
411  void SetLinearMagnification(bool val)
412  { this->SetMagnificationFilter(val?Linear:Nearest); }
413 
415  { return this->MagnificationFilter==Linear; }
416 
418 
423  vtkSetVector4Macro(BorderColor, float);
424  vtkGetVector4Macro(BorderColor, float);
426 
428 
433  vtkSetMacro(Priority, float);
434  vtkGetMacro(Priority, float);
436 
438 
442  vtkSetMacro(MinLOD, float);
443  vtkGetMacro(MinLOD, float);
445 
447 
451  vtkSetMacro(MaxLOD, float);
452  vtkGetMacro(MaxLOD, float);
454 
456 
461  vtkSetMacro(BaseLevel, int);
462  vtkGetMacro(BaseLevel, int);
464 
466 
471  vtkSetMacro(MaxLevel, int);
472  vtkGetMacro(MaxLevel, int);
474 
476 
486  vtkGetMacro(DepthTextureCompare, bool);
487  vtkSetMacro(DepthTextureCompare, bool);
489 
491 
511  vtkGetMacro(DepthTextureCompareFunction, int);
512  vtkSetMacro(DepthTextureCompareFunction, int);
514 
516 
525  vtkGetMacro(DepthTextureMode, int);
526  vtkSetMacro(DepthTextureMode, int);
528 
530 
535  vtkGetMacro(GenerateMipmap, bool);
536  vtkSetMacro(GenerateMipmap, bool);
538 
544  static bool IsSupported(
545  vtkRenderWindow* renWin,
546  bool requireTexFloat,
547  bool requireDepthFloat,
548  bool requireTexInt);
549 
553  static bool IsSupported(vtkRenderWindow* renWin)
554  { return vtkTextureObject::IsSupported(renWin, false, false, false); }
555 
582  void CopyToFrameBuffer(int srcXmin,
583  int srcYmin,
584  int srcXmax,
585  int srcYmax,
586  int dstXmin,
587  int dstYmin,
588  int width,
589  int height);
590 
591 
603  void CopyFromFrameBuffer(int srcXmin,
604  int srcYmin,
605  int dstXmin,
606  int dstYmin,
607  int width,
608  int height);
609 
610 protected:
612  ~vtkTextureObject();
613 
617  bool LoadRequiredExtensions(vtkRenderWindow *renWin);
618 
622  void CreateTexture();
623 
627  void DestroyTexture();
628 
630  unsigned int Width;
631  unsigned int Height;
632  unsigned int Depth;
633 
634  unsigned int Target; // GLenum
635  unsigned int Format; // GLenum
636  unsigned int Type; // GLenum
638 
640  unsigned int Handle;
647 
648  int WrapS;
649  int WrapT;
650  int WrapR;
654  float BorderColor[4];
655 
656  float Priority;
657  float MinLOD;
658  float MaxLOD;
660  int MaxLevel;
661 
662 
666 
668 
671 
672 private:
673  vtkTextureObject(const vtkTextureObject&) VTK_DELETE_FUNCTION;
674  void operator=(const vtkTextureObject&) VTK_DELETE_FUNCTION;
675 
676 };
677 
678 #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