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 | /** This class implements a wrapper for a color buffer object
|
---|
13 | */
|
---|
14 | class ColorBufferObject
|
---|
15 | {
|
---|
16 | public:
|
---|
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 |
|
---|
31 | protected:
|
---|
32 |
|
---|
33 | unsigned int mId;
|
---|
34 | unsigned int mTexId;
|
---|
35 | };
|
---|
36 |
|
---|
37 |
|
---|
38 | /** This class implements a wrapper for a frame buffer object
|
---|
39 | */
|
---|
40 | class FrameBufferObject
|
---|
41 | {
|
---|
42 | public:
|
---|
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 |
|
---|
68 | protected:
|
---|
69 |
|
---|
70 | std::vector<ColorBufferObject *> mColorBuffers;
|
---|
71 |
|
---|
72 | unsigned int mId;
|
---|
73 | unsigned int mDepthId;
|
---|
74 |
|
---|
75 | int mHeight;
|
---|
76 | int mWidth;
|
---|
77 |
|
---|
78 | unsigned int mDepthTexId;
|
---|
79 | };
|
---|
80 |
|
---|
81 | } // namespace
|
---|
82 | #endif // _FrameBufferObject_H__ |
---|