Mercurial > fife-parpg
comparison engine/core/video/video.i @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | 485f4c6dd9fc |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 /*************************************************************************** | |
2 * Copyright (C) 2005-2008 by the FIFE team * | |
3 * http://www.fifengine.de * | |
4 * This file is part of FIFE. * | |
5 * * | |
6 * FIFE is free software; you can redistribute it and/or modify * | |
7 * it under the terms of the GNU General Public License as published by * | |
8 * the Free Software Foundation; either version 2 of the License, or * | |
9 * (at your option) any later version. * | |
10 * * | |
11 * This program is distributed in the hope that it will be useful, * | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 * GNU General Public License for more details. * | |
15 * * | |
16 * You should have received a copy of the GNU General Public License * | |
17 * along with this program; if not, write to the * | |
18 * Free Software Foundation, Inc., * | |
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | |
20 ***************************************************************************/ | |
21 %module fife | |
22 | |
23 %{ | |
24 #include "video/image.h" | |
25 #include "video/cursor.h" | |
26 #include "video/animation.h" | |
27 #include "video/imagepool.h" | |
28 #include "video/animationpool.h" | |
29 #include "video/renderbackend.h" | |
30 #include "util/base/exception.h" | |
31 %} | |
32 | |
33 %include "util/structures/utilstructures.i" | |
34 %include "util/resource/resource.i" | |
35 | |
36 namespace FIFE { | |
37 class Pool; | |
38 class Point; | |
39 | |
40 class AbstractImage { | |
41 public: | |
42 virtual ~AbstractImage() {} | |
43 virtual SDL_Surface* getSurface() = 0; | |
44 virtual unsigned int getWidth() const = 0; | |
45 virtual unsigned int getHeight() const = 0; | |
46 virtual const Rect& getArea() = 0; | |
47 virtual void getPixelRGBA(int x, int y, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) = 0; | |
48 virtual bool putPixel(int x, int y, int r, int g, int b) = 0; | |
49 virtual void drawLine(const Point& p1, const Point& p2, int r, int g, int b) = 0; | |
50 virtual void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b) = 0; | |
51 virtual void pushClipArea(const Rect& cliparea, bool clear=true) = 0; | |
52 virtual void popClipArea() = 0; | |
53 virtual const Rect& getClipArea() const = 0; | |
54 virtual void saveImage(const std::string& filename) = 0; | |
55 virtual void setAlphaOptimizerEnabled(bool enabled) = 0; | |
56 virtual bool isAlphaOptimizerEnabled() = 0; | |
57 }; | |
58 | |
59 class Image : public AbstractImage, public ResourceClass { | |
60 public: | |
61 void render(const Rect& rect, unsigned char alpha = 255); | |
62 virtual ~Image(); | |
63 SDL_Surface* getSurface() { return m_surface; } | |
64 unsigned int getWidth() const; | |
65 unsigned int getHeight() const; | |
66 const Rect& getArea(); | |
67 void setXShift(int xshift); | |
68 inline int getXShift() const; | |
69 void setYShift(int yshift); | |
70 inline int getYShift() const; | |
71 void getPixelRGBA(int x, int y, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a); | |
72 void pushClipArea(const Rect& cliparea, bool clear=true); | |
73 void popClipArea(); | |
74 const Rect& getClipArea() const; | |
75 void setAlphaOptimizerEnabled(bool enabled); | |
76 bool isAlphaOptimizerEnabled(); | |
77 void addRef(); | |
78 void decRef(); | |
79 unsigned int getRefCount(); | |
80 | |
81 private: | |
82 Image(SDL_Surface* surface); | |
83 Image(const uint8_t* data, unsigned int width, unsigned int height); | |
84 }; | |
85 | |
86 class Animation: public ResourceClass { | |
87 public: | |
88 explicit Animation(); | |
89 ~Animation(); | |
90 void addFrame(Image* image, unsigned int duration); | |
91 int getFrameIndex(unsigned int timestamp); | |
92 Image* getFrame(int index); | |
93 Image* getFrameByTimestamp(unsigned int timestamp); | |
94 int getFrameDuration(int index); | |
95 unsigned int getNumFrames() const; | |
96 void setActionFrame(int num); | |
97 int getActionFrame(); | |
98 void setDirection(unsigned int direction); | |
99 unsigned int getDirection(); | |
100 int getDuration(); | |
101 void addRef(); | |
102 void decRef(); | |
103 unsigned int getRefCount(); | |
104 }; | |
105 | |
106 class ImagePool: public Pool { | |
107 public: | |
108 virtual ~ImagePool(); | |
109 inline Image& getImage(unsigned int index); | |
110 private: | |
111 ImagePool(); | |
112 }; | |
113 | |
114 class AnimationPool: public Pool { | |
115 public: | |
116 virtual ~AnimationPool(); | |
117 inline Animation& getAnimation(unsigned int index); | |
118 private: | |
119 AnimationPool(); | |
120 }; | |
121 | |
122 class RenderBackend: public AbstractImage { | |
123 public: | |
124 virtual ~RenderBackend(); | |
125 virtual const std::string& getName() const = 0; | |
126 Image* getScreenImage() const { return m_screen; }; | |
127 void captureScreen(const std::string& filename); | |
128 SDL_Surface* getSurface(); | |
129 unsigned int getWidth() const; | |
130 unsigned int getHeight() const; | |
131 unsigned int getScreenWidth() const { return getWidth(); } | |
132 unsigned int getScreenHeight() const { return getHeight(); } | |
133 const Rect& getArea(); | |
134 void getPixelRGBA(int x, int y, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a); | |
135 bool putPixel(int x, int y, int r, int g, int b); | |
136 void drawLine(const Point& p1, const Point& p2, int r, int g, int b); | |
137 void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b); | |
138 void pushClipArea(const Rect& cliparea, bool clear=true); | |
139 void popClipArea(); | |
140 const Rect& getClipArea() const; | |
141 void setAlphaOptimizerEnabled(bool enabled); | |
142 bool isAlphaOptimizerEnabled(); | |
143 void saveImage(const std::string& filename); | |
144 }; | |
145 | |
146 enum MouseCursorType { | |
147 CURSOR_NONE, | |
148 CURSOR_NATIVE, | |
149 CURSOR_IMAGE, | |
150 CURSOR_ANIMATION | |
151 }; | |
152 | |
153 class Cursor { | |
154 public: | |
155 virtual ~Cursor() {} | |
156 virtual void draw(); | |
157 void set(MouseCursorType ctype, unsigned int cursor_id=0); | |
158 void setDrag(MouseCursorType ctype, unsigned int drag_id=0, int drag_offset_x=0, int drag_offset_y=0); | |
159 MouseCursorType getType() const; | |
160 unsigned int getId() const; | |
161 MouseCursorType getDragType() const; | |
162 unsigned int getDragId() const; | |
163 | |
164 private: | |
165 Cursor(ImagePool* imgpool, AnimationPool* animpool); | |
166 }; | |
167 | |
168 } |