VTK
vtkFrameBufferObject2.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkFrameBufferObject2.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 =========================================================================*/
44 #ifndef vtkFrameBufferObject2_h
45 #define vtkFrameBufferObject2_h
46 
47 #include "vtkObject.h"
48 #include "vtkRenderingOpenGLModule.h" // For export macro
49 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
50 #include "vtkWeakPointer.h" // needed for vtkWeakPointer.
51 
53 
57 #ifdef NDEBUG
58 # define vtkCheckFrameBufferStatusMacro(mode)
59 # define vtkStaticCheckFrameBufferStatusMacro(mode)
60 #else
61 # define vtkCheckFrameBufferStatusMacroImpl(macro, mode) \
62 { \
63 const char *eStr; \
64 bool ok = vtkFrameBufferObject2::GetFrameBufferStatus(mode, eStr); \
65 if (!ok) \
66  { \
67  macro( \
68  << "OpenGL ERROR. The FBO is incomplete : " << eStr); \
69  } \
70  }
71 # define vtkCheckFrameBufferStatusMacro(mode) \
72  vtkCheckFrameBufferStatusMacroImpl(vtkErrorMacro, mode)
73 # define vtkStaticCheckFrameBufferStatusMacro(mode) \
74  vtkCheckFrameBufferStatusMacroImpl(vtkGenericWarningMacro, mode)
75 #endif
76 
77 
78 class vtkRenderWindow;
79 class vtkTextureObject;
80 class vtkRenderbuffer;
84 
86 {
87 public:
90  void PrintSelf(ostream& os, vtkIndent indent);
91 
93 
97  void SetContext(vtkRenderWindow *context);
100 
103  static bool IsSupported(vtkRenderWindow *renWin);
104 
109  void Bind(unsigned int mode);
110 
114  void UnBind(unsigned int mode);
115 
121 
123 
127  void RestorePreviousBuffers(unsigned int mode);
129 
131 
133  unsigned int mode,
134  unsigned int attId,
135  vtkTextureObject* tex);
137 
139  unsigned int mode,
140  unsigned int attId,
141  unsigned int handle);
142 
143  void RemoveTexColorAttachments(unsigned int mode, unsigned int num);
144  void RemoveTexColorAttachment(unsigned int mode, unsigned int attId)
145  { this->AddTexColorAttachment(mode, attId, 0U); }
146 
148 
150  unsigned int mode,
151  unsigned int attId,
152  vtkRenderbuffer* tex);
154 
156  unsigned int mode,
157  unsigned int attId,
158  unsigned int handle);
159 
160  void RemoveRenColorAttachments(unsigned int mode, unsigned int num);
161  void RemoveRenColorAttachment(unsigned int mode, unsigned int attId)
162  { this->AddRenColorAttachment(mode, attId, 0U); }
163 
165 
166  void AddDepthAttachment(unsigned int mode, vtkTextureObject* tex);
167  void AddTexDepthAttachment(unsigned int mode, unsigned int handle);
168  void RemoveTexDepthAttachment(unsigned int mode)
169  { this->AddTexDepthAttachment(mode, 0U); }
171 
173 
174  void AddDepthAttachment(unsigned int mode, vtkRenderbuffer* tex);
175  void AddRenDepthAttachment(unsigned int mode, unsigned int handle);
176  void RemoveRenDepthAttachment(unsigned int mode)
177  { this->AddRenDepthAttachment(mode, 0U); }
179 
181 
182  void ActivateDrawBuffer(unsigned int id);
183  void ActivateReadBuffer(unsigned int id);
186 
188 
189  void ActivateDrawBuffers(unsigned int n);
190  void ActivateDrawBuffers(unsigned int *ids, int n);
193 
195 
199  static
202 
205  int CheckFrameBufferStatus(unsigned int mode);
206 
208 
211  static
213  unsigned int mode,
214  const char *&desc);
216 
218 
221  static
222  int Blit(
223  int srcExt[4],
224  int destExt[4],
225  unsigned int bits,
226  unsigned int mapping);
228 
230 
237  int extent[4],
238  int vtkType,
239  int channel);
241 
243  int extent[4],
244  int vtkType);
245 
247  int extent[4],
248  int vtkType);
249 
251 
255  int extent[4],
256  int vtkType);
258 
260 
265  int extent[4],
266  int vtkType,
267  int nComps,
268  int oglType,
269  int oglFormat);
271 
272  static
273  void Download(
274  int extent[4],
275  int vtkType,
276  int nComps,
277  int oglType,
278  int oglFormat,
279  vtkPixelBufferObject *pbo);
280 
281 //BTX
282 protected:
284 
285  static
288 
289  // gen buffer (occurs when context is set)
290  void CreateFBO();
291 
292  // delete buffer (occurs during destruction or context swicth)
293  void DestroyFBO();
294 
295 
297  int GetOpenGLType(int vtkType);
298 
301 
303 
304  unsigned int FBOIndex;
305  unsigned int PreviousDrawFBO;
306  unsigned int PreviousReadFBO;
307  unsigned int DepthBuffer;
308  unsigned int PreviousDrawBuffer;
309  unsigned int PreviousReadBuffer;
310 
311 private:
312  vtkFrameBufferObject2(const vtkFrameBufferObject2&); // Not implemented.
313  void operator=(const vtkFrameBufferObject2&); // Not implemented.
314 
315  friend class vtkRenderbuffer; // needs access to LoadRequiredExtentsions
316 //ETX
317 };
318 
319 #endif
vtkFrameBufferObject2::GetOpenGLType
int GetOpenGLType(int vtkType)
vtkFrameBufferObject2::PreviousDrawBuffer
unsigned int PreviousDrawBuffer
Definition: vtkFrameBufferObject2.h:308
vtkFrameBufferObject2::RemoveTexDepthAttachment
void RemoveTexDepthAttachment(unsigned int mode)
Definition: vtkFrameBufferObject2.h:168
vtkFrameBufferObject2::AddDepthAttachment
void AddDepthAttachment(unsigned int mode, vtkRenderbuffer *tex)
vtkgl::mapping
GLenum GLenum GLenum GLenum mapping
Definition: vtkgl.h:15941
vtkFrameBufferObject2::InitializeViewport
static void InitializeViewport(int width, int height)
vtkFrameBufferObject2::AddRenColorAttachment
void AddRenColorAttachment(unsigned int mode, unsigned int attId, unsigned int handle)
vtkFrameBufferObject2::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkFrameBufferObject2::vtkFrameBufferObject2
vtkFrameBufferObject2()
vtkFrameBufferObject2::RemoveRenDepthAttachment
void RemoveRenDepthAttachment(unsigned int mode)
Definition: vtkFrameBufferObject2.h:176
vtkFrameBufferObject2::CreateFBO
void CreateFBO()
vtkRenderingOpenGLModule.h
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkgl::n
GLclampd n
Definition: vtkgl.h:14370
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkFrameBufferObject2::RestorePreviousBuffers
void RestorePreviousBuffers(unsigned int mode)
vtkFrameBufferObject2::UnBind
void UnBind(unsigned int mode)
vtkFrameBufferObject2::Download
vtkPixelBufferObject * Download(int extent[4], int vtkType, int nComps, int oglType, int oglFormat)
vtkFrameBufferObject2::AddTexDepthAttachment
void AddTexDepthAttachment(unsigned int mode, unsigned int handle)
vtkFrameBufferObject2::AddTexColorAttachment
void AddTexColorAttachment(unsigned int mode, unsigned int attId, unsigned int handle)
vtkFrameBufferObject2::DeactivateDrawBuffers
void DeactivateDrawBuffers()
vtkFrameBufferObject2::RemoveRenColorAttachment
void RemoveRenColorAttachment(unsigned int mode, unsigned int attId)
Definition: vtkFrameBufferObject2.h:161
vtkFrameBufferObject2::AddColorAttachment
void AddColorAttachment(unsigned int mode, unsigned int attId, vtkRenderbuffer *tex)
vtkFrameBufferObject2::DownloadColor3
vtkPixelBufferObject * DownloadColor3(int extent[4], int vtkType)
vtkOpenGLExtensionManager
Interface class for querying and using OpenGL extensions.
vtkFrameBufferObject2::DeactivateReadBuffer
void DeactivateReadBuffer()
vtkFrameBufferObject2::RemoveRenColorAttachments
void RemoveRenColorAttachments(unsigned int mode, unsigned int num)
vtkgl::ids
GLuint * ids
Definition: vtkgl.h:11831
vtkFrameBufferObject2::ActivateDrawBuffers
void ActivateDrawBuffers(unsigned int n)
vtkFrameBufferObject2::New
static vtkFrameBufferObject2 * New()
vtkFrameBufferObject2::SaveCurrentBuffers
void SaveCurrentBuffers()
vtkFrameBufferObject2::ActivateDrawBuffers
void ActivateDrawBuffers(unsigned int *ids, int n)
vtkFrameBufferObject2::PreviousReadFBO
unsigned int PreviousReadFBO
Definition: vtkFrameBufferObject2.h:306
vtkFrameBufferObject2::ActivateDrawBuffer
void ActivateDrawBuffer(unsigned int id)
vtkFrameBufferObject2::DepthBuffer
unsigned int DepthBuffer
Definition: vtkFrameBufferObject2.h:307
vtkFrameBufferObject2::FBOIndex
unsigned int FBOIndex
Definition: vtkFrameBufferObject2.h:304
vtkFrameBufferObject2::LoadRequiredExtensions
static bool LoadRequiredExtensions(vtkRenderWindow *renWin)
vtkgl::num
GLuint GLuint num
Definition: vtkgl.h:16907
vtkFrameBufferObject2::GetFrameBufferStatus
static bool GetFrameBufferStatus(unsigned int mode, const char *&desc)
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkTextureObject
abstracts an OpenGL texture object.
Definition: vtkTextureObject.h:40
vtkFrameBufferObject2::~vtkFrameBufferObject2
~vtkFrameBufferObject2()
vtkFrameBufferObject2::AddRenDepthAttachment
void AddRenDepthAttachment(unsigned int mode, unsigned int handle)
vtkSmartPointer.h
vtkFrameBufferObject2::CheckFrameBufferStatus
int CheckFrameBufferStatus(unsigned int mode)
vtkFrameBufferObject2::RemoveTexColorAttachments
void RemoveTexColorAttachments(unsigned int mode, unsigned int num)
vtkFrameBufferObject2::DownloadColor4
vtkPixelBufferObject * DownloadColor4(int extent[4], int vtkType)
vtkWeakPointer.h
vtkFrameBufferObject2::ActivateReadBuffer
void ActivateReadBuffer(unsigned int id)
vtkFrameBufferObject2::SaveCurrentBindings
void SaveCurrentBindings()
vtkFrameBufferObject2::Context
vtkWeakPointer< vtkRenderWindow > Context
Definition: vtkFrameBufferObject2.h:302
vtkFrameBufferObject2::GetContext
vtkRenderWindow * GetContext()
vtkObject.h
vtkFrameBufferObject2::SetContext
void SetContext(vtkRenderWindow *context)
vtkgl::width
GLint GLint GLsizei width
Definition: vtkgl.h:11316
vtkFrameBufferObject2::Download
static void Download(int extent[4], int vtkType, int nComps, int oglType, int oglFormat, vtkPixelBufferObject *pbo)
vtkFrameBufferObject2::AddColorAttachment
void AddColorAttachment(unsigned int mode, unsigned int attId, vtkTextureObject *tex)
vtkFrameBufferObject2::DownloadColor1
vtkPixelBufferObject * DownloadColor1(int extent[4], int vtkType, int channel)
vtkFrameBufferObject2::DestroyFBO
void DestroyFBO()
vtkFrameBufferObject2::Bind
void Bind(unsigned int mode)
vtkFrameBufferObject2::AddDepthAttachment
void AddDepthAttachment(unsigned int mode, vtkTextureObject *tex)
vtkFrameBufferObject2::Blit
static int Blit(int srcExt[4], int destExt[4], unsigned int bits, unsigned int mapping)
vtkFrameBufferObject2::RemoveTexColorAttachment
void RemoveTexColorAttachment(unsigned int mode, unsigned int attId)
Definition: vtkFrameBufferObject2.h:144
vtkFrameBufferObject2::PreviousDrawFBO
unsigned int PreviousDrawFBO
Definition: vtkFrameBufferObject2.h:305
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:41
vtkX3D::extent
@ extent
Definition: vtkX3D.h:345
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:89
vtkgl::bits
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: vtkgl.h:18250
vtkgl::mode
GLenum mode
Definition: vtkgl.h:12325
vtkFrameBufferObject2
Interface to OpenGL framebuffer object.
Definition: vtkFrameBufferObject2.h:86
vtkFrameBufferObject2::PreviousReadBuffer
unsigned int PreviousReadBuffer
Definition: vtkFrameBufferObject2.h:309
vtkFrameBufferObject2::IsSupported
static bool IsSupported(vtkRenderWindow *renWin)
vtkPixelBufferObject
abstracts an OpenGL pixel buffer object.
Definition: vtkPixelBufferObject.h:43
vtkWeakPointer< vtkRenderWindow >
vtkFrameBufferObject2::DownloadDepth
vtkPixelBufferObject * DownloadDepth(int extent[4], int vtkType)
vtkRenderbuffer
Storage for FBO's.
Definition: vtkRenderbuffer.h:32
VTKRENDERINGOPENGL_EXPORT
#define VTKRENDERINGOPENGL_EXPORT
Definition: vtkRenderingOpenGLModule.h:15
vtkgl::height
GLint GLint GLsizei GLsizei height
Definition: vtkgl.h:11316