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

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

started reinhard tonemapping implementation but slow

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