comparison engine/core/video/renderbackend.cpp @ 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 // Standard C++ library includes
23
24 // 3rd party library includes
25
26 // FIFE includes
27 // These includes are split up in two parts, separated by one empty line
28 // First block: files included from the FIFE root src directory
29 // Second block: files included from the same folder
30 #include "renderbackend.h"
31
32 namespace FIFE {
33
34 const unsigned int DEFAULT_CHUNKING_SIZE = 256;
35 const unsigned int MAX_CHUNKING_SIZE = 262144; // pixels!
36
37 RenderBackend::RenderBackend():
38 m_screen(NULL), m_isalphaoptimized(false), m_chunkingsize(DEFAULT_CHUNKING_SIZE) {
39 }
40
41
42 RenderBackend::~RenderBackend() {
43 }
44
45 void RenderBackend::deinit() {
46 delete m_screen;
47 m_screen = NULL;
48 SDL_QuitSubSystem(SDL_INIT_VIDEO);
49 }
50
51 void RenderBackend::captureScreen(const std::string& filename) {
52 m_screen->saveImage(filename);
53 }
54
55 void RenderBackend::pushClipArea(const Rect& cliparea, bool clear) {
56 assert(m_screen);
57 m_screen->pushClipArea(cliparea, clear);
58 }
59
60 void RenderBackend::popClipArea() {
61 assert(m_screen);
62 m_screen->popClipArea();
63 }
64
65 const Rect& RenderBackend::getClipArea() const {
66 assert(m_screen);
67 return m_screen->getClipArea();
68 }
69
70 SDL_Surface* RenderBackend::getSurface() {
71 assert(m_screen);
72 return m_screen->getSurface();
73 }
74
75 unsigned int RenderBackend::getWidth() const {
76 assert(m_screen);
77 return m_screen->getWidth();
78 }
79
80 unsigned int RenderBackend::getHeight() const {
81 assert(m_screen);
82 return m_screen->getHeight();
83 }
84
85 const Rect& RenderBackend::getArea() {
86 assert(m_screen);
87 return m_screen->getArea();
88 }
89
90 void RenderBackend::getPixelRGBA(int x, int y, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) {
91 assert(m_screen);
92 m_screen->getPixelRGBA(x, y, r, g, b, a);
93 }
94
95 void RenderBackend::saveImage(const std::string& filename) {
96 assert(m_screen);
97 m_screen->saveImage(filename);
98 }
99
100 void RenderBackend::setAlphaOptimizerEnabled(bool enabled) {
101 assert(m_screen);
102 m_screen->setAlphaOptimizerEnabled(enabled);
103 }
104
105 bool RenderBackend::isAlphaOptimizerEnabled() {
106 assert(m_screen);
107 return m_screen->isAlphaOptimizerEnabled();
108 }
109
110 void RenderBackend::setChunkingSize(unsigned int size) {
111 if (size > MAX_CHUNKING_SIZE) {
112 size = MAX_CHUNKING_SIZE;
113 }
114 m_chunkingsize = 1;
115 while (m_chunkingsize < size) {
116 m_chunkingsize <<= 1;
117 }
118 }
119
120 unsigned int RenderBackend::getChunkingSize() {
121 return m_chunkingsize;
122 }
123 }