Merge branch 'lua' of nslu34:disk/projects/SDLBotor into lua
[sdlbotor.git] / SDLVideoOut.cpp
blobd9b6e038ecd2147c57eb4c27ff32c461318bda75
1 #include <assert.h>
2 #include "SDLVideoOut.h"
4 namespace botor
7 SDLVideoOut::SDLVideoOut( int width, int height, int bpp, Uint32 flags )
9 this->screen = SDL_SetVideoMode( width, height, bpp, flags );
11 assert(this->screen); //Abort when no screen could be allocated.
15 Uint32 SDLVideoOut::MapRGBA( Uint8 r, Uint8 g, Uint8 b, Uint8 a )
17 return SDL_MapRGBA( screen->format, r, g, b, a );
20 Uint32 SDLVideoOut::MapRGB( Uint8 r, Uint8 g, Uint8 b )
22 return SDL_MapRGB( screen->format, r, g, b );
25 void SDLVideoOut::Clear( Uint32 color )
27 SDL_FillRect( this->screen, 0, color );
30 void SDLVideoOut::Flip( )
32 SDL_Flip( this->screen );
36 void SDLVideoOut::Blit( SDL_Surface *src, Sint16 x, Sint16 y )
38 SDL_Rect dstRect;
39 dstRect.x = x;
40 dstRect.y = y;
41 dstRect.w = src->w;
42 dstRect.h = src->h;
44 SDL_BlitSurface( src, 0, this->screen, &dstRect );
47 void SDLVideoOut::Blit( SDL_Surface *src, SDL_Rect *srcRect, Sint16 x, Sint16 y )
49 SDL_Rect dstRect;
50 dstRect.x = x;
51 dstRect.y = y;
52 dstRect.w = srcRect->w;
53 dstRect.h = srcRect->h;
55 SDL_BlitSurface( src, srcRect, this->screen, &dstRect );
59 void SDLVideoOut::DrawString( const char *string, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a )
61 //stringColor( this->screen, x, y, string, color );
62 stringRGBA( this->screen, x, y, string, r,g,b,a );
66 int SDLVideoOut::GetWidth()
68 return screen->w;
71 int SDLVideoOut::GetHeight()
73 return screen->h;