Mercurial > fife-parpg
comparison engine/core/video/renderbackend.h @ 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 | 90005975cdbb |
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 | |
22 #ifndef FIFE_VIDEO_RENDERBACKEND_H | |
23 #define FIFE_VIDEO_RENDERBACKEND_H | |
24 | |
25 // Standard C++ library includes | |
26 #include <string> | |
27 | |
28 // Platform specific includes | |
29 #include "util/base/fife_stdint.h" | |
30 | |
31 // 3rd party library includes | |
32 #include <SDL.h> | |
33 #include <SDL_video.h> | |
34 | |
35 // FIFE includes | |
36 // These includes are split up in two parts, separated by one empty line | |
37 // First block: files included from the FIFE root src directory | |
38 // Second block: files included from the same folder | |
39 #include "util/base/singleton.h" | |
40 #include "util/structures/point.h" | |
41 #include "util/structures/rect.h" | |
42 | |
43 #include "image.h" | |
44 | |
45 namespace FIFE { | |
46 | |
47 class Image; | |
48 | |
49 /** Abstract interface for all the renderbackends. */ | |
50 class RenderBackend: public AbstractImage, public DynamicSingleton<RenderBackend> { | |
51 public: | |
52 /** Constructor. | |
53 * @param name The name of the new renderbackend. | |
54 */ | |
55 RenderBackend(); | |
56 | |
57 /** Destructor. | |
58 */ | |
59 virtual ~RenderBackend(); | |
60 | |
61 /** The name of the renderbackend. | |
62 * @return The name of this renderbackend. | |
63 */ | |
64 virtual const std::string& getName() const = 0; | |
65 | |
66 /** Called when a new frame starts. | |
67 */ | |
68 virtual void startFrame() = 0; | |
69 | |
70 /** Called when a frame is finished and ready to be displayed. | |
71 */ | |
72 virtual void endFrame() = 0; | |
73 | |
74 /** Initializes the backend. | |
75 */ | |
76 virtual void init() = 0; | |
77 | |
78 /** Performs cleanup actions. | |
79 */ | |
80 virtual void deinit(); | |
81 | |
82 /** Creates the mainscreen (the display window). | |
83 * @param width Width of the window. | |
84 * @param height Height of the window. | |
85 * @param bitsPerPixel Bits per pixel, 0 means autodetect. | |
86 * @param fullscreen Use fullscreen mode? | |
87 * @return The new Screen Image | |
88 */ | |
89 virtual Image* createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fullscreen) = 0; | |
90 | |
91 /** Creates an Image suitable for this renderbackend. | |
92 * @param data Pointer to the imagedata (needs to be in RGBA, 8 bits per channel). | |
93 * @param width Width of the image. | |
94 * @param height Height of the image. | |
95 * @return The new Image. | |
96 */ | |
97 virtual Image* createImage(const uint8_t* data, unsigned int width, unsigned int height) = 0; | |
98 | |
99 /** Helper function to create images from SDL_Surfaces. | |
100 * Takes ownership over the surface. | |
101 * @param surface The surface to convert. | |
102 * @return The new Image. | |
103 */ | |
104 virtual Image* createImage(SDL_Surface* surface) = 0; | |
105 | |
106 /** Returns a pointer to the main screen Image | |
107 * @return A pointer to the main screen Image, or 0 if no mainscreen exists. | |
108 */ | |
109 Image* getScreenImage() const { return m_screen; }; | |
110 | |
111 /** Creates a Screenshot and saves it to a file. | |
112 */ | |
113 void captureScreen(const std::string& filename); | |
114 | |
115 SDL_Surface* getSurface(); | |
116 unsigned int getWidth() const; | |
117 unsigned int getHeight() const; | |
118 unsigned int getScreenWidth() const { return getWidth(); } | |
119 unsigned int getScreenHeight() const { return getHeight(); } | |
120 const Rect& getArea(); | |
121 void getPixelRGBA(int x, int y, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a); | |
122 void pushClipArea(const Rect& cliparea, bool clear=true); | |
123 void popClipArea(); | |
124 const Rect& getClipArea() const; | |
125 void setAlphaOptimizerEnabled(bool enabled); | |
126 bool isAlphaOptimizerEnabled(); | |
127 void saveImage(const std::string& filename); | |
128 | |
129 /** OpenGL image needs to be sliced into power of two sized chunks. | |
130 * You can adjust the size by calling this method. | |
131 * Size can be anything (reasonable), it is always changed to the next biggest power of two value | |
132 * @example values 50 -> 64, 340 -> 512 | |
133 */ | |
134 void setChunkingSize(unsigned int size); | |
135 unsigned int getChunkingSize(); | |
136 | |
137 protected: | |
138 Image* m_screen; | |
139 bool m_isalphaoptimized; | |
140 unsigned int m_chunkingsize; | |
141 }; | |
142 } | |
143 | |
144 #endif |