diff --git a/src/audio/caudiolistener.hpp b/src/audio/caudiolistener.hpp index 5f1daf2a3..4d1cf5887 100755 --- a/src/audio/caudiolistener.hpp +++ b/src/audio/caudiolistener.hpp @@ -7,31 +7,31 @@ namespace EE { namespace Audio { typedef Vector3 Vector3AL; //! Use this special vector because OpenAL doesn't support doubles. /** @brief Listener is a global interface for defining the audio listener properties. */ -class EE_API cAudioListener : public cSingleton { +class EE_API cAudioListener : public tSingleton { public: - /** Change the global volume of all the sounds. ( default 100 ) + /** Change the global volume of all the sounds. ( default 100 ) * @param Volume New global volume, in the range [0, 100] */ void SetGlobalVolume( const ALfloat& Volume ); - + /** Get the Global Volume */ ALfloat GetGlobalVolume(); - + /** Change the position of the listener. \n The default position is (0, 0, 0) */ void SetPosition( const ALfloat& X, const ALfloat& Y, const ALfloat& Z ); - + /** Change the position of the listener from a 3D vector. */ void SetPosition(const Vector3AL& Position); - + /** Get the current position of the listener */ Vector3AL GetPosition(); - + /** Change the orientation of the listener (the point he must look at). \n The default target is (0, 0, -1). */ void SetTarget( const ALfloat& X, const ALfloat& Y, const ALfloat& Z ); - + /** Change the orientation of the listener from a 3D vector. */ void SetTarget(const Vector3AL& Target); - + /** Get the current orientation of the listener (the point he's looking at) */ Vector3AL GetTarget(); }; diff --git a/src/base.hpp b/src/base.hpp index 2170a0b59..17a90fb6d 100644 --- a/src/base.hpp +++ b/src/base.hpp @@ -98,7 +98,7 @@ namespace EE { #define eeSAFE_DELETE_ARRAY(p) { if(p) { delete[](p); (p)=NULL; } } typedef float eeFloat; //! The internal floating point used on EE++. \n This can help to improve compatibility with some platforms. \n And helps for an easy change from single precision to double precision. - typedef double eeDouble; //! The internal double floating point. It's only used when the engine needs some very high precision floating point ( for example the timer ) + typedef double eeDouble; //! The internal double floating point. It's only used when the engine needs some very high precision floating point ( for example the timer ) typedef unsigned int eeUint; typedef signed int eeInt; @@ -110,8 +110,6 @@ namespace EE { #ifdef EE_GLES const GLubyte EE_GLES_INDICES [] = {0, 3, 1, 2}; #endif - - using namespace std; } #endif diff --git a/src/graphics/cfontmanager.hpp b/src/graphics/cfontmanager.hpp index c39edef6c..f2c3d0411 100644 --- a/src/graphics/cfontmanager.hpp +++ b/src/graphics/cfontmanager.hpp @@ -6,8 +6,8 @@ namespace EE { namespace Graphics { -class EE_API cFontManager : public tResourceManager, public cSingleton { - friend class cSingleton; +class EE_API cFontManager : public tResourceManager, public tSingleton { + friend class tSingleton; public: cFontManager(); diff --git a/src/graphics/cframebuffer.hpp b/src/graphics/cframebuffer.hpp index 01acc819c..6940c132d 100644 --- a/src/graphics/cframebuffer.hpp +++ b/src/graphics/cframebuffer.hpp @@ -9,7 +9,7 @@ using namespace EE::Window; namespace EE { namespace Graphics { -class cFrameBuffer { +class EE_API cFrameBuffer { public: static cFrameBuffer * CreateNew( const Uint32& Width, const Uint32& Height, bool DepthBuffer = false ); diff --git a/src/graphics/cframebufferfbo.hpp b/src/graphics/cframebufferfbo.hpp index 870f0ebce..c896c14b7 100644 --- a/src/graphics/cframebufferfbo.hpp +++ b/src/graphics/cframebufferfbo.hpp @@ -7,7 +7,7 @@ namespace EE { namespace Graphics { -class cFrameBufferFBO : public cFrameBuffer { +class EE_API cFrameBufferFBO : public cFrameBuffer { public: cFrameBufferFBO(); diff --git a/src/graphics/cframebufferpbuffer.hpp b/src/graphics/cframebufferpbuffer.hpp index 3da60a2da..8ffcb1179 100644 --- a/src/graphics/cframebufferpbuffer.hpp +++ b/src/graphics/cframebufferpbuffer.hpp @@ -43,7 +43,7 @@ namespace EE { namespace Graphics { -class cFrameBufferPBuffer : public cFrameBuffer { +class EE_API cFrameBufferPBuffer : public cFrameBuffer { public: cFrameBufferPBuffer(); diff --git a/src/graphics/cglobalbatchrenderer.hpp b/src/graphics/cglobalbatchrenderer.hpp index a19237988..8f5c80855 100755 --- a/src/graphics/cglobalbatchrenderer.hpp +++ b/src/graphics/cglobalbatchrenderer.hpp @@ -7,8 +7,8 @@ namespace EE { namespace Graphics { /** @brief The global Batch Renderer class. This class will be used by the engine for the rendering. */ -class EE_API cGlobalBatchRenderer : public cSingleton, public cBatchRenderer { - friend class cSingleton; +class EE_API cGlobalBatchRenderer : public tSingleton, public cBatchRenderer { + friend class tSingleton; public: cGlobalBatchRenderer(); ~cGlobalBatchRenderer(); diff --git a/src/graphics/cglobalshapegroup.hpp b/src/graphics/cglobalshapegroup.hpp index f70d29e53..f34cdcf4d 100644 --- a/src/graphics/cglobalshapegroup.hpp +++ b/src/graphics/cglobalshapegroup.hpp @@ -6,8 +6,8 @@ namespace EE { namespace Graphics { -class EE_API cGlobalShapeGroup : public cShapeGroup, public cSingleton { - friend class cSingleton; +class EE_API cGlobalShapeGroup : public cShapeGroup, public tSingleton { + friend class tSingleton; public: cGlobalShapeGroup(); diff --git a/src/graphics/cshader.cpp b/src/graphics/cshader.cpp index d80e69c36..a51069ae4 100644 --- a/src/graphics/cshader.cpp +++ b/src/graphics/cshader.cpp @@ -16,9 +16,9 @@ cShader::cShader( const Uint32& Type, const std::string& Filename ) { cLog::instance()->Write( std::string( "Couldn't open shader object: " ) + Filename ); } - fs.seekg ( 0, ios::end ); + fs.seekg ( 0, std::ios::end ); Int32 Length = fs.tellg(); - fs.seekg ( 0, ios::beg ); + fs.seekg ( 0, std::ios::beg ); std::string Buffer( Length + 1, 0 ); fs.read( reinterpret_cast ( &Buffer[0] ), Length ); fs.close(); diff --git a/src/graphics/cshaderprogrammanager.hpp b/src/graphics/cshaderprogrammanager.hpp index fbc20c659..558771819 100644 --- a/src/graphics/cshaderprogrammanager.hpp +++ b/src/graphics/cshaderprogrammanager.hpp @@ -6,8 +6,8 @@ namespace EE { namespace Graphics { -class EE_API cShaderProgramManager : public tResourceManager, public cSingleton { - friend class cSingleton; +class EE_API cShaderProgramManager : public tResourceManager, public tSingleton { + friend class tSingleton; public: cShaderProgramManager(); diff --git a/src/graphics/cshapegroupmanager.hpp b/src/graphics/cshapegroupmanager.hpp index 572bf36be..78285cb5a 100644 --- a/src/graphics/cshapegroupmanager.hpp +++ b/src/graphics/cshapegroupmanager.hpp @@ -7,8 +7,8 @@ namespace EE { namespace Graphics { -class EE_API cShapeGroupManager : public tResourceManager, public cSingleton { - friend class cSingleton; +class EE_API cShapeGroupManager : public tResourceManager, public tSingleton { + friend class tSingleton; public: cShapeGroupManager(); diff --git a/src/graphics/ctexturefactory.hpp b/src/graphics/ctexturefactory.hpp index 42c051995..7715fe6d0 100755 --- a/src/graphics/ctexturefactory.hpp +++ b/src/graphics/ctexturefactory.hpp @@ -13,8 +13,8 @@ namespace EE { namespace Graphics { class cGlobalBatchRenderer; /** @brief The Texture Manager Class. Here we do all the textures stuff. (Singleton Class) */ -class EE_API cTextureFactory: public cSingleton, protected cMutex { - friend class cSingleton; +class EE_API cTextureFactory: public tSingleton, protected cMutex { + friend class tSingleton; public: /** Create an empty texture * @param Width Texture Width diff --git a/src/graphics/ctexturegrouploader.cpp b/src/graphics/ctexturegrouploader.cpp index c85386ba8..938f2f2f2 100644 --- a/src/graphics/ctexturegrouploader.cpp +++ b/src/graphics/ctexturegrouploader.cpp @@ -1,13 +1,17 @@ #include "ctexturegrouploader.hpp" #include "cshapegroup.hpp" #include "cshapegroupmanager.hpp" +#include "ctexturepacker.hpp" +#include "../helper/SOIL/stb_image.h" +#include "../helper/SOIL/SOIL.h" namespace EE { namespace Graphics { cTextureGroupLoader::cTextureGroupLoader() : mThreaded(false), mLoaded(false), - mAppPath( AppPath() ) + mAppPath( AppPath() ), + mSkipResourceLoad(false) { } @@ -15,11 +19,35 @@ cTextureGroupLoader::cTextureGroupLoader( const std::string& TextureGroupPath, c mTextureGroupPath( TextureGroupPath ), mThreaded( Threaded ), mLoaded(false), - mAppPath( AppPath() ) + mAppPath( AppPath() ), + mPack(NULL), + mSkipResourceLoad(false) { Load(); } +cTextureGroupLoader::cTextureGroupLoader( const Uint8* Data, const Uint32& DataSize, const std::string& TextureGroupName, const bool& Threaded ) : + mTextureGroupPath( TextureGroupName ), + mThreaded( Threaded ), + mLoaded(false), + mAppPath( AppPath() ), + mPack(NULL), + mSkipResourceLoad(false) +{ + LoadFromMemory( Data, DataSize, TextureGroupName ); +} + +cTextureGroupLoader::cTextureGroupLoader( cPack * Pack, const std::string& FilePackPath, const bool& Threaded ) : + mTextureGroupPath( FilePackPath ), + mThreaded( Threaded ), + mLoaded(false), + mAppPath( AppPath() ), + mPack(NULL), + mSkipResourceLoad(false) +{ + LoadFromPack( Pack, FilePackPath ); +} + cTextureGroupLoader::~cTextureGroupLoader() { } @@ -37,15 +65,13 @@ void cTextureGroupLoader::Load( const std::string& TextureGroupPath ) { if ( TextureGroupPath.size() ) mTextureGroupPath = TextureGroupPath; - sTextureGroupHdr TexGrHdr; - std::fstream fs ( mTextureGroupPath.c_str() , std::ios::in | std::ios::binary ); if ( fs.is_open() ) { - fs.read( reinterpret_cast (&TexGrHdr), sizeof(sTextureGroupHdr) ); + fs.read( reinterpret_cast (&mTexGrHdr), sizeof(sTextureGroupHdr) ); - if ( TexGrHdr.Magic == ( ( 'E' << 0 ) | ( 'E' << 8 ) | ( 'T' << 16 ) | ( 'G' << 24 ) ) ) { - for ( Uint32 i = 0; i < TexGrHdr.TextureCount; i++ ) { + if ( mTexGrHdr.Magic == ( ( 'E' << 0 ) | ( 'E' << 8 ) | ( 'T' << 16 ) | ( 'G' << 24 ) ) ) { + for ( Uint32 i = 0; i < mTexGrHdr.TextureCount; i++ ) { sTextureHdr tTextureHdr; sTempTexGroup tTexGroup; @@ -57,7 +83,8 @@ void cTextureGroupLoader::Load( const std::string& TextureGroupPath ) { std::string name( &tTextureHdr.Name[0] ); std::string path( FileRemoveFileName( mTextureGroupPath ) + name ); - mRL.Add( new cTextureLoader( path ) ); + if ( !mSkipResourceLoad ) + mRL.Add( new cTextureLoader( path ) ); fs.read( reinterpret_cast (&tTexGroup.Shapes[0]), sizeof(sShapeHdr) * tTextureHdr.ShapeCount ); @@ -65,7 +92,8 @@ void cTextureGroupLoader::Load( const std::string& TextureGroupPath ) { } } - mRL.Load(); + if ( !mSkipResourceLoad ) + mRL.Load(); if ( !mThreaded ) CreateShapes(); @@ -74,6 +102,8 @@ void cTextureGroupLoader::Load( const std::string& TextureGroupPath ) { void cTextureGroupLoader::LoadFromPack( cPack * Pack, const std::string& FilePackPath ) { if ( NULL != Pack && Pack->IsOpen() && -1 != Pack->Exists( FilePackPath ) ) { + mPack = Pack; + std::vector TempData; Pack->ExtractFileToMemory( FilePackPath, TempData ); @@ -88,16 +118,14 @@ void cTextureGroupLoader::LoadFromMemory( const Uint8* Data, const Uint32& DataS if ( TextureGroupName.size() ) mTextureGroupPath = TextureGroupName; - sTextureGroupHdr TexGrHdr; - const Uint8* dataPtr = Data; if ( NULL != dataPtr ) { - memcpy( (void*)&TexGrHdr, dataPtr, sizeof(sTextureGroupHdr) ); + memcpy( (void*)&mTexGrHdr, dataPtr, sizeof(sTextureGroupHdr) ); dataPtr += sizeof(sTextureGroupHdr); - if ( TexGrHdr.Magic == ( ( 'E' << 0 ) | ( 'E' << 8 ) | ( 'T' << 16 ) | ( 'G' << 24 ) ) ) { - for ( Uint32 i = 0; i < TexGrHdr.TextureCount; i++ ) { + if ( mTexGrHdr.Magic == ( ( 'E' << 0 ) | ( 'E' << 8 ) | ( 'T' << 16 ) | ( 'G' << 24 ) ) ) { + for ( Uint32 i = 0; i < mTexGrHdr.TextureCount; i++ ) { sTextureHdr tTextureHdr; sTempTexGroup tTexGroup; @@ -110,7 +138,10 @@ void cTextureGroupLoader::LoadFromMemory( const Uint8* Data, const Uint32& DataS std::string name( &tTextureHdr.Name[0] ); std::string path( FileRemoveFileName( mTextureGroupPath ) + name ); - mRL.Add( new cTextureLoader( path ) ); + if ( NULL != mPack ) + mRL.Add( new cTextureLoader( mPack, path ) ); + else + mRL.Add( new cTextureLoader( mAppPath + path ) ); memcpy( (void*)(&tTexGroup.Shapes[0]), dataPtr, sizeof(sShapeHdr) * tTextureHdr.ShapeCount ); dataPtr += sizeof(sShapeHdr) * tTextureHdr.ShapeCount; @@ -145,7 +176,7 @@ void cTextureGroupLoader::CreateShapes() { // Create the Shape Group with the name of the real texture, not the Childs ( example load 1.png and not 1_ch1.png ) if ( 0 == z ) { - if ( tTexHdr->Flags & HDR_TEXTURE_FLAG_REMOVE_EXTENSION ) + if ( mTexGrHdr.Flags & HDR_TEXTURE_GROUP_REMOVE_EXTENSION ) name = FileRemoveExtension( name ); tSG = new cShapeGroup( name ); @@ -158,7 +189,7 @@ void cTextureGroupLoader::CreateShapes() { std::string ShapeName( &tSh->Name[0] ); - if ( tSh->Flags & HDR_SHAPE_FLAG_REMOVE_EXTENSION ) + if ( mTexGrHdr.Flags & HDR_TEXTURE_GROUP_REMOVE_EXTENSION ) ShapeName = FileRemoveExtension( ShapeName ); eeRecti tRect( tSh->X, tSh->Y, tSh->X + tSh->Width, tSh->Y + tSh->Height ); @@ -191,5 +222,155 @@ const bool& cTextureGroupLoader::IsLoaded() const { return mLoaded; } -}} +bool cTextureGroupLoader::UpdateTextureAtlas( std::string TextureAtlasPath, std::string ImagesPath ) { + if ( !TextureAtlasPath.size() || !ImagesPath.size() || !FileExists( TextureAtlasPath ) || !IsDirectory( ImagesPath ) ) + return false; + mSkipResourceLoad = true; + Load( TextureAtlasPath ); + mSkipResourceLoad = false; + + if ( !mTempGroups.size() ) + return false; + + Int32 x, y, c; + + Int32 NeedUpdate = 0; + + DirPathAddSlashAtEnd( ImagesPath ); + + Uint32 z; + + Uint32 totalShapes = 0; + for ( z = 0; z < mTempGroups.size(); z++ ) + totalShapes += mTempGroups[z].Texture.ShapeCount; + + Uint32 totalImages = 0; + std::vector PathFiles = FilesGetInPath( ImagesPath ); + + for ( z = 0; z < PathFiles.size(); z++ ) { + std::string realpath( ImagesPath + PathFiles[z] ); + + if ( stbi_info( realpath.c_str(), &x, &y, &c ) ) + totalImages++; + } + + if ( totalShapes != totalImages ) { + NeedUpdate = 2; + } else { + for ( z = 0; z < mTempGroups.size(); z++ ) { + sTempTexGroup * tTexGroup = &mTempGroups[z]; + sTextureHdr * tTexHdr = &tTexGroup->Texture; + + if ( 2 != NeedUpdate ) { + for ( Int32 i = 0; i < tTexHdr->ShapeCount; i++ ) { + sShapeHdr * tSh = &tTexGroup->Shapes[i]; + + std::string path( ImagesPath + tSh->Name ); + + if ( FileExists( path ) ) { + if ( stbi_info( path.c_str(), &x, &y, &c ) ) { + if ( tSh->Date != FileGetModificationDate( path ) ) { + if ( ( !( tSh->Flags & HDR_SHAPE_FLAG_FLIPED ) && tSh->Width == x && tSh->Height == y ) || // If size or channels changed, the image need update + ( ( tSh->Flags & HDR_SHAPE_FLAG_FLIPED ) && tSh->Width == y && tSh->Height == x ) || + tSh->Channels != c + ) + { + NeedUpdate = 1; + } else { + NeedUpdate = 2; + break; + } + } + } else { + NeedUpdate = 2; // Something is wrong on the image + } + } else { + NeedUpdate = 2; // Need recreation of the whole texture atlas, some image where deleted. + break; + } + } + } else { + break; + } + } + } + + if ( NeedUpdate ) { + std::string tapath( FileRemoveExtension( TextureAtlasPath ) + "." + SaveTypeToExtension( mTexGrHdr.Format ) ); + + if ( 2 == NeedUpdate ) { + cTexturePacker tp( mTexGrHdr.Width, mTexGrHdr.Height, mTexGrHdr.Flags & HDR_TEXTURE_GROUP_POW_OF_TWO, mTexGrHdr.PixelBorder, mTexGrHdr.Flags & HDR_TEXTURE_GROUP_ALLOW_FLIPPING ); + + tp.AddTexturesPath( ImagesPath ); + + tp.PackTextures(); + + tp.Save( tapath, (EE_SAVETYPE)mTexGrHdr.Format ); + } else if ( 1 == NeedUpdate ) { + std::string etgpath = FileRemoveExtension( tapath ) + ".etg"; + std::fstream fs ( etgpath.c_str() , std::ios::out | std::ios::binary ); + + if ( !fs.is_open() ) + return false; + + fs.write( reinterpret_cast (&mTexGrHdr), sizeof(sTextureGroupHdr) ); + + for ( Uint32 z = 0; z < mTempGroups.size(); z++ ) { + if ( z != 0 ) { + tapath = FileRemoveExtension( TextureAtlasPath ) + "_ch" + toStr( z ) + "." + SaveTypeToExtension( mTexGrHdr.Format ); + } + + unsigned char * imgPtr = SOIL_load_image( tapath.c_str(), &x, &y, &c, SOIL_LOAD_AUTO ); + + if ( NULL != imgPtr ) { + cImage Img( imgPtr, x, y, c ); + Img.AvoidFreeImage( true ); + + sTempTexGroup * tTexGroup = &mTempGroups[z]; + sTextureHdr * tTexHdr = &tTexGroup->Texture; + + fs.write( reinterpret_cast (tTexHdr), sizeof(sTextureHdr) ); + + for ( Int32 i = 0; i < tTexHdr->ShapeCount; i++ ) { + sShapeHdr * tSh = &tTexGroup->Shapes[i]; + + std::string imgcopypath( ImagesPath + tSh->Name ); + + Uint32 ModifDate = FileGetModificationDate( imgcopypath ); + + if ( tSh->Date != ModifDate ) { + tSh->Date = ModifDate; // Update the shape hdr + + unsigned char * imgCopyPtr = SOIL_load_image( imgcopypath.c_str(), &x, &y, &c, SOIL_LOAD_AUTO ); + + if ( NULL != imgCopyPtr ) { + cImage ImgCopy( imgCopyPtr, x, y, c ); + ImgCopy.AvoidFreeImage( true ); + + Img.CopyImage( &ImgCopy, tSh->X, tSh->Y ); // Update the image into the texture atlas + + SOIL_free_image_data( imgCopyPtr ); + } else + break; + } + } + + fs.write( reinterpret_cast (&tTexGroup->Shapes[0]), sizeof(sShapeHdr) * tTexHdr->ShapeCount ); + + Img.SaveToFile( tapath, (EE_SAVETYPE)mTexGrHdr.Format ); + + SOIL_free_image_data( imgPtr ); + } + else + return false; // fatal error + } + + fs.close(); + } + } + + return true; +} + +}} diff --git a/src/graphics/ctexturegrouploader.hpp b/src/graphics/ctexturegrouploader.hpp index ad984cf7a..0acbadd2a 100644 --- a/src/graphics/ctexturegrouploader.hpp +++ b/src/graphics/ctexturegrouploader.hpp @@ -17,6 +17,10 @@ class EE_API cTextureGroupLoader { cTextureGroupLoader( const std::string& TextureGroupPath, const bool& Threaded = false ); + cTextureGroupLoader( const Uint8* Data, const Uint32& DataSize, const std::string& TextureGroupName, const bool& Threaded = false ); + + cTextureGroupLoader( cPack * Pack, const std::string& FilePackPath, const bool& Threaded = false ); + ~cTextureGroupLoader(); void Update(); @@ -32,18 +36,24 @@ class EE_API cTextureGroupLoader { void Threaded( const bool& threaded ); const bool& IsLoaded() const; + + /** Will check if the texture atlas is updated ( all the image of the path are inside the texture atlas, and are the same version, otherwise it will recreate or update the texture atlas. */ + bool UpdateTextureAtlas( std::string TextureAtlasPath, std::string ImagesPath ); protected: cResourceLoader mRL; std::string mTextureGroupPath; bool mThreaded; bool mLoaded; std::string mAppPath; + cPack * mPack; + bool mSkipResourceLoad; typedef struct sTempTexGroupS { sTextureHdr Texture; std::vector Shapes; } sTempTexGroup; + sTextureGroupHdr mTexGrHdr; std::vector mTempGroups; void CreateShapes(); diff --git a/src/graphics/ctexturepacker.cpp b/src/graphics/ctexturepacker.cpp index f460cec34..f4dcf8513 100644 --- a/src/graphics/ctexturepacker.cpp +++ b/src/graphics/ctexturepacker.cpp @@ -352,8 +352,7 @@ void cTexturePacker::CreateChild() { bool cTexturePacker::AddTexturesPath( std::string TexturesPath ) { if ( IsDirectory( TexturesPath ) ) { - if ( TexturesPath[ TexturesPath.size() - 1 ] != '/' && TexturesPath[ TexturesPath.size() - 1 ] != '\\' ) - TexturesPath += "/"; + DirPathAddSlashAtEnd( TexturesPath ); std::vector files = FilesGetInPath( TexturesPath ); std::sort( files.begin(), files.end() ); @@ -528,6 +527,8 @@ void cTexturePacker::Save( const std::string& Filepath, const EE_SAVETYPE& Forma } } + mFormat = Format; + Img.SaveToFile( Filepath, Format ); ChildSave( Format ); @@ -555,6 +556,20 @@ void cTexturePacker::SaveShapes() { TexGrHdr.Magic = ( ( 'E' << 0 ) | ( 'E' << 8 ) | ( 'T' << 16 ) | ( 'G' << 24 ) ); TexGrHdr.TextureCount = 1 + GetChildCount(); + TexGrHdr.Format = mFormat; + TexGrHdr.Width = mWidth; + TexGrHdr.Height = mHeight; + TexGrHdr.PixelBorder = mPixelBorder; + TexGrHdr.Flags = 0; + + if ( mAllowFlipping ) + TexGrHdr.Flags |= HDR_TEXTURE_GROUP_ALLOW_FLIPPING; + + if ( !mSaveExtensions ) + TexGrHdr.Flags |= HDR_TEXTURE_GROUP_REMOVE_EXTENSION; + + if ( mForcePowOfTwo ) + TexGrHdr.Flags |= HDR_TEXTURE_GROUP_POW_OF_TWO; sTextureHdr TexHdr[ TexGrHdr.TextureCount ]; @@ -626,6 +641,7 @@ void cTexturePacker::CreateShapesHdr( cTexturePacker * Packer, std::vectorWidth(); tShapeHdr.Height = tTex->Height(); + tShapeHdr.Channels = tTex->Channels(); tShapeHdr.DestWidth = tTex->Width(); tShapeHdr.DestHeight = tTex->Height(); tShapeHdr.OffsetX = 0; @@ -638,9 +654,6 @@ void cTexturePacker::CreateShapesHdr( cTexturePacker * Packer, std::vectorFlipped() ) tShapeHdr.Flags |= HDR_SHAPE_FLAG_FLIPED; - if ( !mSaveExtensions ) - tShapeHdr.Flags |= HDR_SHAPE_FLAG_REMOVE_EXTENSION; - fs->write( reinterpret_cast (&tShapeHdr), sizeof(sShapeHdr) ); } } @@ -657,13 +670,7 @@ sTextureHdr cTexturePacker::CreateTextureHdr( cTexturePacker * Packer ) { TexHdr.ResourceID = MakeHash( name ); TexHdr.Size = FileSize( Packer->GetFilepath() ); - TexHdr.Width = Packer->GetWidth(); - TexHdr.Height = Packer->GetHeight(); TexHdr.ShapeCount = Packer->GetPlacedCount(); - TexHdr.Flags = 0; - - if ( !mSaveExtensions ) - TexHdr.Flags |= HDR_TEXTURE_FLAG_REMOVE_EXTENSION; return TexHdr; } diff --git a/src/graphics/ctexturepacker.hpp b/src/graphics/ctexturepacker.hpp index 222643841..50488b699 100644 --- a/src/graphics/ctexturepacker.hpp +++ b/src/graphics/ctexturepacker.hpp @@ -89,6 +89,7 @@ class EE_API cTexturePacker { bool mForcePowOfTwo; Int32 mPixelBorder; bool mSaveExtensions; + EE_SAVETYPE mFormat; cTexturePacker * GetChild() const; diff --git a/src/graphics/ctexturepackertex.cpp b/src/graphics/ctexturepackertex.cpp index 67a4be16f..c68d9d56c 100644 --- a/src/graphics/ctexturepackertex.cpp +++ b/src/graphics/ctexturepackertex.cpp @@ -7,6 +7,7 @@ cTexturePackerTex::cTexturePackerTex( const std::string& Name ) : mName(Name), mWidth(0), mHeight(0), + mChannels(0), mX(0), mY(0), mLongestEdge(0), @@ -16,9 +17,7 @@ cTexturePackerTex::cTexturePackerTex( const std::string& Name ) : mLoadedInfo(false), mDisabled(false) { - Int32 c; - - if ( stbi_info( Name.c_str(), &mWidth, &mHeight, &c ) ) { + if ( stbi_info( Name.c_str(), &mWidth, &mHeight, &mChannels ) ) { mArea = mWidth * mHeight; mLongestEdge = ( mWidth >= mHeight ) ? mWidth : mHeight; mLoadedInfo = true; diff --git a/src/graphics/ctexturepackertex.hpp b/src/graphics/ctexturepackertex.hpp index 8510aff28..9058ae327 100644 --- a/src/graphics/ctexturepackertex.hpp +++ b/src/graphics/ctexturepackertex.hpp @@ -17,6 +17,8 @@ class cTexturePackerTex { inline const Int32& Y() const { return mY; } + inline const Int32& Channels() { return mChannels; } + inline void X( const Int32& x ) { mX = x; } inline void Y( const Int32& y ) { mY = y; } @@ -46,6 +48,7 @@ class cTexturePackerTex { std::string mName; Int32 mWidth; Int32 mHeight; + Int32 mChannels; Int32 mX; Int32 mY; Int32 mLongestEdge; diff --git a/src/graphics/packerhelper.hpp b/src/graphics/packerhelper.hpp index 7f906883b..195405274 100644 --- a/src/graphics/packerhelper.hpp +++ b/src/graphics/packerhelper.hpp @@ -14,6 +14,7 @@ typedef struct sShapeHdrS { Int32 Y; Int32 Width; Int32 Height; + Int32 Channels; Uint32 ResourceID; Int32 OffsetX; Int32 OffsetY; @@ -23,25 +24,28 @@ typedef struct sShapeHdrS { } sShapeHdr; #define HDR_SHAPE_FLAG_FLIPED ( 1 << 0 ) -#define HDR_SHAPE_FLAG_REMOVE_EXTENSION ( 1 << 1 ) typedef struct sTextureHdrS { char Name[ HDR_NAME_SIZE ]; Uint32 ResourceID; Uint32 Size; - Int32 Width; - Int32 Height; Int32 ShapeCount; - Uint32 Flags; } sTextureHdr; -#define HDR_TEXTURE_FLAG_REMOVE_EXTENSION ( 1 << 1 ) - typedef struct sTextureGroupHdrS { Uint32 Magic; Uint32 TextureCount; + Uint32 Format; + Int32 Width; + Int32 Height; + Uint32 PixelBorder; + Uint32 Flags; } sTextureGroupHdr; +#define HDR_TEXTURE_GROUP_ALLOW_FLIPPING ( 1 << 0 ) +#define HDR_TEXTURE_GROUP_REMOVE_EXTENSION ( 1 << 1 ) +#define HDR_TEXTURE_GROUP_POW_OF_TWO ( 1 << 2 ) + }}} #endif diff --git a/src/system/cinifile.cpp b/src/system/cinifile.cpp index bb3cab3e7..a9b69ac93 100755 --- a/src/system/cinifile.cpp +++ b/src/system/cinifile.cpp @@ -3,9 +3,9 @@ namespace EE { namespace System { #if EE_PLATFORM == EE_PLATFORM_WIN32 -#define iniEOL endl +#define iniEOL std::endl #else -#define iniEOL '\r' << endl +#define iniEOL '\r' << std::endl #endif cIniFile::cIniFile ( std::string const iniPath ) { @@ -30,12 +30,12 @@ bool cIniFile::LoadFromMemory( const Uint8* RAWData, const Uint32& size ) { bool cIniFile::LoadFromFile( const std::string& iniPath ) { // Normally you would use ifstream, but the SGI CC compiler has // a few bugs with ifstream. So ... fstream used. - fstream f; + std::fstream f; std::string line; Path ( iniPath ); - f.open ( mPath.c_str(), ios::in ); + f.open ( mPath.c_str(), std::ios::in ); if ( f.fail() ) return false; @@ -112,9 +112,9 @@ bool cIniFile::WriteFile() { unsigned commentID, keyID, valueID; // Normally you would use ofstream, but the SGI CC compiler has // a few bugs with ofstream. So ... fstream used. - fstream f; + std::fstream f; - f.open ( mPath.c_str(), ios::out ); + f.open ( mPath.c_str(), std::ios::out ); if ( f.fail() ) return false; @@ -326,8 +326,8 @@ bool cIniFile::DeleteValue ( std::string const keyname, std::string const valuen return false; // This looks strange, but is neccessary. - vector::iterator npos = mKeys[keyID].names.begin() + valueID; - vector::iterator vpos = mKeys[keyID].values.begin() + valueID; + std::vector::iterator npos = mKeys[keyID].names.begin() + valueID; + std::vector::iterator vpos = mKeys[keyID].values.begin() + valueID; mKeys[keyID].names.erase ( npos, npos + 1 ); mKeys[keyID].values.erase ( vpos, vpos + 1 ); @@ -346,8 +346,8 @@ bool cIniFile::DeleteKey ( std::string const keyname ) { //mKeys[keyID].names.clear(); //mKeys[keyID].values.clear(); - vector::iterator npos = mNames.begin() + keyID; - vector::iterator kpos = mKeys.begin() + keyID; + std::vector::iterator npos = mNames.begin() + keyID; + std::vector::iterator kpos = mKeys.begin() + keyID; mNames.erase ( npos, npos + 1 ); mKeys.erase ( kpos, kpos + 1 ); @@ -378,7 +378,7 @@ std::string cIniFile::HeaderComment ( unsigned const commentID ) const { bool cIniFile::DeleteHeaderComment ( unsigned commentID ) { if ( commentID < mComments.size() ) { - vector::iterator cpos = mComments.begin() + commentID; + std::vector::iterator cpos = mComments.begin() + commentID; mComments.erase ( cpos, cpos + 1 ); return true; } @@ -428,7 +428,7 @@ std::string cIniFile::KeyComment ( std::string const keyname, unsigned const com bool cIniFile::DeleteKeyComment ( unsigned const keyID, unsigned const commentID ) { if ( keyID < mKeys.size() && commentID < mKeys[keyID].comments.size() ) { - vector::iterator cpos = mKeys[keyID].comments.begin() + commentID; + std::vector::iterator cpos = mKeys[keyID].comments.begin() + commentID; mKeys[keyID].comments.erase ( cpos, cpos + 1 ); return true; } diff --git a/src/system/cinifile.hpp b/src/system/cinifile.hpp index ebe4a15a1..ceadbb7c2 100755 --- a/src/system/cinifile.hpp +++ b/src/system/cinifile.hpp @@ -29,13 +29,13 @@ class EE_API cIniFile { bool mCaseInsensitive; std::string mPath; struct key { - vector names; - vector values; - vector comments; + std::vector names; + std::vector values; + std::vector comments; }; - vector mKeys; - vector mNames; - vector mComments; + std::vector mKeys; + std::vector mNames; + std::vector mComments; std::string CheckCase ( std::string s ) const; std::vector mLines; diff --git a/src/system/clog.cpp b/src/system/clog.cpp index 02bdb99ab..51f8877ca 100755 --- a/src/system/clog.cpp +++ b/src/system/clog.cpp @@ -18,9 +18,9 @@ cLog::~cLog() { std::string str = mFilePath; str += "log.log"; - ofstream fs(str.c_str(), ios::app); + std::ofstream fs(str.c_str(), std::ios::app); - fs << mData << endl; + fs << mData << std::endl; fs.close(); } } diff --git a/src/system/clog.hpp b/src/system/clog.hpp index f63aaa1cb..1553d395b 100755 --- a/src/system/clog.hpp +++ b/src/system/clog.hpp @@ -6,8 +6,8 @@ namespace EE { namespace System { -class EE_API cLog : public cSingleton { - friend class cSingleton; +class EE_API cLog : public tSingleton { + friend class tSingleton; public: void Save(const std::string& filepath = "./"); void Write(const std::string& Text, const bool& newLine = true); diff --git a/src/system/cpak.cpp b/src/system/cpak.cpp index 2e8f2aeb8..ca51e7d67 100755 --- a/src/system/cpak.cpp +++ b/src/system/cpak.cpp @@ -50,7 +50,7 @@ bool cPak::Open( const std::string& path ) { if ( CheckPack() == 0 ) { myPak.pakFilesNum = myPak.header.dir_length / 64; // Number of files in the PAK - myPak.fs.seekg( myPak.header.dir_offset, ios::beg ); // Seek to read the pakEntrys + myPak.fs.seekg( myPak.header.dir_offset, std::ios::beg ); // Seek to read the pakEntrys for ( Uint32 i = 0; i < myPak.pakFilesNum; i++ ) { // Read all the pakEntrys pakEntry Entry; @@ -104,7 +104,7 @@ bool cPak::ExtractFile( const std::string& path , const std::string& dest ) { Int32 Pos = Exists( path ); if ( Pos != -1 ) { - fstream fs ( dest.c_str() , std::ios::out | std::ios::binary ); + std::fstream fs ( dest.c_str() , std::ios::out | std::ios::binary ); std::vector tmpv; if ( ExtractFileToMemory( path, tmpv ) ) @@ -130,7 +130,7 @@ bool cPak::ExtractFileToMemory( const std::string& path, std::vector& dat data.clear(); data.resize( pakFiles[Pos].file_length ); - myPak.fs.seekg( pakFiles[Pos].file_position, ios::beg ); + myPak.fs.seekg( pakFiles[Pos].file_position, std::ios::beg ); myPak.fs.read( reinterpret_cast (&data[0]), pakFiles[Pos].file_length ); Ret = true; @@ -152,7 +152,7 @@ bool cPak::ExtractFileToMemory( const std::string& path, Uint8** data, Uint32* d *dataSize = pakFiles[Pos].file_length; *data = new Uint8[ (*dataSize) ]; - myPak.fs.seekg( pakFiles[Pos].file_position, ios::beg ); + myPak.fs.seekg( pakFiles[Pos].file_position, std::ios::beg ); myPak.fs.read( reinterpret_cast ( *data ), pakFiles[Pos].file_length ); Ret = true; @@ -175,7 +175,7 @@ bool cPak::AddFile( const Uint8 * data, const Uint32& dataSize, const std::strin myPak.header.dir_length = sizeof(pakEntry); myPak.pakFilesNum = 1; - myPak.fs.seekg( 4 , ios::beg ); // seek after head (PACK) + myPak.fs.seekg( 4 , std::ios::beg ); // seek after head (PACK) myPak.fs.write( reinterpret_cast (&myPak.header.dir_offset), sizeof( myPak.header.dir_offset ) ); myPak.fs.write( reinterpret_cast (&myPak.header.dir_length), sizeof( myPak.header.dir_length ) ); @@ -201,17 +201,17 @@ bool cPak::AddFile( const Uint8 * data, const Uint32& dataSize, const std::strin std::vector pakE; pakE.resize( myPak.pakFilesNum + 1 ); // Alloc space for all the pakEntrys and the new one - myPak.fs.seekg( myPak.header.dir_offset, ios::beg ); // seek to the file pakEntrys + myPak.fs.seekg( myPak.header.dir_offset, std::ios::beg ); // seek to the file pakEntrys myPak.fs.read( reinterpret_cast (&pakE[0]), sizeof(pakEntry) * myPak.pakFilesNum ); // get all the pakEntrys myPak.header.dir_offset = myPak.header.dir_offset + fsize; // Update the new dir_offset myPak.header.dir_length = myPak.header.dir_length + sizeof(pakEntry); // Update the new dir_length - myPak.fs.seekg( 4 , ios::beg ); // Update the new dir_offset and dir_length to the pakFile + myPak.fs.seekg( 4 , std::ios::beg ); // Update the new dir_offset and dir_length to the pakFile myPak.fs.write( reinterpret_cast (&myPak.header.dir_offset), sizeof( myPak.header.dir_offset ) ); myPak.fs.write( reinterpret_cast (&myPak.header.dir_length), sizeof( myPak.header.dir_length ) ); - myPak.fs.seekg( (myPak.header.dir_offset - fsize), ios::beg ); // Seek to the file allocation zone + myPak.fs.seekg( (myPak.header.dir_offset - fsize), std::ios::beg ); // Seek to the file allocation zone myPak.fs.write( reinterpret_cast (&data[0]), fsize ); // Alloc the file // Fill the new file data on the pakEntry diff --git a/src/system/crc4.cpp b/src/system/crc4.cpp index 72a7b90b5..488679384 100644 --- a/src/system/crc4.cpp +++ b/src/system/crc4.cpp @@ -79,7 +79,7 @@ bool cRC4::EncryptFile( const std::string& SourceFile, const std::string& DestFi fs2.write( reinterpret_cast( &tmpv[0] ), (std::streamsize)tmpv.size() ); fs2.close(); } else { - fs.seekg( 0, ios::beg ); + fs.seekg( 0, std::ios::beg ); fs.write( reinterpret_cast( &tmpv[0] ), (std::streamsize)tmpv.size() ); } diff --git a/src/system/singleton.hpp b/src/system/singleton.hpp index 7cfb63cc1..e54813248 100755 --- a/src/system/singleton.hpp +++ b/src/system/singleton.hpp @@ -5,7 +5,7 @@ namespace EE { namespace System { /** @brief Template class for only one instance classes. */ template -class cSingleton { +class tSingleton { static T* ms_singleton; public: @@ -35,7 +35,7 @@ class cSingleton { } } }; -template T* cSingleton ::ms_singleton = 0; +template T* tSingleton ::ms_singleton = 0; }} #endif diff --git a/src/test/ee.cpp b/src/test/ee.cpp index 33891c93e..0818b586c 100644 --- a/src/test/ee.cpp +++ b/src/test/ee.cpp @@ -291,7 +291,7 @@ void cEETest::Init() { Launch(); } else { - cout << "Failed to start EE++" << endl; + std::cout << "Failed to start EE++" << std::endl; cEngine::DestroySingleton(); exit(0); } @@ -541,7 +541,7 @@ void cEETest::LoadTextures() { CL2.AddFrame(TN[0], 96, 96); CL2.Color( eeRGBA( 255, 255, 255, 255 ) ); - mTGL = new cTextureGroupLoader( MyPath + "res/1.etg", false ); + mTGL = new cTextureGroupLoader( MyPath + "data/bnb/bnb.etg" ); mBlindy.AddFramesByPattern( "rn" ); mBlindy.UpdatePos( 320.f, 0.f ); @@ -1167,9 +1167,15 @@ void cEETest::Particles() { } int main (int argc, char * argv []) { -/* cTexturePacker tp( 512, 512 ); - - std::string Path = "/home/downloads/files/temp/bnb/allin/"; +/* std::string Path( "/home/downloads/files/temp/bnb/allin/" ); +*/ +/* + cTextureGroupLoader * tgl = new cTextureGroupLoader(); + tgl->UpdateTextureAtlas( AppPath() + "data/bnb/bnb.etg", Path ); + delete tgl; +*/ +/* + cTexturePacker tp( 512, 512 ); if ( argc > 1 ) Path = std::string( argv[1] ); @@ -1178,7 +1184,7 @@ int main (int argc, char * argv []) { tp.PackTextures(); - tp.Save( AppPath() + "res/1.png", EE_SAVE_TYPE_PNG ); + tp.Save( AppPath() + "data/bnb/bnb.png", EE_SAVE_TYPE_PNG ); */ cEETest Test; Test.Process(); diff --git a/src/ui/cuimanager.hpp b/src/ui/cuimanager.hpp index a44e7d3db..6657353f4 100644 --- a/src/ui/cuimanager.hpp +++ b/src/ui/cuimanager.hpp @@ -8,8 +8,8 @@ namespace EE { namespace UI { class cUIControl; -class EE_API cUIManager : public cSingleton { - friend class cSingleton; +class EE_API cUIManager : public tSingleton { + friend class tSingleton; public: cUIManager(); ~cUIManager(); diff --git a/src/utils/easing.hpp b/src/utils/easing.hpp index 8d51efadc..bca06f125 100644 --- a/src/utils/easing.hpp +++ b/src/utils/easing.hpp @@ -7,7 +7,7 @@ namespace EE { namespace Utils { namespace easing { typedef eeFloat( *easingCbFunc )( eeFloat, eeFloat, eeFloat, eeFloat ); -extern easingCbFunc easingCb[]; +extern EE_API easingCbFunc easingCb[]; /** * Calculate the position of a point from a linear interpolation. @@ -16,164 +16,164 @@ extern easingCbFunc easingCb[]; * @param b Specifies the initial value of the animation property. * @param c Specifies the total change in the animation property. * @param d Specifies the duration of the motion. -* @return The value of the interpolated property at the specified time. -*/ -eeFloat LinearInterpolation( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +* @return The value of the interpolated property at the specified time. +*/ +eeFloat EE_API LinearInterpolation( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); /** -* The QuadraticIn() method starts motion from a zero velocity -* and then accelerates motion as it executes. +* The QuadraticIn() method starts motion from a zero velocity +* and then accelerates motion as it executes. * @param t Specifies the current time, between 0 and duration inclusive. * @param b Specifies the initial value of the animation property. * @param c Specifies the total change in the animation property. * @param d Specifies the duration of the motion. * @return The value of the interpolated property at the specified time. -*/ -eeFloat QuadraticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +*/ +eeFloat EE_API QuadraticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); /** -* The QuadraticOut() method starts motion fast -* and then decelerates motion to a zero velocity as it executes. +* The QuadraticOut() method starts motion fast +* and then decelerates motion to a zero velocity as it executes. * * @param t Specifies the current time, between 0 and duration inclusive. * @param b Specifies the initial value of the animation property. * @param c Specifies the total change in the animation property. * @param d Specifies the duration of the motion. * @return The value of the interpolated property at the specified time. -*/ -eeFloat QuadraticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +*/ +eeFloat EE_API QuadraticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); /** * The QuadraticInOut() method combines the motion * of the QuadraticIn() and QuadraticOut() methods -* to start the motion from a zero velocity, -* accelerate motion, then decelerate to a zero velocity. +* to start the motion from a zero velocity, +* accelerate motion, then decelerate to a zero velocity. * * @param t Specifies the current time, between 0 and duration inclusive. * @param b Specifies the initial value of the animation property. * @param c Specifies the total change in the animation property. * @param d Specifies the duration of the motion. * @return The value of the interpolated property at the specified time. -*/ -eeFloat QuadraticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +*/ +eeFloat EE_API QuadraticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); /** -* The SineIn() method starts motion from zero velocity -* and then accelerates motion as it executes. +* The SineIn() method starts motion from zero velocity +* and then accelerates motion as it executes. * * @param t Specifies the current time, between 0 and duration inclusive. * @param b Specifies the initial value of the animation property. * @param c Specifies the total change in the animation property. * @param d Specifies the duration of the motion. -* @return The value of the interpolated property at the specified time. -*/ -eeFloat SineIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +* @return The value of the interpolated property at the specified time. +*/ +eeFloat EE_API SineIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); /** -* The easeOut() method starts motion fast -* and then decelerates motion to a zero velocity as it executes. +* The easeOut() method starts motion fast +* and then decelerates motion to a zero velocity as it executes. * * @param t Specifies the current time, between 0 and duration inclusive. * @param b Specifies the initial value of the animation property. * @param c Specifies the total change in the animation property. * @param d Specifies the duration of the motion. -* @return The value of the interpolated property at the specified time. -*/ -eeFloat SineOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +* @return The value of the interpolated property at the specified time. +*/ +eeFloat EE_API SineOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); /** * The easeInOut() method combines the motion * of the easeIn() and easeOut() methods -* to start the motion from a zero velocity, accelerate motion, -* then decelerate to a zero velocity. +* to start the motion from a zero velocity, accelerate motion, +* then decelerate to a zero velocity. * * @param t Specifies the current time, between 0 and duration inclusive. * @param b Specifies the initial value of the animation property. * @param c Specifies the total change in the animation property. * @param d Specifies the duration of the motion. -* @return The value of the interpolated property at the specified time. -*/ -eeFloat SineInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +* @return The value of the interpolated property at the specified time. +*/ +eeFloat EE_API SineInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); /** -* The ExponentialIn() method starts motion slowly -* and then accelerates motion as it executes. +* The ExponentialIn() method starts motion slowly +* and then accelerates motion as it executes. * * @param t Specifies the current time, between 0 and duration inclusive. * @param b Specifies the initial position of a component. * @param c Specifies the total change in position of the component. * @param d Specifies the duration of the effect, in milliseconds. -* @return Number corresponding to the position of the component. -*/ -eeFloat ExponentialIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +* @return Number corresponding to the position of the component. +*/ +eeFloat EE_API ExponentialIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); /** -* The ExponentialOut() method starts motion fast -* and then decelerates motion to a zero velocity as it executes. +* The ExponentialOut() method starts motion fast +* and then decelerates motion to a zero velocity as it executes. * * @param t Specifies the current time, between 0 and duration inclusive. * @param b Specifies the initial value of the animation property. * @param c Specifies the total change in the animation property. * @param d Specifies the duration of the motion. -* @return The value of the interpolated property at the specified time. -*/ -eeFloat ExponentialOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +* @return The value of the interpolated property at the specified time. +*/ +eeFloat EE_API ExponentialOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); /** * The ExponentialInOut() method combines the motion * of the ExponentialIn() and ExponentialOut() methods -* to start the motion from a zero velocity, accelerate motion, -* then decelerate to a zero velocity. +* to start the motion from a zero velocity, accelerate motion, +* then decelerate to a zero velocity. * * @param t Specifies the current time, between 0 and duration inclusive. * @param b Specifies the initial value of the animation property. * @param c Specifies the total change in the animation property. * @param d Specifies the duration of the motion. -* @return The value of the interpolated property at the specified time. -*/ -eeFloat ExponentialInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +* @return The value of the interpolated property at the specified time. +*/ +eeFloat EE_API ExponentialInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat QuarticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API QuarticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat QuarticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API QuarticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat QuarticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API QuarticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat QuinticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API QuinticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat QuinticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API QuinticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat QuinticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API QuinticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat CircularIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API CircularIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat CircularOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API CircularOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat CircularInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API CircularInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat CubicIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API CubicIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat CubicOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API CubicOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat CubicInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API CubicInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat BackIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API BackIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat BackOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API BackOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat BackInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API BackInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat BounceIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API BounceIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat BounceOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API BounceOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat BounceInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API BounceInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat ElasticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API ElasticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat ElasticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API ElasticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); -eeFloat ElasticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); +eeFloat EE_API ElasticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ); }}} diff --git a/src/utils/string.hpp b/src/utils/string.hpp index 046c2277e..d56d4361f 100755 --- a/src/utils/string.hpp +++ b/src/utils/string.hpp @@ -119,9 +119,9 @@ void EE_API StrCopy( char * Dst, const char * Src, eeUint DstSize ); * @param Str String to compare * @return The position of the last char compared ( -1 if fails ) */ -Int32 StrStartsWith( const std::string& Start, const std::string Str ); +Int32 EE_API StrStartsWith( const std::string& Start, const std::string Str ); -Int32 StrStartsWith( const std::wstring& Start, const std::wstring Str ); +Int32 EE_API StrStartsWith( const std::wstring& Start, const std::wstring Str ); }} diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 79a1e1fb9..47e880245 100755 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -309,8 +309,8 @@ bool FileGet( const std::string& path, std::vector& data ) { bool FileCopy( const std::string& src, const std::string& dst ) { if ( FileExists( src ) ) { - ifstream in( src.c_str() ); - ofstream out( dst.c_str() ); + std::ifstream in( src.c_str() ); + std::ofstream out( dst.c_str() ); if ( in.is_open() && out.is_open() ) { out << in.rdbuf(); @@ -408,4 +408,26 @@ Uint32 FileGetModificationDate( const std::string& Filepath ) { return 0; } + +std::string SaveTypeToExtension( const Uint32& Format ) { + switch( Format ) { // I dont use the save types to avoid including something from EE::Graphics + case 0: return "tga"; // EE_SAVE_TYPE_TGA + case 1: return "bmp"; // EE_SAVE_TYPE_BMP + case 2: return "png"; // EE_SAVE_TYPE_PNG + case 3: return "dds"; // EE_SAVE_TYPE_DDS + } + + return ""; +} + +void DirPathAddSlashAtEnd( std::string& path ) { + if ( path[ path.size() - 1 ] != '/' && path[ path.size() - 1 ] != '\\' ) { + #if EE_PLATFORM == EE_PLATFORM_WIN32 + path += '\\'; + #else + path += '/'; + #endif + } +} + }} diff --git a/src/utils/utils.hpp b/src/utils/utils.hpp index 56279e178..4472ec596 100755 --- a/src/utils/utils.hpp +++ b/src/utils/utils.hpp @@ -48,41 +48,47 @@ namespace EE { namespace Utils { * @param data The vector to allocate the file in memory * @return True if returned the file to the vector. */ - bool FileGet( const std::string& path, std::vector& data ); + bool EE_API FileGet( const std::string& path, std::vector& data ); /** Copy a file to location. * @param src Source File Path * @param dst Destination File Path * @return If success. */ - bool FileCopy( const std::string& src, const std::string& dst ); + bool EE_API FileCopy( const std::string& src, const std::string& dst ); /** @return The file extension * @param filepath The file path or name * @param lowerExt Lowercase the extension obtained? ( true by default ) */ - std::string FileExtension( const std::string& filepath, const bool& lowerExt = true ); + std::string EE_API FileExtension( const std::string& filepath, const bool& lowerExt = true ); /** @return The file name of a file path */ - std::string FileNameFromPath( const std::string& filepath ); + std::string EE_API FileNameFromPath( const std::string& filepath ); /** @return Removes the file name from a path, and return the path. */ - std::string FileRemoveFileName( const std::string& filepath ); + std::string EE_API FileRemoveFileName( const std::string& filepath ); /** @return Removes the extension of a filepath */ - std::string FileRemoveExtension( const std::string& filepath ); + std::string EE_API FileRemoveExtension( const std::string& filepath ); /** Write a file in binary mode and close it. */ - bool FileWrite( const std::string& filepath, const Uint8* data, const Uint32& dataSize ); + bool EE_API FileWrite( const std::string& filepath, const Uint8* data, const Uint32& dataSize ); /** Write a file in binary mode and close it. */ - bool FileWrite( const std::string& filepath, const std::vector& data ); + bool EE_API FileWrite( const std::string& filepath, const std::vector& data ); /** @return The Number of CPUs of the system. */ - eeInt GetNumCPUs(); + eeInt EE_API GetNumCPUs(); /** @return The modification date of the file */ - Uint32 FileGetModificationDate( const std::string& Filepath ); + Uint32 EE_API FileGetModificationDate( const std::string& Filepath ); + + /** @return The File Extension of a Save Type */ + std::string EE_API SaveTypeToExtension( const Uint32& Format ); + + /** If the directory path not end with a slash, it will add it. */ + void DirPathAddSlashAtEnd( std::string& path ); } } diff --git a/src/window/cengine.hpp b/src/window/cengine.hpp index 7f8014a55..c93c8fc0d 100755 --- a/src/window/cengine.hpp +++ b/src/window/cengine.hpp @@ -21,8 +21,8 @@ inline BOOL WIN_ShowWindow( HWND hWnd, int nCmdShow ) { #endif /** @brief The basic Graphics class. Here Init the context and render to screen. (Singleton Class). */ -class EE_API cEngine : public cSingleton { - friend class cSingleton; +class EE_API cEngine : public tSingleton { + friend class tSingleton; public: /** Init the opengl context and the screen * @param Width Screen Width diff --git a/src/window/cinput.hpp b/src/window/cinput.hpp index b490d6600..90ffd3cfb 100755 --- a/src/window/cinput.hpp +++ b/src/window/cinput.hpp @@ -291,8 +291,8 @@ enum EE_KEY { }; /** @brief The basic input class. For mouse and keyboard. */ -class EE_API cInput : public cSingleton { - friend class cSingleton; +class EE_API cInput : public tSingleton { + friend class tSingleton; public: typedef boost::function1 InputCallback; typedef boost::function0 VideoResizeCallback; diff --git a/src/window/cjoystickmanager.hpp b/src/window/cjoystickmanager.hpp index 79e2e18bc..16d172d65 100644 --- a/src/window/cjoystickmanager.hpp +++ b/src/window/cjoystickmanager.hpp @@ -8,8 +8,8 @@ namespace EE { namespace Window { #define MAX_JOYSTICKS (16) -class EE_API cJoystickManager : public cSingleton { - friend class cSingleton; +class EE_API cJoystickManager : public tSingleton { + friend class tSingleton; friend class cJoystick; public: cJoystickManager(); diff --git a/src/window/cview.hpp b/src/window/cview.hpp index 7436b89e6..ab442b0d2 100755 --- a/src/window/cview.hpp +++ b/src/window/cview.hpp @@ -6,7 +6,7 @@ namespace EE { namespace Window { /** @brief The class defines a view like a 2D camera ( position, size, move, scale ). \nBasically is a 2D proyection in pixels seted over a viewport. */ -class cView { +class EE_API cView { public: cView(); cView( const eeInt& X, const eeInt& Y, const eeInt& Width, const eeInt& Height );