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 =========================================================================*/
28 #ifndef vtkTextureObject_h
29 #define vtkTextureObject_h
30 
31 #include "vtkRenderingOpenGLModule.h" // For export macro
32 #include "vtkObject.h"
33 #include "vtkWeakPointer.h" // for render context
34 
35 class vtkFloatArray;
36 class vtkTextureObject;
37 class vtkRenderWindow;
41 
42 class VTKRENDERINGOPENGL_EXPORT vtkTextureObject : public vtkObject
43 {
44 public:
45 
46  //BTX
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  //ETX
105 
106  static vtkTextureObject* New();
107  vtkTypeMacro(vtkTextureObject, vtkObject);
108  void PrintSelf(ostream& os, vtkIndent indent);
109 
111 
115  void SetContext(vtkRenderWindow*);
116  vtkRenderWindow* GetContext();
118 
120 
122  vtkGetMacro(Width, unsigned int);
123  vtkGetMacro(Height, unsigned int);
124  vtkGetMacro(Depth, unsigned int);
125  vtkGetMacro(Components, int);
126  unsigned int GetTuples()
127  { return this->Width*this->Height*this->Depth; }
129 
130  vtkGetMacro(NumberOfDimensions, int);
131 
133 
134  vtkGetMacro(Target, unsigned int);
136 
138 
139  vtkGetMacro(Handle, unsigned int);
141 
143 
146  void Bind();
147  void UnBind();
149 
151 
152  void Activate(unsigned int texUnit);
153  void Deactivate(unsigned int texUnit);
155 
156 
159  bool IsBound();
160 
162 
165  void SendParameters();
166  vtkSetMacro(AutoParameters, int);
167  vtkGetMacro(AutoParameters, int);
169 
171 
178  bool Create1D(int numComps,
180  bool shaderSupportsTextureInt);
182 
184 
187  bool Create2D(unsigned int width, unsigned int height, int numComps,
189  bool shaderSupportsTextureInt);
191 
193 
195  bool CreateDepth(unsigned int width,
196  unsigned int height,
197  int internalFormat,
198  vtkPixelBufferObject *pbo);
200 
202 
204  bool CreateDepthFromRaw(unsigned int width,
205  unsigned int height,
206  int internalFormat,
207  int rawType,
208  void *raw);
210 
212 
213  bool AllocateDepth(unsigned int width,unsigned int height,
214  int internalFormat);
216 
219  bool Allocate1D(unsigned int width, int numComps,int vtkType);
220 
222 
224  bool Allocate2D(unsigned int width,unsigned int height, int numComps,
225  int vtkType);
227 
229 
231  bool Allocate3D(unsigned int width,unsigned int height,
232  unsigned int depth, int numComps,
233  int vtkType);
235 
236 
238 
241  bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
242  int numComps, vtkPixelBufferObject *pbo,
243  bool shaderSupportsTextureInt);
245 
246 
248 
251  bool Create2D(unsigned int width, unsigned int height, int numComps,
252  int vtktype,
253  bool shaderSupportsTextureInt);
254  bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
255  int numComps, int vtktype,
256  bool shaderSupportsTextureInt);
258 
263  vtkPixelBufferObject* Download();
264 
266  int GetDataType();
267 
268  unsigned int GetInternalFormat(int vtktype, int numComps,
269  bool shaderSupportsTextureInt);
270  unsigned int GetFormat(int vtktype, int numComps,
271  bool shaderSupportsTextureInt);
272 
274 
277  vtkSetMacro(RequireDepthBufferFloat, bool);
278  vtkGetMacro(RequireDepthBufferFloat, bool);
279  vtkGetMacro(SupportsDepthBufferFloat, bool);
281 
283 
286  vtkSetMacro(RequireTextureFloat,bool);
287  vtkGetMacro(RequireTextureFloat,bool);
288  vtkGetMacro(SupportsTextureFloat,bool);
290 
292 
295  vtkSetMacro(RequireTextureInteger,bool);
296  vtkGetMacro(RequireTextureInteger,bool);
297  vtkGetMacro(SupportsTextureInteger,bool);
299 
301 
304  vtkGetMacro(WrapS,int);
305  vtkSetMacro(WrapS,int);
307 
309 
312  vtkGetMacro(WrapT,int);
313  vtkSetMacro(WrapT,int);
315 
317 
320  vtkGetMacro(WrapR,int);
321  vtkSetMacro(WrapR,int);
323 
325 
330  vtkGetMacro(MinificationFilter,int);
331  vtkSetMacro(MinificationFilter,int);
333 
335 
337  vtkGetMacro(MagnificationFilter,int);
338  vtkSetMacro(MagnificationFilter,int);
340 
342 
344  void SetLinearMagnification(bool val)
345  { this->SetMagnificationFilter(val?Linear:Nearest); }
347 
349  { return this->MagnificationFilter==Linear; }
350 
352 
355  vtkSetVector4Macro(BorderColor,float);
356  vtkGetVector4Macro(BorderColor,float);
358 
360 
363  vtkSetMacro(Priority,float);
364  vtkGetMacro(Priority,float);
366 
368 
370  vtkSetMacro(MinLOD,float);
371  vtkGetMacro(MinLOD,float);
373 
375 
377  vtkSetMacro(MaxLOD,float);
378  vtkGetMacro(MaxLOD,float);
380 
382 
385  vtkSetMacro(BaseLevel,int);
386  vtkGetMacro(BaseLevel,int);
388 
390 
393  vtkSetMacro(MaxLevel,int);
394  vtkGetMacro(MaxLevel,int);
396 
398 
404  vtkGetMacro(DepthTextureCompare,bool);
405  vtkSetMacro(DepthTextureCompare,bool);
407 
409 
419  vtkGetMacro(DepthTextureCompareFunction,int);
420  vtkSetMacro(DepthTextureCompareFunction,int);
422 
424 
429  vtkGetMacro(DepthTextureMode,int);
430  vtkSetMacro(DepthTextureMode,int);
432 
434 
436  vtkGetMacro(GenerateMipmap,bool);
437  vtkSetMacro(GenerateMipmap,bool);
439 
441 
444  static bool IsSupported(
445  vtkRenderWindow* renWin,
446  bool requireTexFloat,
447  bool requireDepthFloat,
448  bool requireTexInt);
450 
452 
453  static bool IsSupported(vtkRenderWindow* renWin)
454  { return vtkTextureObject::IsSupported(renWin, false, false, false); }
456 
458 
477  void CopyToFrameBuffer(int srcXmin,
478  int srcYmin,
479  int srcXmax,
480  int srcYmax,
481  int dstXmin,
482  int dstYmin,
483  int width,
484  int height);
486 
487 
489 
497  void CopyFromFrameBuffer(int srcXmin,
498  int srcYmin,
499  int dstXmin,
500  int dstYmin,
501  int width,
502  int height);
504 
505 
506 
507 //BTX
508 protected:
510  ~vtkTextureObject();
511 
513  bool LoadRequiredExtensions(vtkRenderWindow *renWin);
514 
516  void CreateTexture();
517 
519  void DestroyTexture();
520 
522  unsigned int Width;
523  unsigned int Height;
524  unsigned int Depth;
525 
526  unsigned int Target; // GLenum
527  unsigned int Format; // GLenum
528  unsigned int Type; // GLenum
530 
532  unsigned int Handle;
539 
540  int WrapS;
541  int WrapT;
542  int WrapR;
546  float BorderColor[4];
547 
548  float Priority;
549  float MinLOD;
550  float MaxLOD;
552  int MaxLevel;
553 
554 
558 
560 
563 
564 private:
565  vtkTextureObject(const vtkTextureObject&); // Not implemented.
566  void operator=(const vtkTextureObject&); // Not implemented.
567 //ETX
568 };
569 
570 #endif
OpenGL rendering window.
abstract base class for most VTK objects
Definition: vtkObject.h:61
unsigned int Format
unsigned int Handle
unsigned int GetTuples()
vtkWeakPointer< vtkRenderWindow > Context
record modification and/or execution time
Definition: vtkTimeStamp.h:34
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:45
static bool IsSupported(vtkRenderWindow *renWin, bool requireTexFloat, bool requireDepthFloat, bool requireTexInt)
unsigned int Width
vtkTimeStamp SendParametersTime
virtual void PrintSelf(ostream &os, vtkIndent indent)
unsigned int Target
a simple class to control print indentation
Definition: vtkIndent.h:38
void SetLinearMagnification(bool val)
unsigned int Depth
static bool IsSupported(vtkRenderWindow *renWin)
abstracts an OpenGL pixel buffer object.
Interface class for querying and using OpenGL extensions.
abstracts an OpenGL texture object.
create a window for renderers to draw into
static vtkObject * New()
unsigned int Height