00001 //********************************************************************** 00002 // 00003 // REGCOM: Regimental Command 00004 // Copyright (C) 2008 Randi J. Relander 00005 // <rjrelander@users.sourceforge.net> 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 3 00010 // of the License, or (at your option) any later version. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public 00018 // License along with this program. If not, see 00019 // <http://www.gnu.org/licenses/>. 00020 // 00021 //********************************************************************** 00022 00023 #ifndef REGCOM_GUI_SURFACE_H 00024 #define REGCOM_GUI_SURFACE_H 00025 00026 // SYSTEM INCLUDES 00027 #include <string> 00028 00029 // LIBRARY INCLUDES 00030 #include "SDL.h" 00031 00032 // NAMESPACES 00033 namespace regcom { 00034 namespace gui { 00035 00036 // FORWARD REFERENCES 00037 class Rect; 00038 class Color; 00039 00041 // CLASS: Surface 00047 class Surface 00048 { 00049 public: 00050 00051 // PUBLIC METHODS 00052 00054 Surface(); 00055 00057 virtual ~Surface(); 00058 00060 int Create(int w, int h); 00061 00063 int Load(const std::string& rPath, const std::string& rName); 00064 00066 int Load(const std::string& rName); 00067 00069 int SetColorKey(int r, int g, int b); 00070 00072 int DisplayFormat(); 00073 00075 int DisplayFormatAlpha(); 00076 00078 int Blit(Surface* surface, Rect* src, int x, int y); 00079 00081 int LowerBlit(Surface* surface, Rect* src, int x, int y); 00082 00084 int FillRect(const Rect& rRect, const Color& rColor); 00085 00087 int Transparent(int x, int y); 00088 00090 Uint32 GetPixel(int x, int y); 00091 00093 int Width(); 00094 00096 int Height(); 00097 00099 int Depth(); 00100 00102 int Pitch(); 00103 00105 void* Pixels(); 00106 00108 int Lock(); 00109 00111 int Unlock(); 00112 00114 int GetPalette(Surface* surface); 00115 00117 void SetSurface(SDL_Surface* pSurface) 00118 { 00119 if (m_pSurface) SDL_FreeSurface(m_pSurface); 00120 m_pSurface = pSurface; 00121 } 00122 00124 Uint32 MapRGB(Uint8 red, Uint8 green, Uint8 blue) const 00125 { 00126 if (!m_pSurface) return 0; 00127 return SDL_MapRGB(m_pSurface->format, red, green, blue); 00128 } 00129 00131 Uint32 MapRGBA(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha) const 00132 { 00133 if (!m_pSurface) return 0; 00134 return SDL_MapRGBA(m_pSurface->format, red, green, blue, alpha); 00135 } 00136 00137 protected: 00138 00139 // MEMBER VARIABLES 00140 00142 SDL_Surface* m_pSurface; 00143 }; 00144 00145 } // namespace gui 00146 } // namespace regcom 00147 00148 #endif
Navigation
Home Page
Screen Shots
Developers
Documentation
Doxygen
Namespace List
Class List
Class Hierarchy
File List
Todo List
Links
SDL Library
License
SourceForge Project
Forums
Download
Regimental Command
Copyright © 2008
Randi J. Relander