gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
framebufferObject.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2005,
3  Aaron Lefohn (lefohn@cs.ucdavis.edu)
4  Robert Strzodka (strzodka@stanford.edu)
5  Adam Moerschell (atmoerschell@ucdavis.edu)
6  All rights reserved.
7 
8  This software is licensed under the BSD open-source license. See
9  http://www.opensource.org/licenses/bsd-license.php for more detail.
10 
11  *************************************************************
12  Redistribution and use in source and binary forms, with or
13  without modification, are permitted provided that the following
14  conditions are met:
15 
16  Redistributions of source code must retain the above copyright notice,
17  this list of conditions and the following disclaimer.
18 
19  Redistributions in binary form must reproduce the above copyright notice,
20  this list of conditions and the following disclaimer in the documentation
21  and/or other materials provided with the distribution.
22 
23  Neither the name of the University of Californa, Davis nor the names of
24  the contributors may be used to endorse or promote products derived
25  from this software without specific prior written permission.
26 
27  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
31  THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
32  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
34  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
38  THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
39  OF SUCH DAMAGE.
40 */
41 
42 #ifndef UCDAVIS_FRAMEBUFFER_OBJECT_H
43 #define UCDAVIS_FRAMEBUFFER_OBJECT_H
44 
45 // Added by Franck P. Vidal
46 #ifndef __gVirtualXRayConfig_h
48 #endif
49 
50 #include <iostream>
51 
108 {
109 public:
112  virtual ~FramebufferObject();
113 
115  void Bind();
116 
118  virtual void AttachTexture( GLenum texTarget,
119  GLuint texId,
120  GLenum attachment = GL_COLOR_ATTACHMENT0,
121  int mipLevel = 0,
122  int zSlice = 0 );
123 
127  virtual void AttachTextures( int numTextures,
128  GLenum texTarget[],
129  GLuint texId[],
130  GLenum attachment[] = NULL,
131  int mipLevel[] = NULL,
132  int zSlice[] = NULL );
133 
135  virtual void AttachRenderBuffer( GLuint buffId,
136  GLenum attachment = GL_COLOR_ATTACHMENT0);
137 
142  virtual void AttachRenderBuffers( int numBuffers, GLuint buffId[],
143  GLenum attachment[] = NULL );
144 
146  void Unattach( GLenum attachment );
147 
149  void UnattachAll();
150 
158 #ifndef NDEBUG
159  bool IsValid( std::ostream& ostr = std::cerr );
160 #else
161  bool IsValid( std::ostream& ostr = std::cerr ) {
162  return true;
163  }
164 #endif
165 
168  GLenum GetAttachedType( GLenum attachment );
169 
172  GLuint GetAttachedId( GLenum attachment );
173 
175  GLint GetAttachedMipLevel( GLenum attachment );
176 
178  GLint GetAttachedCubeFace( GLenum attachment );
179 
181  // GLint GetAttachedZSlice( GLenum attachment );
183 
184 
187  static int GetMaxColorAttachments();
188 
198  static void Disable();
200 
201  inline GLuint getID() const {return m_fboId;}
202 
203 protected:
204  void _GuardedBind();
205  void _GuardedUnbind();
206  void _FramebufferTextureND( GLenum attachment, GLenum texTarget,
207  GLuint texId, int mipLevel, int zSlice );
208  static GLuint _GenerateFboId();
209 
210 private:
211  GLuint m_fboId;
212  GLint m_savedFboId;
213 };
214 
215 #endif
virtual void AttachRenderBuffers(int numBuffers, GLuint buffId[], GLenum attachment[]=NULL)
virtual void AttachTextures(int numTextures, GLenum texTarget[], GLuint texId[], GLenum attachment[]=NULL, int mipLevel[]=NULL, int zSlice[]=NULL)
GLint GetAttachedCubeFace(GLenum attachment)
Which cube face is currently attached to "attachment?".
GLenum GetAttachedType(GLenum attachment)
Is attached type GL_RENDERBUFFER_EXT or GL_TEXTURE?
FramebufferObject()
Ctor/Dtor.
static int GetMaxColorAttachments()
Which z-slice is currently attached to "attachment?".
GLuint GetAttachedId(GLenum attachment)
virtual void AttachRenderBuffer(GLuint buffId, GLenum attachment=GL_COLOR_ATTACHMENT0)
Bind a render buffer to the "attachment" point of this FBO.
static void Disable()
static GLuint _GenerateFboId()
void _FramebufferTextureND(GLenum attachment, GLenum texTarget, GLuint texId, int mipLevel, int zSlice)
GLint GetAttachedMipLevel(GLenum attachment)
Which mipmap level is currently attached to "attachement?".
virtual ~FramebufferObject()
void Bind()
Bind this FBO as current render target.
GLuint getID() const
END : Static methods global to all FBOs.
bool IsValid(std::ostream &ostr=std::cerr)
virtual void AttachTexture(GLenum texTarget, GLuint texId, GLenum attachment=GL_COLOR_ATTACHMENT0, int mipLevel=0, int zSlice=0)
Bind a texture to the "attachment" point of this FBO.
void Unattach(GLenum attachment)
Free any resource bound to the "attachment" point of this FBO.
void UnattachAll()
Free any resources bound to any attachment points of this FBO.