00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_GFX_OFFSCREEN_BUFFER_HH
00020 #define OST_GFX_OFFSCREEN_BUFFER_HH
00021
00022
00023
00024
00025
00026
00027
00028 #include <ost/gfx/gl_include.hh>
00029
00030 #if defined(__linux__)
00031 # include <GL/glx.h>
00032 #elif defined(__APPLE__)
00033 # include <OpenGL/OpenGL.h>
00034
00035
00036 #endif
00037
00038 #ifdef Complex
00039 # undef Complex
00040 #endif
00041
00042 namespace ost { namespace gfx {
00043
00045 class OffscreenBuffer {
00046 public:
00047
00049 static OffscreenBuffer& Instance();
00050
00052 bool Begin();
00054 bool End();
00056 bool Resize(unsigned int width, unsigned int height);
00057
00059 bool IsValid() const;
00060
00062 bool IsActive() const;
00063
00064 private:
00065 OffscreenBuffer(int width, int height, int r_bits, int b_bits,
00066 int g_bits, int a_bits, int depth_bits);
00067
00068 OffscreenBuffer(const OffscreenBuffer& b) {}
00069 OffscreenBuffer& operator=(const OffscreenBuffer& b) {return *this;}
00070
00071 int width_;
00072 int height_;
00073 bool valid_;
00074 bool active_;
00075
00076 #if defined(__linux__)
00077 Display* dpy_;
00078 GLXFBConfig* fbconfig_;
00079 GLXPbuffer pbuffer_;
00080 GLXContext context_;
00081 GLXContext old_context_;
00082 GLXDrawable old_dr1_;
00083 GLXDrawable old_dr2_;
00084
00085 #elif defined(__APPLE__)
00086
00087 CGLPBufferObj pbuffer_;
00088 CGLContextObj context_;
00089 CGLPixelFormatObj pix_format_;
00090 CGLContextObj old_context_;
00091
00092 #elif defined(_WIN32)
00093
00094
00095
00096
00097
00098
00099
00100 #endif
00101
00102 GLint old_vp_[4];
00103 };
00104
00105 }}
00106
00107 #endif