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 "vtkRenderingOpenGL2Module.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;
83 
84 class VTKRENDERINGOPENGL2_EXPORT vtkFrameBufferObject2 : public vtkObject
85 {
86 public:
89  void PrintSelf(ostream& os, vtkIndent indent);
90 
92 
96  void SetContext(vtkRenderWindow *context);
99 
102  static bool IsSupported(vtkRenderWindow *renWin);
103 
108  void Bind(unsigned int mode);
109 
113  void UnBind(unsigned int mode);
114 
120 
122 
126  void RestorePreviousBuffers(unsigned int mode);
128 
130 
132  unsigned int mode,
133  unsigned int attId,
134  vtkTextureObject* tex);
136 
138  unsigned int mode,
139  unsigned int attId,
140  unsigned int handle);
141 
142  void RemoveTexColorAttachments(unsigned int mode, unsigned int num);
143  void RemoveTexColorAttachment(unsigned int mode, unsigned int attId)
144  { this->AddTexColorAttachment(mode, attId, 0U); }
145 
147 
149  unsigned int mode,
150  unsigned int attId,
151  vtkRenderbuffer* tex);
153 
155  unsigned int mode,
156  unsigned int attId,
157  unsigned int handle);
158 
159  void RemoveRenColorAttachments(unsigned int mode, unsigned int num);
160  void RemoveRenColorAttachment(unsigned int mode, unsigned int attId)
161  { this->AddRenColorAttachment(mode, attId, 0U); }
162 
164 
165  void AddDepthAttachment(unsigned int mode, vtkTextureObject* tex);
166  void AddTexDepthAttachment(unsigned int mode, unsigned int handle);
167  void RemoveTexDepthAttachment(unsigned int mode)
168  { this->AddTexDepthAttachment(mode, 0U); }
170 
172 
173  void AddDepthAttachment(unsigned int mode, vtkRenderbuffer* tex);
174  void AddRenDepthAttachment(unsigned int mode, unsigned int handle);
175  void RemoveRenDepthAttachment(unsigned int mode)
176  { this->AddRenDepthAttachment(mode, 0U); }
178 
180 
181  void ActivateDrawBuffer(unsigned int id);
182  void ActivateReadBuffer(unsigned int id);
185 
187 
188  void ActivateDrawBuffers(unsigned int n);
189  void ActivateDrawBuffers(unsigned int *ids, int n);
192 
194 
198  static
201 
204  int CheckFrameBufferStatus(unsigned int mode);
205 
207 
210  static
212  unsigned int mode,
213  const char *&desc);
215 
217 
220  static
221  int Blit(
222  int srcExt[4],
223  int destExt[4],
224  unsigned int bits,
225  unsigned int mapping);
227 
229 
236  int extent[4],
237  int vtkType,
238  int channel);
240 
242  int extent[4],
243  int vtkType);
244 
246  int extent[4],
247  int vtkType);
248 
250 
254  int extent[4],
255  int vtkType);
257 
259 
264  int extent[4],
265  int vtkType,
266  int nComps,
267  int oglType,
268  int oglFormat);
270 
271  static
272  void Download(
273  int extent[4],
274  int vtkType,
275  int nComps,
276  int oglType,
277  int oglFormat,
278  vtkPixelBufferObject *pbo);
279 
280 //BTX
281 protected:
283 
284  static
287 
288  // gen buffer (occurs when context is set)
289  void CreateFBO();
290 
291  // delete buffer (occurs during destruction or context swicth)
292  void DestroyFBO();
293 
294 
296  int GetOpenGLType(int vtkType);
297 
300 
302 
303  unsigned int FBOIndex;
304  unsigned int PreviousDrawFBO;
305  unsigned int PreviousReadFBO;
306  unsigned int DepthBuffer;
307  unsigned int PreviousDrawBuffer;
308  unsigned int PreviousReadBuffer;
309 
310 private:
311  vtkFrameBufferObject2(const vtkFrameBufferObject2&); // Not implemented.
312  void operator=(const vtkFrameBufferObject2&); // Not implemented.
313 
314  friend class vtkRenderbuffer; // needs access to LoadRequiredExtentsions
315 //ETX
316 };
317 
318 #endif
vtkFrameBufferObject2::GetOpenGLType
int GetOpenGLType(int vtkType)
vtkFrameBufferObject2::RemoveTexDepthAttachment
void RemoveTexDepthAttachment(unsigned int mode)
Definition: vtkFrameBufferObject2.h:167
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:175
vtkFrameBufferObject2::CreateFBO
void CreateFBO()
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:160
vtkFrameBufferObject2::AddColorAttachment
void AddColorAttachment(unsigned int mode, unsigned int attId, vtkRenderbuffer *tex)
vtkFrameBufferObject2::DownloadColor3
vtkPixelBufferObject * DownloadColor3(int extent[4], int vtkType)
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::ActivateDrawBuffer
void ActivateDrawBuffer(unsigned int id)
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::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:143
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::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
vtkgl::height
GLint GLint GLsizei GLsizei height
Definition: vtkgl.h:11316