00001
00002
00003 #ifndef __FRAME_BUFFER_H
00004 #define __FRAME_BUFFER_H
00005
00006 #include <gra/GRAObject.h>
00007 #include <esg/Definitions.h>
00008 #include <gra/camera/Camera.h>
00009
00010
00011
00012
00013
00014 using namespace esg;
00015
00016 namespace gra {
00017
00018 class GRA_EXPORT FrameBuffer : public GRAObject {
00019 protected:
00020 unsigned _width;
00021 unsigned _height;
00022 unsigned _fbMode;
00023
00024 public:
00025 static const unsigned FB_RGBA = (1 << 0);
00026 static const unsigned FB_INDEX = (1 << 1);
00027 static const unsigned FB_SINGLE = (1 << 2);
00028 static const unsigned FB_DOUBLE = (1 << 3);
00029 static const unsigned FB_DEPTH = (1 << 4);
00030
00031 protected:
00032 void _sanitizeMode()
00033 {
00034 if (_fbMode & (FB_RGBA|FB_INDEX)) _fbMode &= ~FB_RGBA;
00035 if (_fbMode & (FB_SINGLE|FB_DOUBLE)) _fbMode &= ~FB_SINGLE;
00036 if (!((_fbMode & FB_RGBA) || _fbMode & FB_INDEX))
00037 _fbMode |= FB_RGBA;
00038 if (!((_fbMode & FB_SINGLE) || _fbMode & FB_DOUBLE))
00039 _fbMode |= FB_SINGLE;
00040 }
00041
00042 public:
00048 FrameBuffer(unsigned mode) : _width(0), _height(0), _fbMode(mode)
00049 {
00050 _sanitizeMode();
00051 }
00052
00060 FrameBuffer(unsigned width, unsigned height, unsigned mode)
00061 : _width(width), _height(height), _fbMode(mode)
00062 {
00063 _sanitizeMode();
00064 }
00065
00069 virtual ~FrameBuffer() {}
00070
00075 virtual void showContent() {}
00076
00080 virtual unsigned getWidth () const { return _width; }
00081 virtual unsigned getHeight() const { return _height; }
00082 virtual void setWidth (unsigned w) { _width = w; }
00083 virtual void setHeight(unsigned h) { _height = h; }
00084
00094 virtual void setColor(const Camera& ,
00095 unsigned ,
00096 unsigned ,
00097 float ,
00098 const Color3f& ) {}
00099
00100 virtual void setColor(const Camera& ,
00101 unsigned ,
00102 unsigned ,
00103 const Color3f& ) {}
00104
00118 virtual void setColors(const Camera& ,
00119 unsigned ,
00120 unsigned ,
00121 float ,
00122 const Color3f [] ,
00123 unsigned ) {}
00124
00125 virtual void setColors(const Camera& ,
00126 unsigned ,
00127 unsigned ,
00128 const Color3f [] ,
00129 unsigned ) {}
00130
00138 virtual Color3f getColor(unsigned ,
00139 unsigned ) const
00140 {
00141 return Color3f();
00142 }
00143
00149 virtual void clearColor(const Color3f& ) {}
00150 };
00151
00152 }
00153
00154 #endif // __FRAME_BUFFER_H