![[]](/images/special/trans.gif)
LibN2L-4 Library Code ReferenceClassesCompounds Files Members Method Index Full Reference cSurfaceProperties.cppGo to the documentation of this file.00001 /************************************************************************ 00002 Nova-2 Library (libN2L, or simply n2l) Game development C++ Library 00003 Copyright (C) 2003 Aaron Cameron 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 A copy of the GNU Lesser General Public License has been provided with 00020 this library in the file 'COPYING'. 00021 00022 Contact information for the author of this library has been provided 00023 with this library in the file 'AUTHOR'. 00024 ************************************************************************/ 00025 #include "cSurfaceProperties.h" 00026 00027 namespace n2l 00028 { 00029 00030 /* ************************************************************ */ 00031 cSurfaceProperties::cSurfaceProperties() : 00032 mSize(0,0), 00033 mFlags(0), 00034 mPitch(0) 00035 { 00036 } 00037 00038 00039 /* ************************************************************ */ 00040 cSurfaceProperties::cSurfaceProperties( const SDL_Surface & iSurface ) : 00041 mSize( iSurface.w, iSurface.h ), 00042 mFlags( iSurface.flags ), 00043 mPitch( iSurface.pitch ) 00044 { 00045 } 00046 00047 00048 /* ************************************************************ */ 00049 cSurfaceProperties::~cSurfaceProperties() 00050 { 00051 } 00052 00053 00054 /* ************************************************************ */ 00055 void cSurfaceProperties::assign( const cSurfaceProperties & iProperties ) 00056 { 00057 mSize = iProperties.mSize; 00058 mFlags = iProperties.mFlags; 00059 mPitch = iProperties.mPitch; 00060 } 00061 00062 00063 /* ************************************************************ */ 00064 const cSurfaceProperties::tSize & cSurfaceProperties::size() const 00065 { 00066 return mSize; 00067 } 00068 00069 00070 /* ************************************************************ */ 00071 const cSurfaceProperties::tSurfaceFlags cSurfaceProperties::flags() const 00072 { 00073 return mFlags; 00074 } 00075 00076 00077 /* ************************************************************ */ 00078 void cSurfaceProperties::setSize( const tSize & iSize ) 00079 { 00080 mSize = iSize; 00081 } 00082 00083 00084 /* ************************************************************ */ 00085 void cSurfaceProperties::setFlags( const tSurfaceFlags iFlags ) 00086 { 00087 mFlags = iFlags; 00088 } 00089 00090 00091 /* ************************************************************ */ 00092 const tUint cSurfaceProperties::pitch() const 00093 { 00094 return mPitch; 00095 } 00096 00097 /* ************************************************************ */ 00098 void cSurfaceProperties::addFlags( const tSurfaceFlags iFlags ) 00099 { 00100 mFlags = mFlags | iFlags; 00101 } 00102 00103 00104 /* ************************************************************ */ 00105 const tString cSurfaceProperties::asString() const 00106 { 00107 tString temp( "cSurfaceFormat(\n"); 00108 temp += "\tDimension:\t" + n2l::asString(mSize.getX()) + "x" + 00109 n2l::asString(mSize.getY()) + "\n"; 00110 temp += "\tPitch:\t" + n2l::asString( mPitch ) + "\n"; 00111 temp += "\tFlag Mask:\t" + n2l::asBinaryMaskString( mFlags ) + "\n"; 00112 for (tUbyte bit=0; bit<32; ++bit) { 00113 if (mFlags&(1<<bit)) 00114 temp += "\t" + surfaceFlagStr(1<<bit) + "\n"; 00115 } 00116 temp += ")"; 00117 return temp; 00118 } 00119 00120 /* ************************************************************ */ 00121 const tString & cSurfaceProperties::surfaceFlagStr( const tSurfaceFlags iFlags ) 00122 { 00123 static const tString Str_SDL_SWSURFACE = "SDL_SWSURFACE"; 00124 static const tString Str_SDL_HWSURFACE = "SDL_HWSURFACE"; 00125 static const tString Str_SDL_ASYNCBLIT = "SDL_ASYNCBLIT"; 00126 static const tString Str_SDL_ANYFORMAT = "SDL_ANYFORMAT"; 00127 static const tString Str_SDL_HWPALETTE = "SDL_HWPALETTE"; 00128 static const tString Str_SDL_DOUBLEBUF = "SDL_DOUBLEBUF"; 00129 static const tString Str_SDL_FULLSCREEN = "SDL_FULLSCREEN"; 00130 static const tString Str_SDL_OPENGL = "SDL_OPENGL"; 00131 static const tString Str_SDL_OPENGLBLIT = "SDL_OPENGLBLIT"; 00132 static const tString Str_SDL_RESIZABLE = "SDL_RESIZABLE"; 00133 static const tString Str_SDL_NOFRAME = "SDL_NOFRAME"; 00134 static const tString Str_SDL_HWACCEL = "SDL_HWACCEL"; 00135 static const tString Str_SDL_SRCCOLORKEY = "SDL_SRCCOLORKEY"; 00136 static const tString Str_SDL_RLEACCELOK = "SDL_RLEACCELOK"; 00137 static const tString Str_SDL_RLEACCEL = "SDL_RLEACCEL"; 00138 static const tString Str_SDL_SRCALPHA = "SDL_SRCALPHA"; 00139 static const tString Str_SDL_PREALLOC = "SDL_PREALLOC"; 00140 00141 static const tString Str_Unknown = "Unknown Flag"; 00142 00143 switch (iFlags) 00144 { 00145 case SDL_SWSURFACE: 00146 return Str_SDL_SWSURFACE; 00147 case SDL_HWSURFACE: 00148 return Str_SDL_HWSURFACE; 00149 case SDL_ASYNCBLIT: 00150 return Str_SDL_ASYNCBLIT; 00151 case SDL_ANYFORMAT: 00152 return Str_SDL_ANYFORMAT; 00153 case SDL_HWPALETTE: 00154 return Str_SDL_HWPALETTE; 00155 case SDL_DOUBLEBUF: 00156 return Str_SDL_DOUBLEBUF; 00157 case SDL_FULLSCREEN: 00158 return Str_SDL_FULLSCREEN; 00159 case SDL_OPENGL: 00160 return Str_SDL_OPENGL; 00161 case SDL_OPENGLBLIT: 00162 return Str_SDL_OPENGLBLIT; 00163 case SDL_RESIZABLE: 00164 return Str_SDL_RESIZABLE; 00165 case SDL_NOFRAME: 00166 return Str_SDL_NOFRAME; 00167 case SDL_HWACCEL: 00168 return Str_SDL_HWACCEL; 00169 case SDL_SRCCOLORKEY: 00170 return Str_SDL_SRCCOLORKEY; 00171 case SDL_RLEACCELOK: 00172 return Str_SDL_RLEACCELOK; 00173 case SDL_RLEACCEL: 00174 return Str_SDL_RLEACCEL; 00175 case SDL_SRCALPHA: 00176 return Str_SDL_SRCALPHA; 00177 case SDL_PREALLOC: 00178 return Str_SDL_PREALLOC; 00179 } 00180 return Str_Unknown; 00181 } 00182 00183 00184 } // namespace |