Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 #ifndef __FRAMEBUFFER_OBJECT__
00070 #define __FRAMEBUFFER_OBJECT__
00071
00072
00073
00074 #ifdef WIN32
00075 #include <windows.h>
00076 #endif
00077
00078
00079
00080
00082
00083
00084 #include <GL/glew.h>
00085
00086 #include <iostream>
00087 #include <vector>
00088
00089
00090
00091 #define MAX_COLOR_COMPONENTS 16
00092
00093
00094
00095 class FramebufferObject {
00096
00097 public:
00098
00099
00100
00101 enum ColorAttachmentType {
00102
00103 RGB_8 = 0,
00104 RGB_16,
00105 RGB_32,
00106
00107 RGBA_8,
00108 RGBA_16,
00109 RGBA_32,
00110 };
00111
00112
00113
00114 FramebufferObject(const char *strMode="rgba=3x8t depth=24t");
00115 ~FramebufferObject();
00116
00118 bool initialize( unsigned int width, unsigned int height );
00119 bool reInitialize( unsigned int width, unsigned int height, const char *strMode="rgb=16t depth=24t" );
00120
00128 void beginCapture(bool bEnablePassThroughShader=true);
00129
00137 void endCapture(bool bDisablePassThroughShader=true);
00138
00140 void bind(int index=0);
00141
00143 void bindDepth(void);
00144
00146 GLuint getColorAttachmentID(int index = 0);
00147
00149 GLuint getDepthAttachmentID(void);
00150
00152 GLuint getStencilAttachmentID(void);
00153
00155 GLenum getTextureTarget(void) { return _textureTarget; }
00156
00158 unsigned int getWidth(void);
00160 unsigned int getHeight(void);
00161
00163 bool checkFramebufferStatus(void);
00164 void printFramebufferStatus(void);
00165
00167 void enableTextureTarget(void) { glEnable(_textureTarget); }
00169 void disableTextureTarget(void) { glDisable(_textureTarget); }
00170
00172 void setMinFilter(GLint minFilter);
00173
00175 void setMagFilter(GLint magFilter);
00176
00178 void setWrapS(GLint wrapS);
00179
00181 void setWrapT(GLint wrapT);
00182
00183 protected:
00184
00186 GLenum _textureTarget;
00187
00189 GLint _colorFormat;
00191 GLint _internalColorFormat;
00193 GLenum _colorType;
00194
00196 ColorAttachmentType _colorAttachmentDepth;
00197
00199 GLenum _depthFormat;
00202 GLenum _internalDepthFormat;
00204 GLenum _depthType;
00205
00207 GLint _wrapS;
00209 GLint _wrapT;
00210
00212 GLint _minFilter;
00214 GLint _magFilter;
00215
00217 int _width;
00219 int _height;
00220
00222 bool _bFBOSupported;
00223
00225 bool _bInitialized;
00226
00228 bool _bColorAttachment;
00230 bool _bColorAttachmentRenderTexture;
00231
00233 bool _bDepthAttachment;
00235 bool _bDepthAttachmentRenderTexture;
00236
00238 bool _bStencilAttachment;
00240 bool _bStencilAttachmentRenderTexture;
00242 int _stencilDepth;
00244 GLint _internalStencilFormat;
00245
00247 bool _bPassThroughProgramInitialized;
00248
00250 GLuint _frameBufferID;
00251
00253 GLuint _colorAttachmentID[MAX_COLOR_COMPONENTS];
00254
00256 int _numColorAttachments;
00257
00259 int _maxNumDrawBuffers;
00260
00262 GLuint _depthAttachmentID;
00263
00265 GLuint _stencilAttachmentID;
00266
00269 GLint _viewport[4];
00270
00272
00273 GLenum _passthrough_program;
00274 GLenum _passthrough_fragment_shader;
00275 GLuint _passThroughProgram;
00276
00278 bool _bFloatColorBuffer;
00279
00280 private:
00281
00283 void parseModeString(const char *modeString);
00284
00285 typedef std::pair<std::string, std::string> KeyVal;
00287 KeyVal getKeyValuePair(std::string token);
00288
00289
00290 };
00291
00292 #endif