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

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

for some reasons very slow even in small streets on my home computer!!

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