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 =========================================================================*/
25 #ifndef vtkTextureObject_h
26 #define vtkTextureObject_h
27 
28 #include "vtkRenderingOpenGLModule.h" // For export macro
29 #include "vtkObject.h"
30 #include "vtkWeakPointer.h" // for render context
31 
32 class vtkFloatArray;
33 class vtkTextureObject;
34 class vtkRenderWindow;
38 
40 {
41 public:
42 
43  //BTX
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  //ETX
102 
103  static vtkTextureObject* New();
104  vtkTypeMacro(vtkTextureObject, vtkObject);
105  void PrintSelf(ostream& os, vtkIndent indent);
106 
108 
112  void SetContext(vtkRenderWindow*);
113  vtkRenderWindow* GetContext();
115 
117 
119  vtkGetMacro(Width, unsigned int);
120  vtkGetMacro(Height, unsigned int);
121  vtkGetMacro(Depth, unsigned int);
122  vtkGetMacro(Components, int);
123  unsigned int GetTuples()
124  { return this->Width*this->Height*this->Depth; }
126 
127  vtkGetMacro(NumberOfDimensions, int);
128 
130 
131  vtkGetMacro(Target, unsigned int);
133 
135 
136  vtkGetMacro(Handle, unsigned int);
138 
140 
143  void Bind();
144  void UnBind();
146 
148 
149  void Activate(unsigned int texUnit);
150  void Deactivate(unsigned int texUnit);
152 
153 
156  bool IsBound();
157 
159 
162  void SendParameters();
163  vtkSetMacro(AutoParameters, int);
164  vtkGetMacro(AutoParameters, int);
166 
168 
175  bool Create1D(int numComps,
177  bool shaderSupportsTextureInt);
179 
181 
184  bool Create2D(unsigned int width, unsigned int height, int numComps,
186  bool shaderSupportsTextureInt);
188 
190 
192  bool CreateDepth(unsigned int width,
193  unsigned int height,
194  int internalFormat,
195  vtkPixelBufferObject *pbo);
197 
199 
201  bool CreateDepthFromRaw(unsigned int width,
202  unsigned int height,
203  int internalFormat,
204  int rawType,
205  void *raw);
207 
209 
210  bool AllocateDepth(unsigned int width,unsigned int height,
211  int internalFormat);
213 
216  bool Allocate1D(unsigned int width, int numComps,int vtkType);
217 
219 
221  bool Allocate2D(unsigned int width,unsigned int height, int numComps,
222  int vtkType);
224 
226 
228  bool Allocate3D(unsigned int width,unsigned int height,
229  unsigned int depth, int numComps,
230  int vtkType);
232 
233 
235 
238  bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
239  int numComps, vtkPixelBufferObject *pbo,
240  bool shaderSupportsTextureInt);
242 
243 
245 
248  bool Create2D(unsigned int width, unsigned int height, int numComps,
249  int vtktype,
250  bool shaderSupportsTextureInt);
251  bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
252  int numComps, int vtktype,
253  bool shaderSupportsTextureInt);
255 
260  vtkPixelBufferObject* Download();
261 
263  int GetDataType();
264 
265  unsigned int GetInternalFormat(int vtktype, int numComps,
266  bool shaderSupportsTextureInt);
267  unsigned int GetFormat(int vtktype, int numComps,
268  bool shaderSupportsTextureInt);
269 
271 
274  vtkSetMacro(RequireDepthBufferFloat, bool);
275  vtkGetMacro(RequireDepthBufferFloat, bool);
276  vtkGetMacro(SupportsDepthBufferFloat, bool);
278 
280 
283  vtkSetMacro(RequireTextureFloat,bool);
284  vtkGetMacro(RequireTextureFloat,bool);
285  vtkGetMacro(SupportsTextureFloat,bool);
287 
289 
292  vtkSetMacro(RequireTextureInteger,bool);
293  vtkGetMacro(RequireTextureInteger,bool);
294  vtkGetMacro(SupportsTextureInteger,bool);
296 
298 
301  vtkGetMacro(WrapS,int);
302  vtkSetMacro(WrapS,int);
304 
306 
309  vtkGetMacro(WrapT,int);
310  vtkSetMacro(WrapT,int);
312 
314 
317  vtkGetMacro(WrapR,int);
318  vtkSetMacro(WrapR,int);
320 
322 
327  vtkGetMacro(MinificationFilter,int);
328  vtkSetMacro(MinificationFilter,int);
330 
332 
334  vtkGetMacro(MagnificationFilter,int);
335  vtkSetMacro(MagnificationFilter,int);
337 
339 
341  void SetLinearMagnification(bool val)
342  { this->SetMagnificationFilter(val?Linear:Nearest); }
344 
346  { return this->MagnificationFilter==Linear; }
347 
349 
352  vtkSetVector4Macro(BorderColor,float);
353  vtkGetVector4Macro(BorderColor,float);
355 
357 
360  vtkSetMacro(Priority,float);
361  vtkGetMacro(Priority,float);
363 
365 
367  vtkSetMacro(MinLOD,float);
368  vtkGetMacro(MinLOD,float);
370 
372 
374  vtkSetMacro(MaxLOD,float);
375  vtkGetMacro(MaxLOD,float);
377 
379 
382  vtkSetMacro(BaseLevel,int);
383  vtkGetMacro(BaseLevel,int);
385 
387 
390  vtkSetMacro(MaxLevel,int);
391  vtkGetMacro(MaxLevel,int);
393 
395 
401  vtkGetMacro(DepthTextureCompare,bool);
402  vtkSetMacro(DepthTextureCompare,bool);
404 
406 
416  vtkGetMacro(DepthTextureCompareFunction,int);
417  vtkSetMacro(DepthTextureCompareFunction,int);
419 
421 
426  vtkGetMacro(DepthTextureMode,int);
427  vtkSetMacro(DepthTextureMode,int);
429 
431 
433  vtkGetMacro(GenerateMipmap,bool);
434  vtkSetMacro(GenerateMipmap,bool);
436 
438 
441  static bool IsSupported(
442  vtkRenderWindow* renWin,
443  bool requireTexFloat,
444  bool requireDepthFloat,
445  bool requireTexInt);
447 
449 
450  static bool IsSupported(vtkRenderWindow* renWin)
451  { return vtkTextureObject::IsSupported(renWin, false, false, false); }
453 
455 
474  void CopyToFrameBuffer(int srcXmin,
475  int srcYmin,
476  int srcXmax,
477  int srcYmax,
478  int dstXmin,
479  int dstYmin,
480  int width,
481  int height);
483 
484 
486 
494  void CopyFromFrameBuffer(int srcXmin,
495  int srcYmin,
496  int dstXmin,
497  int dstYmin,
498  int width,
499  int height);
501 
502 
503 
504 //BTX
505 protected:
507  ~vtkTextureObject();
508 
510  bool LoadRequiredExtensions(vtkRenderWindow *renWin);
511 
513  void CreateTexture();
514 
516  void DestroyTexture();
517 
519  unsigned int Width;
520  unsigned int Height;
521  unsigned int Depth;
522 
523  unsigned int Target; // GLenum
524  unsigned int Format; // GLenum
525  unsigned int Type; // GLenum
527 
529  unsigned int Handle;
536 
537  int WrapS;
538  int WrapT;
539  int WrapR;
543  float BorderColor[4];
544 
545  float Priority;
546  float MinLOD;
547  float MaxLOD;
549  int MaxLevel;
550 
551 
555 
557 
560 
561 private:
562  vtkTextureObject(const vtkTextureObject&); // Not implemented.
563  void operator=(const vtkTextureObject&); // Not implemented.
564 //ETX
565 };
566 
567 #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
#define VTKRENDERINGOPENGL_EXPORT
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