/************************************************ ** framebufferObject.h ** ** ------------------- ** ** ** ** This is the frame-work for general purpose ** ** initialization of a framebuffer object, ** ** as specified in the OpenGL extension: ** ** GL_EXT_FRAMEBUFFER_OBJECT ** ** ** ** Since this is an OpenGL extension, not WGL, ** ** it should be much more portable (and ** ** supposedly) faster than p-buffers and ** ** render-to-texture. ** ** ** ** Chris Wyman (4/27/2005) ** ************************************************/ #ifndef ___FRAMEBUFFER_OBJECT_H #define ___FRAMEBUFFER_OBJECT_H #include // This has been simplified a bit for class consumption. For instance, // stencil buffers may also be bound, though not directly as "textures" class FrameBuffer { private: GLuint ID; GLuint *colorIDs; GLuint depthID; GLuint stencilID; GLint maxColorBuffers; GLuint prevFrameBuf; int width, height; char fbName[80]; public: FrameBuffer( char *name=0 ); FrameBuffer( int width, int height, char *name=0 ); ~FrameBuffer(); GLenum CheckFramebufferStatus( int printMessage=0 ); // Attach textures to various attachment points int AttachColorTexture( GLuint colorTexID, int colorBuffer=0 ); int AttachDepthTexture( GLuint depthTexID ); // Bind/unbind the current framebuffer. These functions store the currently // bound framebuffer during a BindBuffer() and rebind it upon an UnbindBuffer() GLuint BindBuffer( void ); int UnbindBuffer( void ); // Queries to return the texture/renderbuffer ID of the various attachments inline GLuint GetColorTextureID( int level=0 ) { return (level < maxColorBuffers && level >= 0 ? colorIDs[level] : 0); } inline GLuint GetDepthTextureID( void ) { return depthID; } inline int GetWidth( void ) { return width; } inline int GetHeight( void ) { return height; } inline GLuint GetBufferID( void ) { return ID; } }; #endif