VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkTextureObject.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00025 #ifndef __vtkTextureObject_h 00026 #define __vtkTextureObject_h 00027 00028 #include "vtkRenderingOpenGLModule.h" // For export macro 00029 #include "vtkObject.h" 00030 #include "vtkWeakPointer.h" // needed for vtkWeakPointer. 00031 00032 class vtkRenderWindow; 00033 class vtkOpenGLExtensionManager; 00034 class vtkPixelBufferObject; 00035 00036 class VTKRENDERINGOPENGL_EXPORT vtkTextureObject : public vtkObject 00037 { 00038 public: 00039 00040 //BTX 00041 // DepthTextureCompareFunction values. 00042 enum 00043 { 00044 Lequal=0, // r=R<=Dt ? 1.0 : 0.0 00045 Gequal, // r=R>=Dt ? 1.0 : 0.0 00046 Less, // r=R<D_t ? 1.0 : 0.0 00047 Greater, // r=R>Dt ? 1.0 : 0.0 00048 Equal, // r=R==Dt ? 1.0 : 0.0 00049 NotEqual, // r=R!=Dt ? 1.0 : 0.0 00050 AlwaysTrue, // r=1.0 // WARNING "Always" is macro defined in X11/X.h... 00051 Never, // r=0.0 00052 NumberOfDepthTextureCompareFunctions 00053 }; 00054 00055 // DepthTextureMode values. 00056 enum 00057 { 00058 Luminance=0, // (R,G,B,A)=(r,r,r,1) 00059 Intensity, // (R,G,B,A)=(r,r,r,r) 00060 Alpha, // (R.G.B.A)=(0,0,0,r) 00061 NumberOfDepthTextureModes 00062 }; 00063 00064 // Wrap values. 00065 enum 00066 { 00067 Clamp=0, 00068 ClampToEdge, 00069 Repeat, 00070 ClampToBorder, 00071 MirroredRepeat, 00072 NumberOfWrapModes 00073 }; 00074 00075 // MinificationFilter values. 00076 enum 00077 { 00078 Nearest=0, 00079 Linear, 00080 NearestMipmapNearest, 00081 NearestMipmapLinear, 00082 LinearMipmapNearest, 00083 LinearMipmapLinear, 00084 NumberOfMinificationModes 00085 }; 00086 00087 // Internal depth format 00088 enum 00089 { 00090 Native=0, // will try to match with the depth buffer format. 00091 Fixed16, 00092 Fixed24, 00093 Fixed32, 00094 Float32, 00095 NumberOfDepthFormats 00096 }; 00097 00098 //ETX 00099 00100 static vtkTextureObject* New(); 00101 vtkTypeMacro(vtkTextureObject, vtkObject); 00102 void PrintSelf(ostream& os, vtkIndent indent); 00103 00105 00109 void SetContext(vtkRenderWindow*); 00110 vtkRenderWindow* GetContext(); 00112 00114 00116 vtkGetMacro(Width, unsigned int); 00117 vtkGetMacro(Height, unsigned int); 00118 vtkGetMacro(Depth, unsigned int); 00119 vtkGetMacro(Components, int); 00121 00122 vtkGetMacro(NumberOfDimensions, int); 00123 00125 00126 vtkGetMacro(Target, unsigned int); 00128 00130 00131 vtkGetMacro(Handle, unsigned int); 00133 00135 00137 void Bind(); 00138 void UnBind(); 00140 00143 bool IsBound(); 00144 00147 void SendParameters(); 00148 00150 00157 bool Create1D(int numComps, 00158 vtkPixelBufferObject *pbo, 00159 bool shaderSupportsTextureInt); 00161 00163 00166 bool Create2D(unsigned int width, unsigned int height, int numComps, 00167 vtkPixelBufferObject *pbo, 00168 bool shaderSupportsTextureInt); 00170 00172 00174 bool CreateDepth(unsigned int width, 00175 unsigned int height, 00176 int internalFormat, 00177 vtkPixelBufferObject *pbo); 00179 00181 00183 bool CreateDepthFromRaw(unsigned int width, 00184 unsigned int height, 00185 int internalFormat, 00186 int rawType, 00187 void *raw); 00189 00191 00192 bool AllocateDepth(unsigned int width,unsigned int height, 00193 int internalFormat); 00195 00198 bool Allocate1D(unsigned int width, int numComps,int vtkType); 00199 00201 00203 bool Allocate2D(unsigned int width,unsigned int height, int numComps, 00204 int vtkType); 00206 00208 00210 bool Allocate3D(unsigned int width,unsigned int height, 00211 unsigned int depth, int numComps, 00212 int vtkType); 00214 00215 00217 00220 bool Create3D(unsigned int width, unsigned int height, unsigned int depth, 00221 int numComps, vtkPixelBufferObject *pbo, 00222 bool shaderSupportsTextureInt); 00224 00225 00227 00230 bool Create2D(unsigned int width, unsigned int height, int numComps, 00231 int vtktype, 00232 bool shaderSupportsTextureInt); 00233 bool Create3D(unsigned int width, unsigned int height, unsigned int depth, 00234 int numComps, int vtktype, 00235 bool shaderSupportsTextureInt); 00237 00242 vtkPixelBufferObject* Download(); 00243 00245 int GetDataType(); 00246 00247 unsigned int GetInternalFormat(int vtktype, int numComps, 00248 bool shaderSupportsTextureInt); 00249 unsigned int GetFormat(int vtktype, int numComps, 00250 bool shaderSupportsTextureInt); 00251 00253 00256 vtkGetMacro(WrapS,int); 00257 vtkSetMacro(WrapS,int); 00259 00261 00264 vtkGetMacro(WrapT,int); 00265 vtkSetMacro(WrapT,int); 00267 00269 00272 vtkGetMacro(WrapR,int); 00273 vtkSetMacro(WrapR,int); 00275 00277 00282 vtkGetMacro(MinificationFilter,int); 00283 vtkSetMacro(MinificationFilter,int); 00285 00287 00289 vtkGetMacro(LinearMagnification,bool); 00290 vtkSetMacro(LinearMagnification,bool); 00292 00294 00296 vtkSetVector4Macro(BorderColor,float); 00297 vtkGetVector4Macro(BorderColor,float); 00299 00301 00304 vtkSetMacro(Priority,float); 00305 vtkGetMacro(Priority,float); 00307 00309 00311 vtkSetMacro(MinLOD,float); 00312 vtkGetMacro(MinLOD,float); 00314 00316 00318 vtkSetMacro(MaxLOD,float); 00319 vtkGetMacro(MaxLOD,float); 00321 00323 00326 vtkSetMacro(BaseLevel,int); 00327 vtkGetMacro(BaseLevel,int); 00329 00331 00334 vtkSetMacro(MaxLevel,int); 00335 vtkGetMacro(MaxLevel,int); 00337 00339 00345 vtkGetMacro(DepthTextureCompare,bool); 00346 vtkSetMacro(DepthTextureCompare,bool); 00348 00350 00360 vtkGetMacro(DepthTextureCompareFunction,int); 00361 vtkSetMacro(DepthTextureCompareFunction,int); 00363 00365 00370 vtkGetMacro(DepthTextureMode,int); 00371 vtkSetMacro(DepthTextureMode,int); 00373 00375 00377 vtkGetMacro(GenerateMipmap,bool); 00378 vtkSetMacro(GenerateMipmap,bool); 00380 00382 static bool IsSupported(vtkRenderWindow* renWin); 00383 00385 00404 void CopyToFrameBuffer(int srcXmin, 00405 int srcYmin, 00406 int srcXmax, 00407 int srcYmax, 00408 int dstXmin, 00409 int dstYmin, 00410 int width, 00411 int height); 00413 00414 00416 00424 void CopyFromFrameBuffer(int srcXmin, 00425 int srcYmin, 00426 int dstXmin, 00427 int dstYmin, 00428 int width, 00429 int height); 00431 00432 00433 //BTX 00434 protected: 00435 vtkTextureObject(); 00436 ~vtkTextureObject(); 00437 00439 bool LoadRequiredExtensions(vtkOpenGLExtensionManager*); 00440 00442 void CreateTexture(); 00443 00445 void DestroyTexture(); 00446 00447 int NumberOfDimensions; 00448 unsigned int Width; 00449 unsigned int Height; 00450 unsigned int Depth; 00451 00452 unsigned int Target; // GLenum 00453 unsigned int Format; // GLenum 00454 unsigned int Type; // GLenum 00455 int Components; 00456 00457 vtkWeakPointer<vtkRenderWindow> Context; 00458 unsigned int Handle; 00459 bool SupportsTextureInteger; 00460 bool SupportsTextureFloat; 00461 00462 int WrapS; 00463 int WrapT; 00464 int WrapR; 00465 int MinificationFilter; 00466 bool LinearMagnification; 00467 float BorderColor[4]; 00468 00469 float Priority; 00470 float MinLOD; 00471 float MaxLOD; 00472 int BaseLevel; 00473 int MaxLevel; 00474 00475 00476 bool DepthTextureCompare; 00477 int DepthTextureCompareFunction; 00478 int DepthTextureMode; 00479 00480 bool GenerateMipmap; 00481 00482 vtkTimeStamp SendParametersTime; 00483 00484 private: 00485 vtkTextureObject(const vtkTextureObject&); // Not implemented. 00486 void operator=(const vtkTextureObject&); // Not implemented. 00487 //ETX 00488 }; 00489 00490 #endif 00491 00492