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

Revision 2866, 2.0 KB checked in by mattausch, 16 years ago (diff)

bug: downsampling of positions does not work

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                                          bool useMultiSampling,
28                                          int attachment_idx);
29
30        unsigned int GetTexture() const {return mTexId;}
31
32protected:
33
34        unsigned int mId;
35        unsigned int mTexId;
36};
37
38
39/** This class implements a wrapper for a frame buffer object
40*/
41class FrameBufferObject
42{
43public:
44
45        enum DEPTH_FORMAT { DEPTH_NONE, DEPTH_16, DEPTH_24, DEPTH_32 };
46
47        /** constructor requesting an opengl occlusion query.
48        */
49        FrameBufferObject(int w, int h, DEPTH_FORMAT d, bool useDepthTex = false);
50        /** Creates and adds a color buffer to the current frame buffer object.
51                Returns the index that allows to retrieve the color buffer object.
52        */
53        int AddColorBuffer(int w, int h,
54                                   ColorBufferObject::FORMAT col,
55                               ColorBufferObject::WRAP_TYPE wrapType,
56                                           ColorBufferObject::FILTER_TYPE filterType,
57                                           bool useMipMap,
58                                           bool useMultiSampling);
59
60        /** Returns the color buffer object on position i.
61        */
62        ColorBufferObject *GetColorBuffer(int i) const { return mColorBuffers[i]; }
63        /** Binds this frame buffer object.
64        */
65        void Bind() const;
66        /** Releases any bound frame buffer object.
67        */
68        static void Release();
69       
70
71protected:
72
73        std::vector<ColorBufferObject *> mColorBuffers;
74
75        unsigned int mId;
76        unsigned int mDepthId;
77
78        int mHeight;
79        int mWidth;
80
81        unsigned int mDepthTexId;
82};
83
84} // namespace
85#endif // _FrameBufferObject_H__
Note: See TracBrowser for help on using the repository browser.