FrameBufferObject.cpp
Go to the documentation of this file.
00001 
00002 //      File:           FrameBufferObject.cpp
00003 //      Author:         Changchang Wu
00004 //      Description : Implementation of FrameBufferObject Class
00005 //
00006 //
00007 //
00008 //      Copyright (c) 2007 University of North Carolina at Chapel Hill
00009 //      All Rights Reserved
00010 //
00011 //      Permission to use, copy, modify and distribute this software and its
00012 //      documentation for educational, research and non-profit purposes, without
00013 //      fee, and without a written agreement is hereby granted, provided that the
00014 //      above copyright notice and the following paragraph appear in all copies.
00015 //      
00016 //      The University of North Carolina at Chapel Hill make no representations
00017 //      about the suitability of this software for any purpose. It is provided
00018 //      'as is' without express or implied warranty. 
00019 //
00020 //      Please send BUG REPORTS to ccwu@cs.unc.edu
00021 //
00023 
00024 
00025 #include "GL/glew.h"
00026 #include <stdlib.h>
00027 #include "GlobalUtil.h"
00028 #include "FrameBufferObject.h"
00029 
00030 //whether use only one FBO globally
00031 int             FrameBufferObject::UseSingleFBO=1;
00032 GLuint  FrameBufferObject::GlobalFBO=0;
00033 
00035 // Construction/Destruction
00037 
00038 FrameBufferObject::FrameBufferObject(int autobind)
00039 {
00040         if(UseSingleFBO && GlobalFBO)
00041         {
00042                 _fboID = GlobalFBO;
00043         }else
00044         {
00045                 glGenFramebuffersEXT(1, &_fboID);
00046                 if(UseSingleFBO )GlobalFBO = _fboID;
00047         }
00048         if(autobind )   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fboID);
00049 }
00050 
00051 FrameBufferObject::~FrameBufferObject()
00052 {
00053         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
00054         if(!UseSingleFBO )
00055         {
00056                 glDeleteFramebuffersEXT (1,&_fboID);
00057         }
00058 }
00059 
00060 void FrameBufferObject::DeleteGlobalFBO()
00061 {
00062         if(UseSingleFBO)
00063         {
00064                 glDeleteFramebuffersEXT (1,&GlobalFBO);
00065                 GlobalFBO = 0;
00066         }
00067 }
00068 
00069 void FrameBufferObject::AttachDepthTexture(GLenum textureTarget, GLuint texID)
00070 {
00071 
00072   glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, textureTarget, texID, 0);
00073 }
00074 
00075 void FrameBufferObject::AttachTexture(GLenum textureTarget, GLenum attachment, GLuint texId)
00076 {
00077   glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, textureTarget, texId, 0);
00078 }
00079 
00080 void FrameBufferObject::BindFBO()
00081 {
00082   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fboID);
00083 }
00084 
00085 void FrameBufferObject::UnbindFBO()
00086 {
00087         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
00088 }
00089 
00090 void FrameBufferObject::UnattachTex(GLenum attachment)
00091 {
00092         glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, 0, 0 );
00093 }
00094 
00095 void FrameBufferObject::AttachRenderBuffer(GLenum attachment, GLuint buffID)
00096 {
00097         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, buffID);
00098 
00099 }
00100 
00101 void FrameBufferObject:: UnattachRenderBuffer(GLenum attachment)
00102 {
00103         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, 0);
00104 }
00105 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


rgbd_registration
Author(s): Ross Kidson
autogenerated on Sun Oct 6 2013 12:00:39