WoopsiGfx 1.4
Nintendo DS 2D Graphics Library
libwoopsigfx/include/framebuffer.h
00001 #ifndef _FRAME_BUFFER_H_
00002 #define _FRAME_BUFFER_H_
00003 
00004 #include <nds.h>
00005 #include "mutablebitmapbase.h"
00006 
00007 namespace WoopsiGfx {
00008 
00009     class Graphics;
00010 
00021     class FrameBuffer : public MutableBitmapBase {
00022     public:
00023 
00036         void copy(s16 x, s16 y, u32 size, u16* dest) const;
00037 
00038 #ifdef USING_SDL
00039         // SDL version
00040         
00047         FrameBuffer(SDL_Surface* surface, u16 width, u16 height, u16 yOffset);
00048         
00053         const u16* getData() const;
00054 #else
00055         // DS version
00056         
00063         FrameBuffer(u16* data, u16 width, u16 height);
00064         
00069         inline const u16* getData() const { return _bitmap; };
00070 #endif
00071 
00075         virtual inline ~FrameBuffer() { };
00076         
00083         const u16 getPixel(s16 x, s16 y) const;
00084 
00091         virtual void setPixel(const s16 x, const s16 y, const u16 colour);
00092 
00100         inline const u16* getData(s16 x, s16 y) const;
00101 
00107         Graphics* newGraphics();
00108 
00116         void blit(const s16 x, const s16 y, const u16* data, const u32 size);
00117 
00125         void blitFill(const s16 x, const s16 y, const u16 colour, const u32 size);
00126 
00131         inline const u16 getWidth() const { return _width; };
00132 
00137         inline const u16 getHeight() const { return _height; };
00138 
00139     protected:
00140         
00141 #ifdef USING_SDL
00142         // SDL version
00143         SDL_Surface* _surface;  
00144         u16 _yOffset;           
00145         u16* _dataBuffer;       
00153         void putSDLPixel(int x, int y, Uint32 pixel);
00154 
00161         Uint32 getSDLPixel(int x, int y);
00162 #else
00163         // DS version
00164         u16* _bitmap __attribute__ ((aligned (4)));     
00165 #endif
00166 
00170         inline FrameBuffer(const FrameBuffer& bitmap) { };
00171 
00172         u16 _width;                                 
00173         u16 _height;                                
00174     };
00175 }
00176 
00177 #endif