VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkFrameBufferObject.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 =========================================================================*/ 00028 #ifndef vtkFrameBufferObject_h 00029 #define vtkFrameBufferObject_h 00030 00031 #include "vtkObject.h" 00032 #include "vtkRenderingOpenGLModule.h" // For export macro 00033 #include "vtkSmartPointer.h" // needed for vtkSmartPointer. 00034 #include "vtkWeakPointer.h" // needed for vtkWeakPointer. 00035 //BTX 00036 #include <vector> // for the lists of logical buffers. 00037 //ETX 00038 00039 class vtkRenderWindow; 00040 class vtkTextureObject; 00041 class vtkRenderbuffer; 00042 class vtkPixelBufferObject; 00043 class vtkOpenGLExtensionManager; 00044 class vtkOpenGLRenderWindow; 00045 00046 class VTKRENDERINGOPENGL_EXPORT vtkFrameBufferObject : public vtkObject 00047 { 00048 public: 00049 static vtkFrameBufferObject* New(); 00050 vtkTypeMacro(vtkFrameBufferObject, vtkObject); 00051 void PrintSelf(ostream& os, vtkIndent indent); 00052 00054 00058 void SetContext(vtkRenderWindow *context); 00059 vtkRenderWindow *GetContext(); 00061 00063 00069 bool Start(int width, int height, bool shaderSupportsTextureInt); 00070 bool StartNonOrtho(int width, int height, bool shaderSupportsTextureInt); 00072 00078 void RenderQuad(int minX, int maxX, int minY, int maxY); 00079 00081 void Bind(); 00082 00085 void UnBind(); 00086 00088 00089 void SetActiveBuffer(unsigned int index) 00090 { 00091 this->SetActiveBuffers(1, &index); 00092 } 00094 00099 void SetActiveBuffers(int numbuffers, unsigned int indices[]); 00100 00102 00110 void SetColorBuffer( 00111 unsigned int index, 00112 vtkTextureObject *texture, 00113 unsigned int zslice=0); 00115 00116 vtkTextureObject *GetColorBuffer(unsigned int index); 00117 void RemoveColorBuffer(unsigned int index); 00118 void RemoveAllColorBuffers(); 00119 00121 00122 void SetDepthBuffer(vtkTextureObject *depthTexture); 00123 void RemoveDepthBuffer(); 00125 00127 00129 vtkSetMacro(DepthBufferNeeded,bool); 00130 vtkGetMacro(DepthBufferNeeded,bool); 00132 00134 00139 void SetNumberOfRenderTargets(unsigned int); 00140 vtkGetMacro(NumberOfRenderTargets,unsigned int); 00142 00146 unsigned int GetMaximumNumberOfActiveTargets(); 00147 00151 unsigned int GetMaximumNumberOfRenderTargets(); 00152 00154 00155 vtkGetVector2Macro(LastSize,int); 00157 00160 static bool IsSupported(vtkRenderWindow *renWin); 00161 00164 int CheckFrameBufferStatus(unsigned int mode); 00165 00166 //BTX 00167 protected: 00169 00170 static 00171 bool LoadRequiredExtensions(vtkRenderWindow *renWin); 00173 00174 // gen buffer (occurs when context is set) 00175 void CreateFBO(); 00176 00177 // delete buffer (occurs during destruction or context swicth) 00178 void DestroyFBO(); 00179 00180 // create texture or renderbuffer and attach 00181 // if user provided a texture just use that 00182 // mode specifies DRAW or READ 00183 void CreateDepthBuffer(int width, int height, unsigned int mode); 00184 00185 // create textures for each target and attach 00186 // if user provided textures use those, if the user 00187 // provides any then they need to provide all 00188 // mode specifies DRAW or READ 00189 void CreateColorBuffers( 00190 int width, 00191 int height, 00192 unsigned int mode, 00193 bool shaderSupportsTextureInt); 00194 00195 // detach and delete our reference(s) 00196 void DestroyDepthBuffer(); 00197 void DestroyColorBuffers(); 00198 00199 // glDrawBuffers 00200 void ActivateBuffers(); 00201 00203 void DisplayFrameBufferAttachments(); 00204 00206 void DisplayFrameBufferAttachment(unsigned int uattachment); 00207 00209 void DisplayDrawBuffers(); 00210 00212 void DisplayReadBuffer(); 00213 00215 void DisplayBuffer(int value); 00216 00217 vtkFrameBufferObject(); 00218 ~vtkFrameBufferObject(); 00219 00220 vtkWeakPointer<vtkRenderWindow> Context; 00221 00222 bool DepthBufferNeeded; 00223 bool ColorBuffersDirty; 00224 unsigned int FBOIndex; 00225 int PreviousFBOIndex; 00226 unsigned int DepthBuffer; 00227 unsigned int NumberOfRenderTargets; 00228 int LastSize[2]; 00229 std::vector<unsigned int> UserZSlices; 00230 std::vector<vtkSmartPointer<vtkTextureObject> > UserColorBuffers; 00231 std::vector<vtkSmartPointer<vtkTextureObject> > ColorBuffers; 00232 std::vector<unsigned int> ActiveBuffers; 00233 vtkSmartPointer<vtkTextureObject> UserDepthBuffer; 00234 bool DepthBufferDirty; 00235 00236 private: 00237 vtkFrameBufferObject(const vtkFrameBufferObject&); // Not implemented. 00238 void operator=(const vtkFrameBufferObject&); // Not implemented. 00239 //ETX 00240 }; 00241 00242 #endif