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 "vtkObject.h"
29 #include "vtkWeakPointer.h" // needed for vtkWeakPointer.
30 
31 class vtkRenderWindow;
34 
36 {
37 public:
38 
39  //BTX
40  // DepthTextureCompareFunction values.
41  enum
42  {
43  Lequal=0, // r=R<=Dt ? 1.0 : 0.0
44  Gequal, // r=R>=Dt ? 1.0 : 0.0
45  Less, // r=R<D_t ? 1.0 : 0.0
46  Greater, // r=R>Dt ? 1.0 : 0.0
47  Equal, // r=R==Dt ? 1.0 : 0.0
48  NotEqual, // r=R!=Dt ? 1.0 : 0.0
49  AlwaysTrue, // r=1.0 // WARNING "Always" is macro defined in X11/X.h...
50  Never, // r=0.0
51  NumberOfDepthTextureCompareFunctions
52  };
53 
54  // DepthTextureMode values.
55  enum
56  {
57  Luminance=0, // (R,G,B,A)=(r,r,r,1)
58  Intensity, // (R,G,B,A)=(r,r,r,r)
59  Alpha, // (R.G.B.A)=(0,0,0,r)
60  NumberOfDepthTextureModes
61  };
62 
63  // Wrap values.
64  enum
65  {
66  Clamp=0,
71  NumberOfWrapModes
72  };
73 
74  // MinificationFilter values.
75  enum
76  {
77  Nearest=0,
83  NumberOfMinificationModes
84  };
85 
86  // Internal depth format
87  enum
88  {
89  Native=0, // will try to match with the depth buffer format.
94  NumberOfDepthFormats
95  };
96 
97  //ETX
98 
99  static vtkTextureObject* New();
100  vtkTypeMacro(vtkTextureObject, vtkObject);
101  void PrintSelf(ostream& os, vtkIndent indent);
102 
104 
108  void SetContext(vtkRenderWindow*);
109  vtkRenderWindow* GetContext();
111 
113 
115  vtkGetMacro(Width, unsigned int);
116  vtkGetMacro(Height, unsigned int);
117  vtkGetMacro(Depth, unsigned int);
118  vtkGetMacro(Components, int);
120 
121  vtkGetMacro(NumberOfDimensions, int);
122 
124 
125  vtkGetMacro(Target, unsigned int);
127 
129 
130  vtkGetMacro(Handle, unsigned int);
132 
134 
136  void Bind();
137  void UnBind();
139 
142  bool IsBound();
143 
146  void SendParameters();
147 
149 
156  bool Create1D(int numComps,
158  bool shaderSupportsTextureInt);
160 
162 
165  bool Create2D(unsigned int width, unsigned int height, int numComps,
167  bool shaderSupportsTextureInt);
169 
171 
173  bool CreateDepth(unsigned int width,
174  unsigned int height,
175  int internalFormat,
176  vtkPixelBufferObject *pbo);
178 
180 
182  bool CreateDepthFromRaw(unsigned int width,
183  unsigned int height,
184  int internalFormat,
185  int rawType,
186  void *raw);
188 
190 
191  bool AllocateDepth(unsigned int width,unsigned int height,
192  int internalFormat);
194 
197  bool Allocate1D(unsigned int width, int numComps,int vtkType);
198 
200 
202  bool Allocate2D(unsigned int width,unsigned int height, int numComps,
203  int vtkType);
205 
207 
209  bool Allocate3D(unsigned int width,unsigned int height,
210  unsigned int depth, int numComps,
211  int vtkType);
213 
214 
216 
219  bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
220  int numComps, vtkPixelBufferObject *pbo,
221  bool shaderSupportsTextureInt);
223 
224 
226 
229  bool Create2D(unsigned int width, unsigned int height, int numComps,
230  int vtktype,
231  bool shaderSupportsTextureInt);
232  bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
233  int numComps, int vtktype,
234  bool shaderSupportsTextureInt);
236 
241  vtkPixelBufferObject* Download();
242 
244  int GetDataType();
245 
246  unsigned int GetInternalFormat(int vtktype, int numComps,
247  bool shaderSupportsTextureInt);
248  unsigned int GetFormat(int vtktype, int numComps,
249  bool shaderSupportsTextureInt);
250 
252 
255  vtkGetMacro(WrapS,int);
256  vtkSetMacro(WrapS,int);
258 
260 
263  vtkGetMacro(WrapT,int);
264  vtkSetMacro(WrapT,int);
266 
268 
271  vtkGetMacro(WrapR,int);
272  vtkSetMacro(WrapR,int);
274 
276 
281  vtkGetMacro(MinificationFilter,int);
282  vtkSetMacro(MinificationFilter,int);
284 
286 
288  vtkGetMacro(LinearMagnification,bool);
289  vtkSetMacro(LinearMagnification,bool);
291 
293 
295  vtkSetVector4Macro(BorderColor,float);
296  vtkGetVector4Macro(BorderColor,float);
298 
300 
303  vtkSetMacro(Priority,float);
304  vtkGetMacro(Priority,float);
306 
308 
310  vtkSetMacro(MinLOD,float);
311  vtkGetMacro(MinLOD,float);
313 
315 
317  vtkSetMacro(MaxLOD,float);
318  vtkGetMacro(MaxLOD,float);
320 
322 
325  vtkSetMacro(BaseLevel,int);
326  vtkGetMacro(BaseLevel,int);
328 
330 
333  vtkSetMacro(MaxLevel,int);
334  vtkGetMacro(MaxLevel,int);
336 
338 
344  vtkGetMacro(DepthTextureCompare,bool);
345  vtkSetMacro(DepthTextureCompare,bool);
347 
349 
359  vtkGetMacro(DepthTextureCompareFunction,int);
360  vtkSetMacro(DepthTextureCompareFunction,int);
362 
364 
369  vtkGetMacro(DepthTextureMode,int);
370  vtkSetMacro(DepthTextureMode,int);
372 
374 
376  vtkGetMacro(GenerateMipmap,bool);
377  vtkSetMacro(GenerateMipmap,bool);
379 
381  static bool IsSupported(vtkRenderWindow* renWin);
382 
384 
403  void CopyToFrameBuffer(int srcXmin,
404  int srcYmin,
405  int srcXmax,
406  int srcYmax,
407  int dstXmin,
408  int dstYmin,
409  int width,
410  int height);
412 
413 
415 
423  void CopyFromFrameBuffer(int srcXmin,
424  int srcYmin,
425  int dstXmin,
426  int dstYmin,
427  int width,
428  int height);
430 
431 
432 //BTX
433 protected:
435  ~vtkTextureObject();
436 
438  bool LoadRequiredExtensions(vtkOpenGLExtensionManager*);
439 
441  void CreateTexture();
442 
444  void DestroyTexture();
445 
447  unsigned int Width;
448  unsigned int Height;
449  unsigned int Depth;
450 
451  unsigned int Target; // GLenum
452  unsigned int Format; // GLenum
453  unsigned int Type; // GLenum
455 
457  unsigned int Handle;
460 
461  int WrapS;
462  int WrapT;
463  int WrapR;
466  float BorderColor[4];
467 
468  float Priority;
469  float MinLOD;
470  float MaxLOD;
472  int MaxLevel;
473 
474 
478 
480 
482 
483 private:
484  vtkTextureObject(const vtkTextureObject&); // Not implemented.
485  void operator=(const vtkTextureObject&); // Not implemented.
486 //ETX
487 };
488 
489 #endif
490 
491