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=========================================================================*/
29#ifndef vtkTextureObject_h
30#define vtkTextureObject_h
31
32#include "vtkRenderingOpenGLModule.h" // For export macro
33#include "vtkObject.h"
34#include "vtkWeakPointer.h" // for render context
35
36class vtkFloatArray;
38class vtkRenderWindow;
42
43class VTKRENDERINGOPENGL_EXPORT vtkTextureObject : public vtkObject
44{
45public:
46
47 // DepthTextureCompareFunction values.
48 enum
49 {
50 Lequal=0, // r=R<=Dt ? 1.0 : 0.0
51 Gequal, // r=R>=Dt ? 1.0 : 0.0
52 Less, // r=R<D_t ? 1.0 : 0.0
53 Greater, // r=R>Dt ? 1.0 : 0.0
54 Equal, // r=R==Dt ? 1.0 : 0.0
55 NotEqual, // r=R!=Dt ? 1.0 : 0.0
56 AlwaysTrue, // r=1.0 // WARNING "Always" is macro defined in X11/X.h...
57 Never, // r=0.0
58 NumberOfDepthTextureCompareFunctions
59 };
60
61 // DepthTextureMode values.
62 enum
63 {
64 Luminance=0, // (R,G,B,A)=(r,r,r,1)
65 Intensity, // (R,G,B,A)=(r,r,r,r)
66 Alpha, // (R,G,B,A)=(0,0,0,r)
67 NumberOfDepthTextureModes
68 };
69
70 // Wrap values.
71 enum
72 {
73 Clamp=0,
78 NumberOfWrapModes
79 };
80
81 // MinificationFilter values.
82 enum
83 {
84 Nearest=0,
90 NumberOfMinificationModes
91 };
92
93 // Internal depth format
94 enum
95 {
96 Native=0, // will try to match with the depth buffer format.
101 NumberOfDepthFormats
102 };
103
106 void PrintSelf(ostream& os, vtkIndent indent);
107
109
118
120
124 vtkGetMacro(Width, unsigned int);
125 vtkGetMacro(Height, unsigned int);
126 vtkGetMacro(Depth, unsigned int);
127 vtkGetMacro(Components, int);
128 unsigned int GetTuples()
129 { return this->Width*this->Height*this->Depth; }
131
132 vtkGetMacro(NumberOfDimensions, int);
133
135
138 vtkGetMacro(Target, unsigned int);
140
142
145 vtkGetMacro(Handle, unsigned int);
147
149
154 void Bind();
155 void UnBind();
157
159
162 void Activate(unsigned int texUnit);
163 void Deactivate(unsigned int texUnit);
165
166
171 bool IsBound();
172
174
181 vtkSetMacro(AutoParameters, int);
182 vtkGetMacro(AutoParameters, int);
184
195 bool Create1D(int numComps,
197 bool shaderSupportsTextureInt);
198
205 bool Create2D(unsigned int width, unsigned int height, int numComps,
207 bool shaderSupportsTextureInt);
208
213 bool CreateDepth(unsigned int width,
214 unsigned int height,
215 int internalFormat,
217
222 bool CreateDepthFromRaw(unsigned int width,
223 unsigned int height,
224 int internalFormat,
225 int rawType,
226 void *raw);
227
231 bool AllocateDepth(unsigned int width, unsigned int height,
232 int internalFormat);
233
238 bool Allocate1D(unsigned int width, int numComps, int vtkType);
239
244 bool Allocate2D(unsigned int width, unsigned int height, int numComps,
245 int vtkType);
246
251 bool Allocate3D(unsigned int width, unsigned int height,
252 unsigned int depth, int numComps,
253 int vtkType);
254
255
262 bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
263 int numComps, vtkPixelBufferObject *pbo,
264 bool shaderSupportsTextureInt);
265
266
268
273 bool Create2D(unsigned int width, unsigned int height, int numComps,
274 int vtktype,
275 bool shaderSupportsTextureInt);
276 bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
277 int numComps, int vtktype,
278 bool shaderSupportsTextureInt);
280
288
293
294 unsigned int GetInternalFormat(int vtktype, int numComps,
295 bool shaderSupportsTextureInt);
296 unsigned int GetFormat(int vtktype, int numComps,
297 bool shaderSupportsTextureInt);
298
300
306 vtkSetMacro(RequireDepthBufferFloat, bool);
307 vtkGetMacro(RequireDepthBufferFloat, bool);
308 vtkGetMacro(SupportsDepthBufferFloat, bool);
310
312
318 vtkSetMacro(RequireTextureFloat, bool);
319 vtkGetMacro(RequireTextureFloat, bool);
320 vtkGetMacro(SupportsTextureFloat, bool);
322
324
330 vtkSetMacro(RequireTextureInteger, bool);
331 vtkGetMacro(RequireTextureInteger, bool);
332 vtkGetMacro(SupportsTextureInteger, bool);
334
336
346 vtkGetMacro(WrapS, int);
347 vtkSetMacro(WrapS, int);
349
351
361 vtkGetMacro(WrapT, int);
362 vtkSetMacro(WrapT, int);
364
366
376 vtkGetMacro(WrapR, int);
377 vtkSetMacro(WrapR, int);
379
381
394 vtkGetMacro(MinificationFilter, int);
395 vtkSetMacro(MinificationFilter, int);
397
399
406 vtkGetMacro(MagnificationFilter, int);
407 vtkSetMacro(MagnificationFilter, int);
409
415 { this->SetMagnificationFilter(val?Linear:Nearest); }
416
418 { return this->MagnificationFilter==Linear; }
419
421
426 vtkSetVector4Macro(BorderColor, float);
427 vtkGetVector4Macro(BorderColor, float);
429
431
436 vtkSetMacro(Priority, float);
437 vtkGetMacro(Priority, float);
439
441
445 vtkSetMacro(MinLOD, float);
446 vtkGetMacro(MinLOD, float);
448
450
454 vtkSetMacro(MaxLOD, float);
455 vtkGetMacro(MaxLOD, float);
457
459
464 vtkSetMacro(BaseLevel, int);
465 vtkGetMacro(BaseLevel, int);
467
469
474 vtkSetMacro(MaxLevel, int);
475 vtkGetMacro(MaxLevel, int);
477
479
489 vtkGetMacro(DepthTextureCompare, bool);
490 vtkSetMacro(DepthTextureCompare, bool);
492
494
514 vtkGetMacro(DepthTextureCompareFunction, int);
515 vtkSetMacro(DepthTextureCompareFunction, int);
517
519
528 vtkGetMacro(DepthTextureMode, int);
529 vtkSetMacro(DepthTextureMode, int);
531
533
538 vtkGetMacro(GenerateMipmap, bool);
539 vtkSetMacro(GenerateMipmap, bool);
541
547 static bool IsSupported(
548 vtkRenderWindow* renWin,
549 bool requireTexFloat,
550 bool requireDepthFloat,
551 bool requireTexInt);
552
556 static bool IsSupported(vtkRenderWindow* renWin)
557 { return vtkTextureObject::IsSupported(renWin, false, false, false); }
558
585 void CopyToFrameBuffer(int srcXmin,
586 int srcYmin,
587 int srcXmax,
588 int srcYmax,
589 int dstXmin,
590 int dstYmin,
591 int width,
592 int height);
593
594
606 void CopyFromFrameBuffer(int srcXmin,
607 int srcYmin,
608 int dstXmin,
609 int dstYmin,
610 int width,
611 int height);
612
613protected:
616
621
626
631
633 unsigned int Width;
634 unsigned int Height;
635 unsigned int Depth;
636
637 unsigned int Target; // GLenum
638 unsigned int Format; // GLenum
639 unsigned int Type; // GLenum
641
643 unsigned int Handle;
650
651 int WrapS;
652 int WrapT;
653 int WrapR;
657 float BorderColor[4];
658
659 float Priority;
660 float MinLOD;
661 float MaxLOD;
664
665
669
671
674
675private:
676 vtkTextureObject(const vtkTextureObject&) VTK_DELETE_FUNCTION;
677 void operator=(const vtkTextureObject&) VTK_DELETE_FUNCTION;
678
679};
680
681#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,...
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
vtkRenderWindow * GetContext()
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
static vtkTextureObject * New()
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.
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.