summaryrefslogtreecommitdiffstats
path: root/engine/include/surface.hpp
blob: 6e9026a0cea2e5d951d6a74a98a09d431cd622a9 (plain)
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
#ifndef __FLATSURFACE_H__
#define __FLATSURFACE_H__

#include "object.hpp"
#include "core/labelled.hpp"
#include <SDL2/SDL.h>

namespace flat {

class surface : virtual public object, virtual public core::labelled
{
    SDL_Surface * sdl_surface;
    SDL_Surface * parent;

    SDL_Rect * offset;
    SDL_Rect * viewport;

    bool hide;

public:

    surface(const char *filename, uint32_t format = SDL_PIXELFORMAT_RGBA32, SDL_Surface *parent = 0);
    surface(SDL_Surface *surf, SDL_Surface *parent = 0);

    surface(const surface&);

    ~surface();

    void setOffset(int, int, int w = -1, int h = -1);

    void setOffset(const SDL_Rect&);

    void setViewport(int x = 0, int y = 0, int w = -1, int h = -1);

    void setViewport(const SDL_Rect&);

    const SDL_Rect * getOffset() const;

    const SDL_Rect * getViewport() const;

    void setParent(SDL_Surface *parent);

    SDL_Surface * getParent();

    SDL_Surface * getSurface();

    void setHidden(bool);

    bool isHidden() const;

    void blit();

    static SDL_Surface * loadOptimizedSurface(const char* filename, uint32_t format);

    static SDL_Surface * copySurface(SDL_Surface*);
};

}

#endif