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" // needed for vtkWeakPointer.
31 
32 class vtkRenderWindow;
35 
36 class VTKRENDERINGOPENGL_EXPORT vtkTextureObject : public vtkObject
37 {
38 public:
39 
40  //BTX
41  // DepthTextureCompareFunction values.
42  enum
43  {
44  Lequal=0, // r=R<=Dt ? 1.0 : 0.0
45  Gequal, // r=R>=Dt ? 1.0 : 0.0
46  Less, // r=R<D_t ? 1.0 : 0.0
47  Greater, // r=R>Dt ? 1.0 : 0.0
48  Equal, // r=R==Dt ? 1.0 : 0.0
49  NotEqual, // r=R!=Dt ? 1.0 : 0.0
50  AlwaysTrue, // r=1.0 // WARNING "Always" is macro defined in X11/X.h...
51  Never, // r=0.0
52  NumberOfDepthTextureCompareFunctions
53  };
54 
55  // DepthTextureMode values.
56  enum
57  {
58  Luminance=0, // (R,G,B,A)=(r,r,r,1)
59  Intensity, // (R,G,B,A)=(r,r,r,r)
60  Alpha, // (R.G.B.A)=(0,0,0,r)
61  NumberOfDepthTextureModes
62  };
63 
64  // Wrap values.
65  enum
66  {
67  Clamp=0,
72  NumberOfWrapModes
73  };
74 
75  // MinificationFilter values.
76  enum
77  {
78  Nearest=0,
84  NumberOfMinificationModes
85  };
86 
87  // Internal depth format
88  enum
89  {
90  Native=0, // will try to match with the depth buffer format.
95  NumberOfDepthFormats
96  };
97 
98  //ETX
99 
100  static vtkTextureObject* New();
101  vtkTypeMacro(vtkTextureObject, vtkObject);
102  void PrintSelf(ostream& os, vtkIndent indent);
103 
105 
109  void SetContext(vtkRenderWindow*);
110  vtkRenderWindow* GetContext();
112 
114 
116  vtkGetMacro(Width, unsigned int);
117  vtkGetMacro(Height, unsigned int);
118  vtkGetMacro(Depth, unsigned int);
119  vtkGetMacro(Components, int);
121 
122  vtkGetMacro(NumberOfDimensions, int);
123 
125 
126  vtkGetMacro(Target, unsigned int);
128 
130 
131  vtkGetMacro(Handle, unsigned int);
133 
135 
137  void Bind();
138  void UnBind();
140 
143  bool IsBound();
144 
147  void SendParameters();
148 
150 
157  bool Create1D(int numComps,
159  bool shaderSupportsTextureInt);
161 
163 
166  bool Create2D(unsigned int width, unsigned int height, int numComps,
168  bool shaderSupportsTextureInt);
170 
172 
174  bool CreateDepth(unsigned int width,
175  unsigned int height,
176  int internalFormat,
177  vtkPixelBufferObject *pbo);
179 
181 
183  bool CreateDepthFromRaw(unsigned int width,
184  unsigned int height,
185  int internalFormat,
186  int rawType,
187  void *raw);
189 
191 
192  bool AllocateDepth(unsigned int width,unsigned int height,
193  int internalFormat);
195 
198  bool Allocate1D(unsigned int width, int numComps,int vtkType);
199 
201 
203  bool Allocate2D(unsigned int width,unsigned int height, int numComps,
204  int vtkType);
206 
208 
210  bool Allocate3D(unsigned int width,unsigned int height,
211  unsigned int depth, int numComps,
212  int vtkType);
214 
215 
217 
220  bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
221  int numComps, vtkPixelBufferObject *pbo,
222  bool shaderSupportsTextureInt);
224 
225 
227 
230  bool Create2D(unsigned int width, unsigned int height, int numComps,
231  int vtktype,
232  bool shaderSupportsTextureInt);
233  bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
234  int numComps, int vtktype,
235  bool shaderSupportsTextureInt);
237 
242  vtkPixelBufferObject* Download();
243 
245  int GetDataType();
246 
247  unsigned int GetInternalFormat(int vtktype, int numComps,
248  bool shaderSupportsTextureInt);
249  unsigned int GetFormat(int vtktype, int numComps,
250  bool shaderSupportsTextureInt);
251 
253 
256  vtkGetMacro(WrapS,int);
257  vtkSetMacro(WrapS,int);
259 
261 
264  vtkGetMacro(WrapT,int);
265  vtkSetMacro(WrapT,int);
267 
269 
272  vtkGetMacro(WrapR,int);
273  vtkSetMacro(WrapR,int);
275 
277 
282  vtkGetMacro(MinificationFilter,int);
283  vtkSetMacro(MinificationFilter,int);
285 
287 
289  vtkGetMacro(LinearMagnification,bool);
290  vtkSetMacro(LinearMagnification,bool);
292 
294 
296  vtkSetVector4Macro(BorderColor,float);
297  vtkGetVector4Macro(BorderColor,float);
299 
301 
304  vtkSetMacro(Priority,float);
305  vtkGetMacro(Priority,float);
307 
309 
311  vtkSetMacro(MinLOD,float);
312  vtkGetMacro(MinLOD,float);
314 
316 
318  vtkSetMacro(MaxLOD,float);
319  vtkGetMacro(MaxLOD,float);
321 
323 
326  vtkSetMacro(BaseLevel,int);
327  vtkGetMacro(BaseLevel,int);
329 
331 
334  vtkSetMacro(MaxLevel,int);
335  vtkGetMacro(MaxLevel,int);
337 
339 
345  vtkGetMacro(DepthTextureCompare,bool);
346  vtkSetMacro(DepthTextureCompare,bool);
348 
350 
360  vtkGetMacro(DepthTextureCompareFunction,int);
361  vtkSetMacro(DepthTextureCompareFunction,int);
363 
365 
370  vtkGetMacro(DepthTextureMode,int);
371  vtkSetMacro(DepthTextureMode,int);
373 
375 
377  vtkGetMacro(GenerateMipmap,bool);
378  vtkSetMacro(GenerateMipmap,bool);
380 
382  static bool IsSupported(vtkRenderWindow* renWin);
383 
385 
404  void CopyToFrameBuffer(int srcXmin,
405  int srcYmin,
406  int srcXmax,
407  int srcYmax,
408  int dstXmin,
409  int dstYmin,
410  int width,
411  int height);
413 
414 
416 
424  void CopyFromFrameBuffer(int srcXmin,
425  int srcYmin,
426  int dstXmin,
427  int dstYmin,
428  int width,
429  int height);
431 
432 
433 //BTX
434 protected:
436  ~vtkTextureObject();
437 
439  bool LoadRequiredExtensions(vtkOpenGLExtensionManager*);
440 
442  void CreateTexture();
443 
445  void DestroyTexture();
446 
448  unsigned int Width;
449  unsigned int Height;
450  unsigned int Depth;
451 
452  unsigned int Target; // GLenum
453  unsigned int Format; // GLenum
454  unsigned int Type; // GLenum
456 
458  unsigned int Handle;
461 
462  int WrapS;
463  int WrapT;
464  int WrapR;
467  float BorderColor[4];
468 
469  float Priority;
470  float MinLOD;
471  float MaxLOD;
473  int MaxLevel;
474 
475 
479 
481 
483 
484 private:
485  vtkTextureObject(const vtkTextureObject&); // Not implemented.
486  void operator=(const vtkTextureObject&); // Not implemented.
487 //ETX
488 };
489 
490 #endif
491 
492