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

Revision 2877, 1.9 KB checked in by mattausch, 16 years ago (diff)
Line 
1#ifndef _FrameBufferObject_H__
2#define _FrameBufferObject_H__
3
4#include <vector>
5#include "common.h"
6
7
8namespace CHCDemoEngine
9{
10
11
12/** This class implements a wrapper for a color buffer object
13*/
14class ColorBufferObject
15{
16public:
17
18        enum FORMAT { BUFFER_UBYTE, BUFFER_FLOAT_16, BUFFER_FLOAT_32 };
19        enum WRAP_TYPE{ WRAP_REPEAT, WRAP_CLAMP_TO_EDGE };
20        enum FILTER_TYPE { FILTER_NEAREST, FILTER_LINEAR, FILTER_MIPMAP_LINEAR };
21
22        ColorBufferObject(int w, int h,
23                              FORMAT c,
24                                          WRAP_TYPE wrapType,
25                                          FILTER_TYPE filterType,
26                                          bool useMipMap,
27                                          int attachment_idx);
28
29        unsigned int GetTexture() const {return mTexId;}
30
31protected:
32
33        unsigned int mId;
34        unsigned int mTexId;
35};
36
37
38/** This class implements a wrapper for a frame buffer object
39*/
40class FrameBufferObject
41{
42public:
43
44        enum DEPTH_FORMAT { DEPTH_NONE, DEPTH_16, DEPTH_24, DEPTH_32 };
45
46        /** constructor requesting an opengl occlusion query.
47        */
48        FrameBufferObject(int w, int h, DEPTH_FORMAT d, bool useDepthTex = false);
49        /** Creates and adds a color buffer to the current frame buffer object.
50                Returns the index that allows to retrieve the color buffer object.
51        */
52        int AddColorBuffer(ColorBufferObject::FORMAT col,
53                               ColorBufferObject::WRAP_TYPE wrapType,
54                                           ColorBufferObject::FILTER_TYPE filterType,
55                                           bool useMipMap);
56
57        /** Returns the color buffer object on position i.
58        */
59        ColorBufferObject *GetColorBuffer(int i) const { return mColorBuffers[i]; }
60        /** Binds this frame buffer object.
61        */
62        void Bind() const;
63        /** Releases any bound frame buffer object.
64        */
65        static void Release();
66       
67        unsigned int GetDepthTex() const { return mDepthTexId; }
68
69protected:
70
71        std::vector<ColorBufferObject *> mColorBuffers;
72
73        unsigned int mId;
74        unsigned int mDepthId;
75
76        int mHeight;
77        int mWidth;
78
79        unsigned int mDepthTexId;
80};
81
82} // namespace
83#endif // _FrameBufferObject_H__
Note: See TracBrowser for help on using the repository browser.