FIFE 2008.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2005-2008 by the FIFE team * 00003 * http://www.fifengine.de * 00004 * This file is part of FIFE. * 00005 * * 00006 * FIFE is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 00022 // Standard C++ library includes 00023 00024 // 3rd party library includes 00025 00026 // FIFE includes 00027 // These includes are split up in two parts, separated by one empty line 00028 // First block: files included from the FIFE root src directory 00029 // Second block: files included from the same folder 00030 #include "renderbackend.h" 00031 #include "video/devicecaps.h" 00032 00033 namespace FIFE { 00034 00035 00036 RenderBackend::RenderBackend(const SDL_Color& colorkey): 00037 m_screen(NULL), 00038 m_isalphaoptimized(false), 00039 m_iscolorkeyenabled(false), 00040 m_colorkey(colorkey) { 00041 } 00042 00043 00044 RenderBackend::~RenderBackend() { 00045 } 00046 00047 void RenderBackend::deinit() { 00048 delete m_screen; 00049 m_screen = NULL; 00050 SDL_QuitSubSystem(SDL_INIT_VIDEO); 00051 } 00052 00053 void RenderBackend::captureScreen(const std::string& filename) { 00054 m_screen->saveImage(filename); 00055 } 00056 00057 void RenderBackend::pushClipArea(const Rect& cliparea, bool clear) { 00058 assert(m_screen); 00059 m_screen->pushClipArea(cliparea, clear); 00060 } 00061 00062 void RenderBackend::popClipArea() { 00063 assert(m_screen); 00064 m_screen->popClipArea(); 00065 } 00066 00067 const Rect& RenderBackend::getClipArea() const { 00068 assert(m_screen); 00069 return m_screen->getClipArea(); 00070 } 00071 00072 SDL_Surface* RenderBackend::getSurface() { 00073 assert(m_screen); 00074 return m_screen->getSurface(); 00075 } 00076 00077 const ScreenMode& RenderBackend::getCurrentScreenMode() const{ 00078 return m_screenMode; 00079 } 00080 00081 unsigned int RenderBackend::getWidth() const { 00082 assert(m_screen); 00083 return m_screen->getWidth(); 00084 } 00085 00086 unsigned int RenderBackend::getHeight() const { 00087 assert(m_screen); 00088 return m_screen->getHeight(); 00089 } 00090 00091 const Rect& RenderBackend::getArea() { 00092 assert(m_screen); 00093 SDL_Surface* s = m_screen->getSurface(); 00094 static Rect r(0, 0, s->w, s->h); 00095 return r; 00096 } 00097 00098 void RenderBackend::getPixelRGBA(int x, int y, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) { 00099 assert(m_screen); 00100 m_screen->getPixelRGBA(x, y, r, g, b, a); 00101 } 00102 00103 void RenderBackend::saveImage(const std::string& filename) { 00104 assert(m_screen); 00105 m_screen->saveImage(filename); 00106 } 00107 00108 void RenderBackend::setAlphaOptimizerEnabled(bool enabled) { 00109 assert(m_screen); 00110 m_screen->setAlphaOptimizerEnabled(enabled); 00111 } 00112 00113 bool RenderBackend::isAlphaOptimizerEnabled() { 00114 assert(m_screen); 00115 return m_screen->isAlphaOptimizerEnabled(); 00116 } 00117 00118 void RenderBackend::setColorKeyEnabled(bool colorkeyenable) { 00119 m_iscolorkeyenabled = colorkeyenable; 00120 } 00121 00122 bool RenderBackend::isColorKeyEnabled() const { 00123 return m_iscolorkeyenabled; 00124 } 00125 00126 void RenderBackend::setColorKey(const SDL_Color& colorkey) { 00127 m_colorkey = colorkey; 00128 } 00129 00130 const SDL_Color& RenderBackend::getColorKey() const { 00131 return m_colorkey; 00132 } 00133 }