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