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 
102  vtkTypeMacro(vtkTextureObject, vtkObject);
103  void PrintSelf(ostream& os, vtkIndent indent);
104 
106 
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 
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 
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:
613 
618 
623 
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
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:42
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:60
Interface class for querying and using OpenGL extensions.
OpenGL rendering window.
abstracts an OpenGL pixel buffer object.
create a window for renderers to draw into
abstracts an OpenGL texture object.
unsigned int Target
void Deactivate(unsigned int texUnit)
bool AllocateDepth(unsigned int width, unsigned int height, int internalFormat)
Create a 2D depth texture but does not initialize its values.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
int GetDataType()
Get the data type for the texture as a vtk type int i.e.
unsigned int Depth
bool IsBound()
Tells if the texture object is bound to the active texture image unit.
bool Allocate1D(unsigned int width, int numComps, int vtkType)
Create a 1D color texture but does not initialize its values.
bool Create1D(int numComps, vtkPixelBufferObject *pbo, bool shaderSupportsTextureInt)
Create a 1D texture using the PBO.
unsigned int Handle
unsigned int GetFormat(int vtktype, int numComps, bool shaderSupportsTextureInt)
void DestroyTexture()
Destroy the texture.
void SetLinearMagnification(bool val)
Tells if the magnification mode is linear (true) or nearest (false).
vtkTimeStamp SendParametersTime
void CopyToFrameBuffer(int srcXmin, int srcYmin, int srcXmax, int srcYmax, int dstXmin, int dstYmin, int width, int height)
Copy a sub-part of the texture (src) in the current framebuffer at location (dstXmin,...
static vtkTextureObject * New()
void CreateTexture()
Creates a texture handle if not already created.
unsigned int Format
bool Create3D(unsigned int width, unsigned int height, unsigned int depth, int numComps, vtkPixelBufferObject *pbo, bool shaderSupportsTextureInt)
Create a 3D texture using the PBO.
bool CreateDepthFromRaw(unsigned int width, unsigned int height, int internalFormat, int rawType, void *raw)
Create a 2D depth texture using a raw pointer.
unsigned int GetInternalFormat(int vtktype, int numComps, bool shaderSupportsTextureInt)
bool LoadRequiredExtensions(vtkRenderWindow *renWin)
Load all necessary extensions.
unsigned int GetTuples()
unsigned int Width
static bool IsSupported(vtkRenderWindow *renWin, bool requireTexFloat, bool requireDepthFloat, bool requireTexInt)
Returns if the context supports the required extensions.
vtkWeakPointer< vtkRenderWindow > Context
bool Create2D(unsigned int width, unsigned int height, int numComps, vtkPixelBufferObject *pbo, bool shaderSupportsTextureInt)
Create a 2D texture using the PBO.
bool Create3D(unsigned int width, unsigned int height, unsigned int depth, int numComps, int vtktype, bool shaderSupportsTextureInt)
bool Allocate3D(unsigned int width, unsigned int height, unsigned int depth, int numComps, int vtkType)
Create a 3D color texture but does not initialize its values.
bool Create2D(unsigned int width, unsigned int height, int numComps, int vtktype, bool shaderSupportsTextureInt)
Create texture without uploading any data.
void Activate(unsigned int texUnit)
Set the active tex unit and bind (using our bind).
static bool IsSupported(vtkRenderWindow *renWin)
Check for feature support, without any optional features.
bool CreateDepth(unsigned int width, unsigned int height, int internalFormat, vtkPixelBufferObject *pbo)
Create a 2D depth texture using a PBO.
unsigned int Height
void CopyFromFrameBuffer(int srcXmin, int srcYmin, int dstXmin, int dstYmin, int width, int height)
Copy a sub-part of a logical buffer of the framebuffer (color or depth) to the texture object.
vtkRenderWindow * GetContext()
void SendParameters()
Send all the texture object parameters to the hardware if not done yet.
void Bind()
Activate the texture.
void SetContext(vtkRenderWindow *)
Get/Set the context.
bool Allocate2D(unsigned int width, unsigned int height, int numComps, int vtkType)
Create a 2D color texture but does not initialize its values.
vtkPixelBufferObject * Download()
This is used to download raw data from the texture into a pixel bufer.
record modification and/or execution time
Definition: vtkTimeStamp.h:36
@ height
Definition: vtkX3D.h:254
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.