source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h @ 2965

Revision 2965, 3.0 KB checked in by mattausch, 16 years ago (diff)

removed dirttexture stuff. started tonemapping stuff

RevLine 
[2855]1#ifndef _FrameBufferObject_H__
2#define _FrameBufferObject_H__
3
4#include <vector>
5#include "common.h"
6
7
8namespace CHCDemoEngine
9{
10
11/** This class implements a wrapper for a color buffer object
12*/
13class ColorBufferObject
14{
15public:
16
[2856]17        enum FORMAT { BUFFER_UBYTE, BUFFER_FLOAT_16, BUFFER_FLOAT_32 };
[2965]18        enum WRAP_TYPE { WRAP_REPEAT, WRAP_CLAMP_TO_EDGE };
19        enum FILTER_TYPE { FILTER_NEAREST, FILTER_LINEAR };
[2855]20
[2965]21
22        /** Creates color buffer without mipmap. attachment_idx describes
23                the number of the render target the buffer is attached to
24        */
[2855]25        ColorBufferObject(int w, int h,
[2965]26                              int attachment_idx  ,           
27                                          FORMAT c,
[2856]28                                          WRAP_TYPE wrapType,
[2965]29                                          FILTER_TYPE filterType);
30
31        /** Same as above, with mipmapping enabled.
32        */
33        ColorBufferObject(int w, int h,
34                              int attachment_idx,       
35                                          FORMAT c,
36                                          WRAP_TYPE wrapType,
[2856]37                                          FILTER_TYPE filterType,
[2965]38                                          FILTER_TYPE filterTypeMipMap
39                                          );
[2856]40
[2878]41        ~ColorBufferObject();
42
[2965]43        unsigned int GetTexture() const { return mTexId; }
[2859]44
[2965]45        /** Returns texture data.
46        */
47        void *ReadTexture() const;
48
49
[2856]50protected:
51
[2965]52        void Init(int w, int h,
53                      int attachment_idx,
54                      FORMAT format,
55                          WRAP_TYPE wrapType,
56                          FILTER_TYPE filterType,
57                          bool useMipMap,
58                          FILTER_TYPE filterTypeMipMap
59                          );
60
61
62
63        ///////////
64
65        int mGlFormat;
66        int mInternalFormat;
[2856]67        unsigned int mId;
68        unsigned int mTexId;
[2965]69
70        int mWidth;
71        int mHeight;
[2855]72};
73
74
75/** This class implements a wrapper for a frame buffer object
76*/
77class FrameBufferObject
78{
79public:
80
[2965]81        enum DEPTH_FORMAT {DEPTH_NONE, DEPTH_16, DEPTH_24, DEPTH_32};
[2859]82
[2855]83        /** constructor requesting an opengl occlusion query.
84        */
[2862]85        FrameBufferObject(int w, int h, DEPTH_FORMAT d, bool useDepthTex = false);
[2878]86       
87        ~FrameBufferObject();
[2855]88        /** Creates and adds a color buffer to the current frame buffer object.
[2859]89                Returns the index that allows to retrieve the color buffer object.
[2855]90        */
[2867]91        int AddColorBuffer(ColorBufferObject::FORMAT col,
[2859]92                               ColorBufferObject::WRAP_TYPE wrapType,
[2965]93                                           ColorBufferObject::FILTER_TYPE filterType);
[2855]94
[2965]95        /** Same as above, but enables mipmapping using the specified filter.
96        */
97        int AddColorBuffer(ColorBufferObject::FORMAT col,
98                               ColorBufferObject::WRAP_TYPE wrapType,
99                                           ColorBufferObject::FILTER_TYPE filterType,
100                                           ColorBufferObject::FILTER_TYPE filterTypeMipMap);
101
[2859]102        /** Returns the color buffer object on position i.
103        */
104        ColorBufferObject *GetColorBuffer(int i) const { return mColorBuffers[i]; }
[2861]105        /** Binds this frame buffer object.
106        */
107        void Bind() const;
108        /** Releases any bound frame buffer object.
109        */
110        static void Release();
[2862]111       
[2877]112        unsigned int GetDepthTex() const { return mDepthTexId; }
[2859]113
[2855]114protected:
115
116        std::vector<ColorBufferObject *> mColorBuffers;
117
118        unsigned int mId;
119        unsigned int mDepthId;
120
121        int mHeight;
122        int mWidth;
[2862]123
124        unsigned int mDepthTexId;
[2855]125};
126
127} // namespace
128#endif // _FrameBufferObject_H__
Note: See TracBrowser for help on using the repository browser.