AaronCameron.net
Not Left, nor right. Just correct.
Not a Member? - Login or Create an Account
Wednesday the 23rd of May 2012 @ 06:11pm
Front Page Journal Projects Your Profile About
[]

LibN2L-4 Library Code Reference

Classes
Compounds
Files
Members
Method Index
Full Reference

cSurfaceCommonImp.h

Go 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 #ifndef _n2l4_cSurfaceCommonImp_H
00026 #define _n2l4_cSurfaceCommonImp_H
00027 
00028 #include "n2l/n2l.h"
00029 #include "n2l/geometry.h"
00030 
00031 #include "cSurfaceInterface.h"
00032 
00033 #include "cPixelFormat.h"
00034 #include "cSurfaceProperties.h"
00035 
00036 #include "SDL_video.h"
00037 
00038 namespace n2l
00039 {
00040 
00041     class cVfsFileInterface;
00042 
00043     class cSurfaceCommonImp : public cSurfaceInterface
00044     {
00045     public:
00048         cSurfaceCommonImp();
00049 
00052         virtual ~cSurfaceCommonImp();
00053 
00054         virtual void blit(  const tVector2s & iDestPos,
00055                             const cSurfaceInterface & iSurface,
00056                             const tRectangle2u & iSrcRect =
00057                                 tRectangle2u(   tVector2u(0,0),
00058                                                 tVector2u(0,0) )  );
00059 
00063         virtual const tBool empty() const;
00064 
00066         virtual const cPixelFormat & format() const;
00067 
00069         virtual const cSurfaceProperties & properties() const;
00070 
00072         virtual const void * const aquireROBuffer() const;
00073 
00075         virtual void releaseROBuffer() const;
00076 
00078         virtual const tBool supportsRWBuffer() const;
00079 
00081         virtual void * const aquireRWBuffer();
00082 
00084         virtual void releaseRWBuffer() const;
00085 
00087         virtual const tBool surfaceIsSupported(
00088                                 const cPixelFormat & iFormat,
00089                                 const cSurfaceProperties & iProperties ) const;
00090 
00091         virtual SDL_Surface * const rawSurface() const;
00092 
00093         virtual void clearSurface( const tUint32 iPixelColour );
00094 
00095 
00096         virtual const tUint32 mapRGBA(  const tUbyte iR, const tUbyte iG,
00097                                         const tUbyte iB, const tUbyte iA ) const;
00098 
00099         virtual const tUint32 mapRGB(   const tUbyte iR, const tUbyte iG,
00100                                         const tUbyte iB ) const;
00101 
00102 
00103 
00108         virtual void free();
00109 
00110     protected:
00111         typedef tUint tLockCount;
00112 
00113         void setRawSurface( SDL_Surface * const ioSurface,
00114                             const tBool iTakeOwnership );
00115         
00116         void setFormat( const cPixelFormat & iFormat );
00117         void setProperties( const cSurfaceProperties & iProperties );
00118         
00119         const tLockCount readLocks() const;
00120         const tLockCount writeLocks() const;
00121 
00122         void incReadLock() const;
00123         void incWriteLock() const;
00124 
00125         void decReadLock() const;
00126         void decWriteLock() const;
00127 
00128     private:
00131         tBool               mOwned;
00132 
00137         mutable SDL_Surface * mSurface;
00138 
00139         mutable tLockCount  mReadLockCount;
00140         mutable tLockCount  mWriteLockCount;
00141 
00142         cPixelFormat        mFormat;
00143         cSurfaceProperties  mProperties;
00144 
00145     }; // class
00146 
00147 } // namespace n2l
00148 
00149 #endif
©2012 Aaron Cameron