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

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        unsigned int GetTexture() const { return mTexId; }
44
45        /** Returns texture data.
46        */
47        void *ReadTexture() const;
48
49
50protected:
51
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;
67        unsigned int mId;
68        unsigned int mTexId;
69
70        int mWidth;
71        int mHeight;
72};
73
74
75/** This class implements a wrapper for a frame buffer object
76*/
77class FrameBufferObject
78{
79public:
80
81        enum DEPTH_FORMAT {DEPTH_NONE, DEPTH_16, DEPTH_24, DEPTH_32};
82
83        /** constructor requesting an opengl occlusion query.
84        */
85        FrameBufferObject(int w, int h, DEPTH_FORMAT d, bool useDepthTex = false);
86       
87        ~FrameBufferObject();
88        /** Creates and adds a color buffer to the current frame buffer object.
89                Returns the index that allows to retrieve the color buffer object.
90        */
91        int AddColorBuffer(ColorBufferObject::FORMAT col,
92                               ColorBufferObject::WRAP_TYPE wrapType,
93                                           ColorBufferObject::FILTER_TYPE filterType);
94
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
102        /** Returns the color buffer object on position i.
103        */
104        ColorBufferObject *GetColorBuffer(int i) const { return mColorBuffers[i]; }
105        /** Binds this frame buffer object.
106        */
107        void Bind() const;
108        /** Releases any bound frame buffer object.
109        */
110        static void Release();
111       
112        unsigned int GetDepthTex() const { return mDepthTexId; }
113
114protected:
115
116        std::vector<ColorBufferObject *> mColorBuffers;
117
118        unsigned int mId;
119        unsigned int mDepthId;
120
121        int mHeight;
122        int mWidth;
123
124        unsigned int mDepthTexId;
125};
126
127} // namespace
128#endif // _FrameBufferObject_H__
Note: See TracBrowser for help on using the repository browser.