VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkTextureObject.h,v $ 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 "vtkObject.h" 00029 #include "vtkWeakPointer.h" // needed for vtkWeakPointer. 00030 00031 class vtkRenderWindow; 00032 class vtkOpenGLExtensionManager; 00033 class vtkPixelBufferObject; 00034 00035 class VTK_RENDERING_EXPORT vtkTextureObject : public vtkObject 00036 { 00037 public: 00038 00039 //BTX 00040 // DepthTextureCompareFunction values. 00041 enum 00042 { 00043 Lequal=0, // r=R<=Dt ? 1.0 : 0.0 00044 Gequal, // r=R>=Dt ? 1.0 : 0.0 00045 Less, // r=R<D_t ? 1.0 : 0.0 00046 Greater, // r=R>Dt ? 1.0 : 0.0 00047 Equal, // r=R==Dt ? 1.0 : 0.0 00048 NotEqual, // r=R!=Dt ? 1.0 : 0.0 00049 AlwaysTrue, // r=1.0 // WARNING "Always" is macro defined in X11/X.h... 00050 Never // r=0.0 00051 }; 00052 00053 // DepthTextureMode values. 00054 enum 00055 { 00056 Luminance=0, // (R,G,B,A)=(r,r,r,1) 00057 Intensity, // (R,G,B,A)=(r,r,r,r) 00058 Alpha // (R.G.B.A)=(0,0,0,r) 00059 }; 00060 00061 // Wrap values. 00062 enum 00063 { 00064 Clamp=0, 00065 ClampToEdge, 00066 Repeat, 00067 ClampToBorder, 00068 MirroredRepeat 00069 }; 00070 00071 // MinificationFilter values. 00072 enum 00073 { 00074 Nearest=0, 00075 Linear, 00076 NearestMipmapNearest, 00077 NearestMipmapLinear, 00078 LinearMipmapNearest, 00079 LinearMipmapLinear 00080 }; 00081 //ETX 00082 00083 static vtkTextureObject* New(); 00084 vtkTypeRevisionMacro(vtkTextureObject, vtkObject); 00085 void PrintSelf(ostream& os, vtkIndent indent); 00086 00088 00092 void SetContext(vtkRenderWindow*); 00093 vtkRenderWindow* GetContext(); 00095 00097 00099 vtkGetMacro(Width, unsigned int); 00100 vtkGetMacro(Height, unsigned int); 00101 vtkGetMacro(Depth, unsigned int); 00102 vtkGetMacro(Components, int); 00104 00105 vtkGetMacro(NumberOfDimensions, int); 00106 00108 00109 vtkGetMacro(Target, int); 00111 00113 00114 vtkGetMacro(Handle, unsigned int); 00116 00118 00120 void Bind(); 00121 void UnBind(); 00123 00125 bool IsBound(); 00126 00129 void SendParameters(); 00130 00132 00139 bool Create1D(int numComps, 00140 vtkPixelBufferObject *pbo, 00141 bool shaderSupportsTextureInt); 00143 00145 00148 bool Create2D(unsigned int width, unsigned int height, int numComps, 00149 vtkPixelBufferObject *pbo, 00150 bool shaderSupportsTextureInt); 00152 00154 00157 bool Create3D(unsigned int width, unsigned int height, unsigned int depth, 00158 int numComps, vtkPixelBufferObject *pbo, 00159 bool shaderSupportsTextureInt); 00161 00162 00164 00167 bool Create2D(unsigned int width, unsigned int height, int numComps, 00168 int vtktype, 00169 bool shaderSupportsTextureInt); 00170 bool Create3D(unsigned int width, unsigned int height, unsigned int depth, 00171 int numComps, int vtktype, 00172 bool shaderSupportsTextureInt); 00174 00179 vtkPixelBufferObject* Download(); 00180 00182 int GetDataType(); 00183 00184 int GetInternalFormat(int vtktype, int numComps, 00185 bool shaderSupportsTextureInt); 00186 int GetFormat(int vtktype, int numComps, 00187 bool shaderSupportsTextureInt); 00188 00190 00193 vtkGetMacro(WrapS,int); 00194 vtkSetMacro(WrapS,int); 00196 00198 00201 vtkGetMacro(WrapT,int); 00202 vtkSetMacro(WrapT,int); 00204 00206 00209 vtkGetMacro(WrapR,int); 00210 vtkSetMacro(WrapR,int); 00212 00214 00219 vtkGetMacro(MinificationFilter,int); 00220 vtkSetMacro(MinificationFilter,int); 00222 00224 00226 vtkGetMacro(LinearMagnification,bool); 00227 vtkSetMacro(LinearMagnification,bool); 00229 00231 00233 vtkSetVector4Macro(BorderColor,float); 00234 vtkGetVector4Macro(BorderColor,float); 00236 00238 00241 vtkSetMacro(Priority,float); 00242 vtkGetMacro(Priority,float); 00244 00246 00248 vtkSetMacro(MinLOD,float); 00249 vtkGetMacro(MinLOD,float); 00251 00253 00255 vtkSetMacro(MaxLOD,float); 00256 vtkGetMacro(MaxLOD,float); 00258 00260 00263 vtkSetMacro(BaseLevel,int); 00264 vtkGetMacro(BaseLevel,int); 00266 00268 00271 vtkSetMacro(MaxLevel,int); 00272 vtkGetMacro(MaxLevel,int); 00274 00276 00282 vtkGetMacro(DepthTextureCompare,bool); 00283 vtkSetMacro(DepthTextureCompare,bool); 00285 00287 00297 vtkGetMacro(DepthTextureCompareFunction,int); 00298 vtkSetMacro(DepthTextureCompareFunction,int); 00300 00302 00307 vtkGetMacro(DepthTextureMode,int); 00308 vtkSetMacro(DepthTextureMode,int); 00310 00312 00314 vtkGetMacro(GenerateMipmap,bool); 00315 vtkSetMacro(GenerateMipmap,bool); 00317 00319 static bool IsSupported(vtkRenderWindow* renWin); 00320 //BTX 00321 protected: 00322 vtkTextureObject(); 00323 ~vtkTextureObject(); 00324 00326 bool LoadRequiredExtensions(vtkOpenGLExtensionManager*); 00327 00329 void CreateTexture(); 00330 00332 void DestroyTexture(); 00333 00334 int NumberOfDimensions; 00335 unsigned int Width; 00336 unsigned int Height; 00337 unsigned int Depth; 00338 00339 int Target; // GLenum 00340 int Format; // GLint 00341 int Type; // GLint 00342 int Components; 00343 00344 vtkWeakPointer<vtkRenderWindow> Context; 00345 unsigned int Handle; 00346 bool SupportsTextureInteger; 00347 00348 int WrapS; 00349 int WrapT; 00350 int WrapR; 00351 int MinificationFilter; 00352 bool LinearMagnification; 00353 float BorderColor[4]; 00354 00355 float Priority; 00356 float MinLOD; 00357 float MaxLOD; 00358 int BaseLevel; 00359 int MaxLevel; 00360 00361 00362 bool DepthTextureCompare; 00363 int DepthTextureCompareFunction; 00364 int DepthTextureMode; 00365 00366 bool GenerateMipmap; 00367 00368 vtkTimeStamp SendParametersTime; 00369 00370 private: 00371 vtkTextureObject(const vtkTextureObject&); // Not implemented. 00372 void operator=(const vtkTextureObject&); // Not implemented. 00373 //ETX 00374 }; 00375 00376 #endif 00377 00378