File: SDLCalls.h

package info (click to toggle)
moagg 0.18-6
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,924 kB
  • ctags: 4,059
  • sloc: cpp: 23,814; sh: 2,652; makefile: 283
file content (86 lines) | stat: -rw-r--r-- 3,492 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef SDLCALLS_H
#define SDLCALLS_H

#include <SDL.h>
#include <SDL_rotozoom.h>


//----------------------------------------------------------------------------
#define ZAP_SURFACE(s) \
    SDL_CALLS::FreeSurface(s); \
    s = NULL


//----------------------------------------------------------------------------
/**
 * This namespace contains wrappers to most needed SDL calls.
 * Each wrapper will call the related SDL function
 * and will check the return code for errors.
 * If an error occured, an SDLException will be thrown.
 * This way, the application never needs to check return codes.
 */
namespace SDL_CALLS
{
    //------------------------------------------------------------------------
    void Init(Uint32 flags);

    //------------------------------------------------------------------------
    void BlitSurface(const SDL_Surface *src, const SDL_Rect *srcrect,
                     SDL_Surface *dst, const SDL_Rect *dstrect);

    //------------------------------------------------------------------------
    SDL_Surface *ConvertSurface(const SDL_Surface *src,
                                const SDL_PixelFormat *fmt,
                                Uint32 flags);

    //------------------------------------------------------------------------
    SDL_Surface *CreateRGBSurface(
        Uint32 flags, int width, int height, int depth,
        Uint32 Rmask=0, Uint32 Gmask=0, Uint32 Bmask=0, Uint32 Amask=0);

    //------------------------------------------------------------------------
    SDL_Surface *CreateRGBSurfaceFrom(
        void *pixels, int width, int height, int depth, int pitch,
        Uint32 Rmask=0, Uint32 Gmask=0, Uint32 Bmask=0, Uint32 Amask=0);

    //------------------------------------------------------------------------
    void UpdateRect(Sint32 x, Sint32 y, Sint32 w, Sint32 h);

    //------------------------------------------------------------------------
    void UpdateRects(int numrects, const SDL_Rect *rects);

    //------------------------------------------------------------------------
    void Flip();

    //------------------------------------------------------------------------
    void FreeSurface(SDL_Surface *surface);

    //------------------------------------------------------------------------
    void SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key);

    //------------------------------------------------------------------------
    void SetPalette(SDL_Surface *surface, int flags,
                    SDL_Color *colors, int firstcolor, int ncolors);

    //------------------------------------------------------------------------
    SDL_Surface *LoadBMP(const char *file);

    //------------------------------------------------------------------------
    void SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);

    //------------------------------------------------------------------------
    SDL_Surface *SetVideoMode(int width, int height, int bpp, Uint32 flags);

    //------------------------------------------------------------------------
    void FillRect(SDL_Surface *surface, const SDL_Rect *rect, Uint32 color);


    //------------------------------------------------------------------------
    SDL_Surface *rotozoomSurface(const SDL_Surface *src, double angle,
                                 double zoom, int smooth);
    
    //------------------------------------------------------------------------
    void PushEvent(const SDL_Event &event);
}

#endif //SDLCALLS_H