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:
88  static vtkFrameBufferObject2* New();
90  void PrintSelf(ostream& os, vtkIndent indent);
91 
93 
97  void SetContext(vtkRenderWindow *context);
98  vtkRenderWindow *GetContext();
100 
103  static bool IsSupported(vtkRenderWindow *renWin);
104 
109  void Bind(unsigned int mode);
110 
114  void UnBind(unsigned int mode);
115 
120  void SaveCurrentBindings();
121 
123 
126  void SaveCurrentBuffers();
127  void RestorePreviousBuffers(unsigned int mode);
129 
131 
132  void AddColorAttachment(
133  unsigned int mode,
134  unsigned int attId,
135  vtkTextureObject* tex);
137 
138  void AddTexColorAttachment(
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 
149  void AddColorAttachment(
150  unsigned int mode,
151  unsigned int attId,
152  vtkRenderbuffer* tex);
154 
155  void AddRenColorAttachment(
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);
184  void DeactivateReadBuffer();
186 
188 
189  void ActivateDrawBuffers(unsigned int n);
190  void ActivateDrawBuffers(unsigned int *ids, int n);
191  void DeactivateDrawBuffers();
193 
195 
199  static
200  void InitializeViewport(int width, int height);
202 
205  int CheckFrameBufferStatus(unsigned int mode);
206 
208 
211  static
212  bool GetFrameBufferStatus(
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 
236  vtkPixelBufferObject *DownloadColor1(
237  int extent[4],
238  int vtkType,
239  int channel);
241 
242  vtkPixelBufferObject *DownloadColor3(
243  int extent[4],
244  int vtkType);
245 
246  vtkPixelBufferObject *DownloadColor4(
247  int extent[4],
248  int vtkType);
249 
251 
254  vtkPixelBufferObject *DownloadDepth(
255  int extent[4],
256  int vtkType);
258 
260 
264  vtkPixelBufferObject *Download(
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
286  bool LoadRequiredExtensions(vtkRenderWindow *renWin);
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
OpenGL rendering window.
void RemoveRenColorAttachment(unsigned int mode, unsigned int attId)
void RemoveRenDepthAttachment(unsigned int mode)
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkWeakPointer< vtkRenderWindow > Context
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
#define VTKRENDERINGOPENGL_EXPORT
abstracts an OpenGL pixel buffer object.
Interface class for querying and using OpenGL extensions.
abstracts an OpenGL texture object.
create a window for renderers to draw into
Storage for FBO's.
static vtkObject * New()
void RemoveTexColorAttachment(unsigned int mode, unsigned int attId)
void RemoveTexDepthAttachment(unsigned int mode)
Interface to OpenGL framebuffer object.