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 
105  void PrintSelf(ostream& os, vtkIndent indent);
106 
108 
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 
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 
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 
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 
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:
508 
511 
514 
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
vtkTextureObject::Allocate2D
bool Allocate2D(unsigned int width, unsigned int height, int numComps, int vtkType)
vtkTextureObject::DepthTextureCompare
bool DepthTextureCompare
Definition: vtkTextureObject.h:552
vtkTextureObject::Less
@ Less
Definition: vtkTextureObject.h:49
vtkTextureObject::Greater
@ Greater
Definition: vtkTextureObject.h:50
vtkTextureObject::Create1D
bool Create1D(int numComps, vtkPixelBufferObject *pbo, bool shaderSupportsTextureInt)
vtkTextureObject::Create3D
bool Create3D(unsigned int width, unsigned int height, unsigned int depth, int numComps, int vtktype, bool shaderSupportsTextureInt)
vtkTextureObject::Depth
unsigned int Depth
Definition: vtkTextureObject.h:521
vtkTextureObject::IsSupported
static bool IsSupported(vtkRenderWindow *renWin)
Definition: vtkTextureObject.h:450
vtkTextureObject::NumberOfDimensions
int NumberOfDimensions
Definition: vtkTextureObject.h:518
vtkTextureObject::Fixed32
@ Fixed32
Definition: vtkTextureObject.h:96
vtkTextureObject::LinearMagnification
bool LinearMagnification
Definition: vtkTextureObject.h:542
vtkTextureObject::Gequal
@ Gequal
Definition: vtkTextureObject.h:48
vtkTextureObject::SendParametersTime
vtkTimeStamp SendParametersTime
Definition: vtkTextureObject.h:559
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:49
vtkTextureObject::Equal
@ Equal
Definition: vtkTextureObject.h:51
vtkTextureObject::LinearMipmapNearest
@ LinearMipmapNearest
Definition: vtkTextureObject.h:85
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:35
vtkTextureObject::Download
vtkPixelBufferObject * Download()
vtkTextureObject::RequireTextureFloat
bool RequireTextureFloat
Definition: vtkTextureObject.h:532
vtkgl::GenerateMipmap
VTKRENDERINGOPENGL_EXPORT PFNGLGENERATEMIPMAPPROC GenerateMipmap
vtkRenderingOpenGLModule.h
vtkTextureObject::Target
unsigned int Target
Definition: vtkTextureObject.h:523
vtkTextureObject::Intensity
@ Intensity
Definition: vtkTextureObject.h:62
vtkTextureObject::WrapR
int WrapR
Definition: vtkTextureObject.h:539
vtkTextureObject::MagnificationFilter
int MagnificationFilter
Definition: vtkTextureObject.h:541
vtkTextureObject::Linear
@ Linear
Definition: vtkTextureObject.h:82
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkTextureObject::GenerateMipmap
bool GenerateMipmap
Definition: vtkTextureObject.h:556
vtkTextureObject::SupportsTextureInteger
bool SupportsTextureInteger
Definition: vtkTextureObject.h:531
vtkTextureObject::SupportsDepthBufferFloat
bool SupportsDepthBufferFloat
Definition: vtkTextureObject.h:535
vtkTextureObject::GetFormat
unsigned int GetFormat(int vtktype, int numComps, bool shaderSupportsTextureInt)
vtkTextureObject::AllocateDepth
bool AllocateDepth(unsigned int width, unsigned int height, int internalFormat)
vtkTextureObject::Activate
void Activate(unsigned int texUnit)
vtkTextureObject::GetLinearMagnification
bool GetLinearMagnification()
Definition: vtkTextureObject.h:345
vtkTextureObject::vtkTextureObject
vtkTextureObject()
vtkTextureObject::Context
vtkWeakPointer< vtkRenderWindow > Context
Definition: vtkTextureObject.h:528
vtkTextureObject::MaxLevel
int MaxLevel
Definition: vtkTextureObject.h:549
vtkTextureObject::CreateDepth
bool CreateDepth(unsigned int width, unsigned int height, int internalFormat, vtkPixelBufferObject *pbo)
vtkTextureObject::GetInternalFormat
unsigned int GetInternalFormat(int vtktype, int numComps, bool shaderSupportsTextureInt)
vtkTextureObject::Fixed16
@ Fixed16
Definition: vtkTextureObject.h:94
vtkgl::val
GLuint GLfloat * val
Definition: vtkgl.h:13789
vtkTextureObject::Priority
float Priority
Definition: vtkTextureObject.h:545
vtkTextureObject::MinificationFilter
int MinificationFilter
Definition: vtkTextureObject.h:540
vtkgl::depth
GLint GLint GLsizei GLsizei GLsizei depth
Definition: vtkgl.h:11316
vtkTextureObject::GetTuples
unsigned int GetTuples()
Definition: vtkTextureObject.h:123
vtkTextureObject::RequireDepthBufferFloat
bool RequireDepthBufferFloat
Definition: vtkTextureObject.h:534
vtkOpenGLExtensionManager
Interface class for querying and using OpenGL extensions.
vtkTextureObject::Fixed24
@ Fixed24
Definition: vtkTextureObject.h:95
vtkTextureObject::CreateTexture
void CreateTexture()
vtkTextureObject::SetContext
void SetContext(vtkRenderWindow *)
vtkTextureObject::NearestMipmapNearest
@ NearestMipmapNearest
Definition: vtkTextureObject.h:83
vtkTextureObject::AlwaysTrue
@ AlwaysTrue
Definition: vtkTextureObject.h:53
vtkTextureObject::LoadRequiredExtensions
bool LoadRequiredExtensions(vtkRenderWindow *renWin)
vtkTextureObject::Components
int Components
Definition: vtkTextureObject.h:526
vtkTextureObject::RequireTextureInteger
bool RequireTextureInteger
Definition: vtkTextureObject.h:530
vtkTextureObject::Create2D
bool Create2D(unsigned int width, unsigned int height, int numComps, int vtktype, bool shaderSupportsTextureInt)
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkTextureObject
abstracts an OpenGL texture object.
Definition: vtkTextureObject.h:40
vtkTextureObject::~vtkTextureObject
~vtkTextureObject()
vtkTextureObject::New
static vtkTextureObject * New()
vtkTextureObject::Width
unsigned int Width
Definition: vtkTextureObject.h:519
vtkTextureObject::CopyFromFrameBuffer
void CopyFromFrameBuffer(int srcXmin, int srcYmin, int dstXmin, int dstYmin, int width, int height)
vtkTextureObject::Create3D
bool Create3D(unsigned int width, unsigned int height, unsigned int depth, int numComps, vtkPixelBufferObject *pbo, bool shaderSupportsTextureInt)
vtkWeakPointer.h
vtkTextureObject::CopyToFrameBuffer
void CopyToFrameBuffer(int srcXmin, int srcYmin, int srcXmax, int srcYmax, int dstXmin, int dstYmin, int width, int height)
vtkGetMacro
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
vtkTextureObject::Deactivate
void Deactivate(unsigned int texUnit)
vtkTextureObject::Allocate1D
bool Allocate1D(unsigned int width, int numComps, int vtkType)
vtkTextureObject::Never
@ Never
Definition: vtkTextureObject.h:54
vtkTextureObject::LinearMipmapLinear
@ LinearMipmapLinear
Definition: vtkTextureObject.h:86
vtkObject.h
vtkTextureObject::MaxLOD
float MaxLOD
Definition: vtkTextureObject.h:547
vtkTextureObject::NotEqual
@ NotEqual
Definition: vtkTextureObject.h:52
vtkTextureObject::SendParameters
void SendParameters()
vtkgl::width
GLint GLint GLsizei width
Definition: vtkgl.h:11316
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
vtkTextureObject::GetContext
vtkRenderWindow * GetContext()
vtkSetVector4Macro
#define vtkSetVector4Macro(name, type)
Definition: vtkSetGet.h:322
vtkTextureObject::Allocate3D
bool Allocate3D(unsigned int width, unsigned int height, unsigned int depth, int numComps, int vtkType)
vtkTextureObject::Repeat
@ Repeat
Definition: vtkTextureObject.h:72
vtkTextureObject::GetDataType
int GetDataType()
vtkTextureObject::Create2D
bool Create2D(unsigned int width, unsigned int height, int numComps, vtkPixelBufferObject *pbo, bool shaderSupportsTextureInt)
vtkTextureObject::SupportsTextureFloat
bool SupportsTextureFloat
Definition: vtkTextureObject.h:533
vtkTextureObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkgl::internalFormat
GLenum internalFormat
Definition: vtkgl.h:15195
vtkTextureObject::WrapS
int WrapS
Definition: vtkTextureObject.h:537
vtkTextureObject::ClampToEdge
@ ClampToEdge
Definition: vtkTextureObject.h:71
vtkTextureObject::Handle
unsigned int Handle
Definition: vtkTextureObject.h:529
vtkTextureObject::IsBound
bool IsBound()
vtkTextureObject::MirroredRepeat
@ MirroredRepeat
Definition: vtkTextureObject.h:74
vtkTextureObject::AutoParameters
int AutoParameters
Definition: vtkTextureObject.h:558
vtkTextureObject::Float32
@ Float32
Definition: vtkTextureObject.h:97
vtkTextureObject::Height
unsigned int Height
Definition: vtkTextureObject.h:520
vtkTextureObject::CreateDepthFromRaw
bool CreateDepthFromRaw(unsigned int width, unsigned int height, int internalFormat, int rawType, void *raw)
vtkTextureObject::Format
unsigned int Format
Definition: vtkTextureObject.h:524
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:41
vtkTextureObject::Bind
void Bind()
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:89
vtkTextureObject::UnBind
void UnBind()
vtkTextureObject::Alpha
@ Alpha
Definition: vtkTextureObject.h:63
vtkTextureObject::WrapT
int WrapT
Definition: vtkTextureObject.h:538
vtkTextureObject::NearestMipmapLinear
@ NearestMipmapLinear
Definition: vtkTextureObject.h:84
vtkTextureObject::SetLinearMagnification
void SetLinearMagnification(bool val)
Definition: vtkTextureObject.h:341
vtkGetVector4Macro
#define vtkGetVector4Macro(name, type)
Definition: vtkSetGet.h:341
vtkTextureObject::DestroyTexture
void DestroyTexture()
vtkTextureObject::DepthTextureCompareFunction
int DepthTextureCompareFunction
Definition: vtkTextureObject.h:553
vtkTextureObject::ClampToBorder
@ ClampToBorder
Definition: vtkTextureObject.h:73
vtkTextureObject::DepthTextureMode
int DepthTextureMode
Definition: vtkTextureObject.h:554
vtkTextureObject::BaseLevel
int BaseLevel
Definition: vtkTextureObject.h:548
vtkTextureObject::Type
unsigned int Type
Definition: vtkTextureObject.h:525
vtkPixelBufferObject
abstracts an OpenGL pixel buffer object.
Definition: vtkPixelBufferObject.h:43
vtkWeakPointer< vtkRenderWindow >
VTKRENDERINGOPENGL_EXPORT
#define VTKRENDERINGOPENGL_EXPORT
Definition: vtkRenderingOpenGLModule.h:15
vtkgl::height
GLint GLint GLsizei GLsizei height
Definition: vtkgl.h:11316
vtkTextureObject::IsSupported
static bool IsSupported(vtkRenderWindow *renWin, bool requireTexFloat, bool requireDepthFloat, bool requireTexInt)
vtkTextureObject::MinLOD
float MinLOD
Definition: vtkTextureObject.h:546