[2855] | 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 |
|
---|
[2856] | 18 | enum FORMAT { BUFFER_UBYTE, BUFFER_FLOAT_16, BUFFER_FLOAT_32 };
|
---|
[2857] | 19 | enum WRAP_TYPE{ WRAP_REPEAT, WRAP_CLAMP_TO_EDGE };
|
---|
| 20 | enum FILTER_TYPE { FILTER_NEAREST, FILTER_LINEAR, FILTER_MIPMAP_LINEAR };
|
---|
[2855] | 21 |
|
---|
| 22 | ColorBufferObject(int w, int h,
|
---|
[2856] | 23 | FORMAT c,
|
---|
| 24 | WRAP_TYPE wrapType,
|
---|
| 25 | FILTER_TYPE filterType,
|
---|
[2855] | 26 | bool useMipMap,
|
---|
[2861] | 27 | bool useMultiSampling,
|
---|
| 28 | int attachment_idx);
|
---|
[2856] | 29 |
|
---|
[2859] | 30 | unsigned int GetTexture() const {return mTexId;}
|
---|
| 31 |
|
---|
[2856] | 32 | protected:
|
---|
| 33 |
|
---|
| 34 | unsigned int mId;
|
---|
| 35 | unsigned int mTexId;
|
---|
[2855] | 36 | };
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 | /** This class implements a wrapper for a frame buffer object
|
---|
| 40 | */
|
---|
| 41 | class FrameBufferObject
|
---|
| 42 | {
|
---|
| 43 | public:
|
---|
| 44 |
|
---|
[2861] | 45 | enum DEPTH_FORMAT { DEPTH_NONE, DEPTH_16, DEPTH_24, DEPTH_32 };
|
---|
[2859] | 46 |
|
---|
[2855] | 47 | /** constructor requesting an opengl occlusion query.
|
---|
| 48 | */
|
---|
[2861] | 49 | FrameBufferObject(int w, int h, DEPTH_FORMAT d);
|
---|
[2855] | 50 | /** Creates and adds a color buffer to the current frame buffer object.
|
---|
[2859] | 51 | Returns the index that allows to retrieve the color buffer object.
|
---|
[2855] | 52 | */
|
---|
[2859] | 53 | int AddColorBuffer(ColorBufferObject::FORMAT col,
|
---|
| 54 | ColorBufferObject::WRAP_TYPE wrapType,
|
---|
| 55 | ColorBufferObject::FILTER_TYPE filterType,
|
---|
| 56 | bool useMipMap,
|
---|
| 57 | bool useMultiSampling);
|
---|
[2855] | 58 |
|
---|
[2859] | 59 | /** Returns the color buffer object on position i.
|
---|
| 60 | */
|
---|
| 61 | ColorBufferObject *GetColorBuffer(int i) const { return mColorBuffers[i]; }
|
---|
[2861] | 62 | /** Binds this frame buffer object.
|
---|
| 63 | */
|
---|
| 64 | void Bind() const;
|
---|
| 65 | /** Releases any bound frame buffer object.
|
---|
| 66 | */
|
---|
| 67 | static void Release();
|
---|
[2859] | 68 |
|
---|
[2855] | 69 | protected:
|
---|
| 70 |
|
---|
| 71 | std::vector<ColorBufferObject *> mColorBuffers;
|
---|
| 72 |
|
---|
| 73 | unsigned int mId;
|
---|
| 74 | unsigned int mDepthId;
|
---|
| 75 |
|
---|
| 76 | int mHeight;
|
---|
| 77 | int mWidth;
|
---|
| 78 | };
|
---|
| 79 |
|
---|
| 80 | } // namespace
|
---|
| 81 | #endif // _FrameBufferObject_H__ |
---|