00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00025 #ifndef __vtkFrameBufferObject_h
00026 #define __vtkFrameBufferObject_h
00027
00028 #include "vtkObject.h"
00029 #include "vtkSmartPointer.h"
00030 #include "vtkWeakPointer.h"
00031
00032 #include <vtkstd/vector>
00033
00034
00035 class vtkRenderWindow;
00036 class vtkTextureObject;
00037 class vtkOpenGLExtensionManager;
00038
00039 class VTK_RENDERING_EXPORT vtkFrameBufferObject : public vtkObject
00040 {
00041 public:
00042 static vtkFrameBufferObject* New();
00043 vtkTypeMacro(vtkFrameBufferObject, vtkObject);
00044 void PrintSelf(ostream& os, vtkIndent indent);
00045
00047
00051 void SetContext(vtkRenderWindow *context);
00052 vtkRenderWindow *GetContext();
00054
00056
00062 bool Start(int width,
00063 int height,
00064 bool shaderSupportsTextureInt);
00065 bool StartNonOrtho(int width,
00066 int height,
00067 bool shaderSupportsTextureInt);
00069
00071
00076 void RenderQuad(int minX,
00077 int maxX,
00078 int minY,
00079 int maxY);
00081
00084 void Bind();
00085
00088 void UnBind();
00089
00091
00092 void SetActiveBuffer(unsigned int index)
00093 {
00094 this->SetActiveBuffers(1, &index);
00095 }
00097
00099
00101 void SetActiveBuffers(int numbuffers,
00102 unsigned int indices[]);
00104
00105
00106
00107
00108
00109
00110
00111 void SetColorBuffer(unsigned int index,
00112 vtkTextureObject *texture,
00113 unsigned int zslice=0);
00114
00115 vtkTextureObject *GetColorBuffer(unsigned int index);
00116 void RemoveColorBuffer(unsigned int index);
00117 void RemoveAllColorBuffers();
00118
00120
00121 void SetDepthBuffer(vtkTextureObject *depthTexture);
00122 void RemoveDepthBuffer();
00124
00126
00128 vtkSetMacro(DepthBufferNeeded,bool);
00129 vtkGetMacro(DepthBufferNeeded,bool);
00131
00133
00134 void SetNumberOfRenderTargets(unsigned int);
00135 vtkGetMacro(NumberOfRenderTargets,unsigned int);
00137
00141 unsigned int GetMaximumNumberOfActiveTargets();
00142
00146 unsigned int GetMaximumNumberOfRenderTargets();
00147
00149
00150 vtkGetVector2Macro(LastSize,int);
00152
00154 static bool IsSupported(vtkRenderWindow *renWin);
00155
00156
00157 protected:
00159 void CheckFrameBufferStatus();
00160
00162 void DisplayFrameBufferAttachments();
00163
00165 void DisplayFrameBufferAttachment(unsigned int uattachment);
00166
00168 void DisplayDrawBuffers();
00169
00171 void DisplayReadBuffer();
00172
00174 void DisplayBuffer(int value);
00175
00176 vtkFrameBufferObject();
00177 ~vtkFrameBufferObject();
00178
00179 vtkWeakPointer<vtkRenderWindow> Context;
00180
00181 bool DepthBufferNeeded;
00182 bool ColorBuffersDirty;
00183 unsigned int FBOIndex;
00184 int PreviousFBOIndex;
00185 unsigned int DepthBuffer;
00186
00187 unsigned int NumberOfRenderTargets;
00188
00189
00190 int LastSize[2];
00191
00192 void CreateFBO();
00193 void DestroyFBO();
00194 void Create(int width,
00195 int height);
00196 void CreateBuffers(int width,
00197 int height);
00198 void CreateColorBuffers(int width,
00199 int height,
00200 bool shaderSupportsTextureInt);
00201 void Destroy();
00202 void DestroyBuffers();
00203 void DestroyColorBuffers();
00204 void ActivateBuffers();
00205
00207 bool LoadRequiredExtensions(vtkOpenGLExtensionManager *manager);
00208
00209 vtkstd::vector<unsigned int> UserZSlices;
00210 vtkstd::vector<vtkSmartPointer<vtkTextureObject> > UserColorBuffers;
00211 vtkstd::vector<vtkSmartPointer<vtkTextureObject> > ColorBuffers;
00212 vtkstd::vector<unsigned int> ActiveBuffers;
00213 vtkSmartPointer<vtkTextureObject> UserDepthBuffer;
00214 bool DepthBufferDirty;
00215 private:
00216 vtkFrameBufferObject(const vtkFrameBufferObject&);
00217 void operator=(const vtkFrameBufferObject&);
00218
00219 };
00220
00221 #endif