FrameBuffer.h

Go to the documentation of this file.
00001 /* $Id: FrameBuffer.h,v 1.5 2002/09/26 09:28:16 cvs Exp $ */
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  * Frame-buffer "interface"
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); // RGB(A) mode, default
00026         static const unsigned FB_INDEX   = (1 << 1); // overrides FB_RGBA
00027         static const unsigned FB_SINGLE  = (1 << 2); // single buffer, default
00028         static const unsigned FB_DOUBLE  = (1 << 3); // overrides FB_SINGLE
00029         static const unsigned FB_DEPTH   = (1 << 4); // depth buffer
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&  /* camera */,
00095                               unsigned       /* posX   */,
00096                               unsigned       /* posY   */,
00097                               float          /* depth  */,
00098                               const Color3f& /* color  */) {}
00099         
00100         virtual void setColor(const Camera&  /* camera */,
00101                               unsigned       /* posX   */,
00102                               unsigned       /* posY   */,
00103                               const Color3f& /* color  */) {}
00104         
00118         virtual void setColors(const Camera&    /* camera */,
00119                                unsigned         /* posX   */,
00120                                unsigned         /* posY   */,
00121                                float            /* depth  */,
00122                                const Color3f [] /* colors */,
00123                                unsigned         /* size   */) {}
00124         
00125         virtual void setColors(const Camera&    /* camera */,
00126                                unsigned         /* posX   */,
00127                                unsigned         /* posY   */,
00128                                const Color3f [] /* colors */,
00129                                unsigned         /* size   */) {}
00130         
00138         virtual Color3f getColor(unsigned /* posX */,
00139                                  unsigned /* posY */) const
00140               {
00141                   return Color3f();
00142               }
00143         
00149         virtual void clearColor(const Color3f& /* color */) {}
00150 };
00151     
00152 } // namespace
00153 
00154 #endif // __FRAME_BUFFER_H

Generated on Tue Nov 21 15:11:42 2006 for gra by  doxygen 1.4.6