From 89bb55df44b16b4d5342440eac7ee86167c9ef6f Mon Sep 17 00:00:00 2001 From: spartanj Date: Thu, 9 Sep 2010 16:44:31 -0300 Subject: [PATCH] Restore on context lost vertex buffers and frame buffers. Fixed some compiler warnings. --- ee.linux.cbp | 5 +++ src/graphics/base.hpp | 1 + src/graphics/cframebuffer.cpp | 10 ++++- src/graphics/cframebuffer.hpp | 3 ++ src/graphics/cframebufferfbo.cpp | 23 ++++++---- src/graphics/cframebufferfbo.hpp | 2 + src/graphics/cframebuffermanager.cpp | 20 +++++++++ src/graphics/cframebuffermanager.hpp | 22 +++++++++ src/graphics/cframebufferpbuffer.cpp | 22 ++++++--- src/graphics/cframebufferpbuffer.hpp | 2 + src/graphics/cshaderprogram.cpp | 20 ++++++--- src/graphics/cshaderprogram.hpp | 9 +++- src/graphics/cvertexbuffer.cpp | 29 +++++++----- src/graphics/cvertexbuffer.hpp | 2 + src/graphics/cvertexbuffermanager.cpp | 20 +++++++++ src/graphics/cvertexbuffermanager.hpp | 22 +++++++++ src/graphics/cvertexbufferogl.cpp | 3 ++ src/graphics/cvertexbufferogl.hpp | 2 + src/graphics/cvertexbuffervbo.cpp | 5 +++ src/graphics/cvertexbuffervbo.hpp | 2 + src/helper/libzip/config.h | 13 +++--- src/helper/libzip/mkstemp.c | 9 ++++ src/system/tcontainer.hpp | 65 +++++++++++++++++++++++++++ src/system/tresourcemanager.hpp | 2 - src/utils/cinterpolation.cpp | 6 +-- src/window/cengine.cpp | 12 ++++- 26 files changed, 281 insertions(+), 50 deletions(-) create mode 100644 src/graphics/cframebuffermanager.cpp create mode 100644 src/graphics/cframebuffermanager.hpp create mode 100644 src/graphics/cvertexbuffermanager.cpp create mode 100644 src/graphics/cvertexbuffermanager.hpp create mode 100644 src/system/tcontainer.hpp diff --git a/ee.linux.cbp b/ee.linux.cbp index 091030f79..8dcceac53 100644 --- a/ee.linux.cbp +++ b/ee.linux.cbp @@ -91,6 +91,8 @@ + + @@ -147,6 +149,8 @@ + + @@ -489,6 +493,7 @@ + diff --git a/src/graphics/base.hpp b/src/graphics/base.hpp index c58f4aa3f..1f6f5c3c5 100644 --- a/src/graphics/base.hpp +++ b/src/graphics/base.hpp @@ -24,6 +24,7 @@ using namespace EE::Math; #include "../system/clog.hpp" #include "../system/cpack.hpp" #include "../system/tresourcemanager.hpp" +#include "../system/tcontainer.hpp" using namespace EE::System; #include "renders.hpp" diff --git a/src/graphics/cframebuffer.cpp b/src/graphics/cframebuffer.cpp index 9c3a517be..7a491ceb2 100644 --- a/src/graphics/cframebuffer.cpp +++ b/src/graphics/cframebuffer.cpp @@ -3,6 +3,9 @@ #include "../window/cengine.hpp" #include "cframebufferfbo.hpp" #include "cframebufferpbuffer.hpp" +#include "cframebuffermanager.hpp" + +using namespace EE::Graphics::Private; namespace EE { namespace Graphics { @@ -19,13 +22,18 @@ cFrameBuffer * cFrameBuffer::CreateNew( const Uint32& Width, const Uint32& Heigh cFrameBuffer::cFrameBuffer() : mWidth(0), mHeight(0), + mHasDepthBuffer(false), mTexture(NULL), mClearColor(0,0,0,0) -{} +{ + cFrameBufferManager::instance()->Add( this ); +} cFrameBuffer::~cFrameBuffer() { if ( NULL != mTexture ) cTextureFactory::instance()->Remove( mTexture->Id() ); + + cFrameBufferManager::instance()->Remove( this ); } cTexture * cFrameBuffer::GetTexture() const { diff --git a/src/graphics/cframebuffer.hpp b/src/graphics/cframebuffer.hpp index 6940c132d..adc77ab78 100644 --- a/src/graphics/cframebuffer.hpp +++ b/src/graphics/cframebuffer.hpp @@ -23,6 +23,8 @@ class EE_API cFrameBuffer { virtual void Unbind() = 0; + virtual void Reload() = 0; + cTexture * GetTexture() const; void ClearColor( eeColorAf Color ); @@ -31,6 +33,7 @@ class EE_API cFrameBuffer { protected: Int32 mWidth; Int32 mHeight; + bool mHasDepthBuffer; cTexture * mTexture; eeColorAf mClearColor; cView mPrevView; diff --git a/src/graphics/cframebufferfbo.cpp b/src/graphics/cframebufferfbo.cpp index ececfa1f4..a71d1666e 100644 --- a/src/graphics/cframebufferfbo.cpp +++ b/src/graphics/cframebufferfbo.cpp @@ -54,6 +54,10 @@ bool cFrameBufferFBO::Create( const Uint32& Width, const Uint32& Height, bool De if ( !IsSupported() ) return false; + mWidth = Width; + mHeight = Height; + mHasDepthBuffer = DepthBuffer; + GLuint frameBuffer = 0; glGenFramebuffersEXT( 1, &frameBuffer ); @@ -82,12 +86,14 @@ bool cFrameBufferFBO::Create( const Uint32& Width, const Uint32& Height, bool De glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepthBuffer ); } - Uint32 TexId = cTextureFactory::instance()->CreateEmptyTexture( Width, Height, eeColorA(0,0,0,0) ); + if ( NULL == mTexture ) { + Uint32 TexId = cTextureFactory::instance()->CreateEmptyTexture( Width, Height, eeColorA(0,0,0,0) ); - if ( cTextureFactory::instance()->TextureIdExists( TexId ) ) { - mTexture = cTextureFactory::instance()->GetTexture( TexId ); - } else { - return false; + if ( cTextureFactory::instance()->TextureIdExists( TexId ) ) { + mTexture = cTextureFactory::instance()->GetTexture( TexId ); + } else { + return false; + } } glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, mTexture->Handle(), 0 ); @@ -100,9 +106,6 @@ bool cFrameBufferFBO::Create( const Uint32& Width, const Uint32& Height, bool De glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); - mWidth = Width; - mHeight = Height; - return true; } @@ -120,4 +123,8 @@ void cFrameBufferFBO::Unbind() { } } +void cFrameBufferFBO::Reload() { + Create( mWidth, mHeight, mHasDepthBuffer ); +} + }} diff --git a/src/graphics/cframebufferfbo.hpp b/src/graphics/cframebufferfbo.hpp index c896c14b7..83b6d7d6f 100644 --- a/src/graphics/cframebufferfbo.hpp +++ b/src/graphics/cframebufferfbo.hpp @@ -23,6 +23,8 @@ class EE_API cFrameBufferFBO : public cFrameBuffer { void Unbind(); + void Reload(); + static bool IsSupported(); protected: Int32 mFrameBuffer; diff --git a/src/graphics/cframebuffermanager.cpp b/src/graphics/cframebuffermanager.cpp new file mode 100644 index 000000000..e7e700f28 --- /dev/null +++ b/src/graphics/cframebuffermanager.cpp @@ -0,0 +1,20 @@ +#include "cframebuffermanager.hpp" + +namespace EE { namespace Graphics { namespace Private { + +cFrameBufferManager::cFrameBufferManager() +{ +} + +cFrameBufferManager::~cFrameBufferManager() +{ +} + +void cFrameBufferManager::Reload() { + std::list::iterator it; + + for ( it = mResources.begin(); it != mResources.end(); it++ ) + (*it)->Reload(); +} + +}}} diff --git a/src/graphics/cframebuffermanager.hpp b/src/graphics/cframebuffermanager.hpp new file mode 100644 index 000000000..855df10ca --- /dev/null +++ b/src/graphics/cframebuffermanager.hpp @@ -0,0 +1,22 @@ +#ifndef EE_GRAPHICSCFRAMEBUFFERMANAGER_HPP +#define EE_GRAPHICSCFRAMEBUFFERMANAGER_HPP + +#include "base.hpp" +#include "cframebuffer.hpp" + +namespace EE { namespace Graphics { namespace Private { + +class EE_API cFrameBufferManager : public tContainer, public tSingleton { + friend class tSingleton; + public: + cFrameBufferManager(); + + virtual ~cFrameBufferManager(); + + void Reload(); + protected: +}; + +}}} + +#endif diff --git a/src/graphics/cframebufferpbuffer.cpp b/src/graphics/cframebufferpbuffer.cpp index 58161a4e9..db68913f7 100644 --- a/src/graphics/cframebufferpbuffer.cpp +++ b/src/graphics/cframebufferpbuffer.cpp @@ -83,8 +83,9 @@ bool cFrameBufferPBuffer::Create( const Uint32& Width, const Uint32& Height, boo if ( !IsSupported() ) return false; - mWidth = Width; - mHeight = Height; + mWidth = Width; + mHeight = Height; + mHasDepthBuffer = DepthBuffer; #if EE_PLATFORM == EE_PLATFORM_WIN32 HDC currentDC = wglGetCurrentDC(); @@ -193,12 +194,14 @@ bool cFrameBufferPBuffer::Create( const Uint32& Width, const Uint32& Height, boo XFree(visual); #endif - Uint32 TexId = cTextureFactory::instance()->CreateEmptyTexture( Width, Height, eeColorA(0,0,0,0) ); + if ( NULL == mTexture ) { + Uint32 TexId = cTextureFactory::instance()->CreateEmptyTexture( Width, Height, eeColorA(0,0,0,0) ); - if ( cTextureFactory::instance()->TextureIdExists( TexId ) ) { - mTexture = cTextureFactory::instance()->GetTexture( TexId ); - } else { - return false; + if ( cTextureFactory::instance()->TextureIdExists( TexId ) ) { + mTexture = cTextureFactory::instance()->GetTexture( TexId ); + } else { + return false; + } } return true; @@ -242,4 +245,9 @@ void cFrameBufferPBuffer::Unbind() { RecoverView(); } + +void cFrameBufferPBuffer::Reload() { + Create( mWidth, mHeight, mHasDepthBuffer ); +} + }} diff --git a/src/graphics/cframebufferpbuffer.hpp b/src/graphics/cframebufferpbuffer.hpp index 8ffcb1179..821ebdada 100644 --- a/src/graphics/cframebufferpbuffer.hpp +++ b/src/graphics/cframebufferpbuffer.hpp @@ -59,6 +59,8 @@ class EE_API cFrameBufferPBuffer : public cFrameBuffer { void Unbind(); + void Reload(); + static bool IsSupported(); protected: #if EE_PLATFORM == EE_PLATFORM_WIN32 diff --git a/src/graphics/cshaderprogram.cpp b/src/graphics/cshaderprogram.cpp index a25d74d67..d80d7b89f 100644 --- a/src/graphics/cshaderprogram.cpp +++ b/src/graphics/cshaderprogram.cpp @@ -7,14 +7,16 @@ using namespace EE::Graphics::Private; namespace EE { namespace Graphics { cShaderProgram::cShaderProgram( const std::string& name ) : - mGLId(0) + mHandler(0), + mId(0) { AddToManager( name ); Init(); } cShaderProgram::cShaderProgram( const std::vector& Shaders, const std::string& name ) : - mGLId(0) + mHandler(0), + mId(0) { AddToManager( name ); Init(); @@ -25,7 +27,8 @@ cShaderProgram::cShaderProgram( const std::vector& Shaders, const std: } cShaderProgram::cShaderProgram( const std::string& VertexShaderFile, const std::string& FragmentShaderFile, const std::string& name ) : - mGLId(0) + mHandler(0), + mId(0) { AddToManager( name ); Init(); @@ -46,7 +49,8 @@ cShaderProgram::cShaderProgram( const std::string& VertexShaderFile, const std:: } cShaderProgram::cShaderProgram( cPack * Pack, const std::string& VertexShaderPath, const std::string& FragmentShaderPath, const std::string& name ) : - mGLId(0) + mHandler(0), + mId(0) { AddToManager( name ); Init(); @@ -69,7 +73,8 @@ cShaderProgram::cShaderProgram( cPack * Pack, const std::string& VertexShaderPat } cShaderProgram::cShaderProgram( const Uint8 * VertexShaderData, const Uint32& VertexShaderDataSize, const Uint8 * FragmentShaderData, const Uint32& FragmentShaderDataSize, const std::string& name ) : - mGLId(0) + mHandler(0), + mId(0) { AddToManager( name ); Init(); @@ -112,7 +117,7 @@ void cShaderProgram::RemoveFromManager() { void cShaderProgram::Init() { if ( cGL::instance()->ShadersSupported() && 0 == Id() ) { - mGLId = glCreateProgram(); + mHandler = glCreateProgram(); mValid = false; mUniformLocations.clear(); mAttributeLocations.clear(); @@ -120,7 +125,7 @@ void cShaderProgram::Init() { } void cShaderProgram::Reload() { - mGLId = 0; + mHandler = 0; Init(); @@ -256,6 +261,7 @@ const std::string& cShaderProgram::Name() const { void cShaderProgram::Name( const std::string& name ) { mName = name; + mId = MakeHash( mName ); Uint32 NameCount = cShaderProgramManager::instance()->Exists( mName ); diff --git a/src/graphics/cshaderprogram.hpp b/src/graphics/cshaderprogram.hpp index 9fbdb2e3d..3af2478e0 100644 --- a/src/graphics/cshaderprogram.hpp +++ b/src/graphics/cshaderprogram.hpp @@ -73,7 +73,10 @@ class EE_API cShaderProgram { bool SetUniform( const std::string& Name, Int32 Value ); /** @return The id of the program (the handle) */ - const Uint32& Id() const { return mGLId; } + const Uint32& Handler() const { return mHandler; } + + /** @return The Id of the program ( hash of the program name ) */ + const Uint32& Id() const { return mId; } /** Reloads the shaders */ void Reload(); @@ -85,7 +88,9 @@ class EE_API cShaderProgram { void Name( const std::string& name ); protected: std::string mName; - Uint32 mGLId; + Uint32 mHandler; + Uint32 mId; + bool mValid; std::string mLinkLog; diff --git a/src/graphics/cvertexbuffer.cpp b/src/graphics/cvertexbuffer.cpp index d29930be5..cc8a5099e 100644 --- a/src/graphics/cvertexbuffer.cpp +++ b/src/graphics/cvertexbuffer.cpp @@ -2,6 +2,7 @@ #include "cvertexbufferogl.hpp" #include "cvertexbuffervbo.hpp" #include "glhelper.hpp" +#include "cvertexbuffermanager.hpp" using namespace EE::Graphics::Private; @@ -20,24 +21,28 @@ cVertexBuffer::cVertexBuffer( const Uint32& VertexFlags, EE_DRAW_MODE DrawType, mUsageType( UsageType ), mElemDraw(-1) { - if( ReserveVertexSize > 0 ) { - for( Int32 i = 0; i < VERTEX_FLAGS_COUNT; i++ ) { - if( VERTEX_FLAG_QUERY( mVertexFlags, i ) ) { - if ( i != VERTEX_FLAG_COLOR ) - mVertexArray[ i ].reserve( ReserveVertexSize * eeVertexElements[ i ] ); - else - mColorArray.reserve( ReserveVertexSize * eeVertexElements[ i ] ); - } + if( ReserveVertexSize > 0 ) { + for( Int32 i = 0; i < VERTEX_FLAGS_COUNT; i++ ) { + if( VERTEX_FLAG_QUERY( mVertexFlags, i ) ) { + if ( i != VERTEX_FLAG_COLOR ) + mVertexArray[ i ].reserve( ReserveVertexSize * eeVertexElements[ i ] ); + else + mColorArray.reserve( ReserveVertexSize * eeVertexElements[ i ] ); } } + } + + cVertexBufferManager::instance()->Add( this ); } cVertexBuffer::~cVertexBuffer() { - for( Int32 i = 0; i < VERTEX_FLAGS_COUNT_ARR; i++ ) - mVertexArray[ i ].clear(); + for( Int32 i = 0; i < VERTEX_FLAGS_COUNT_ARR; i++ ) + mVertexArray[ i ].clear(); - mColorArray.clear(); - mIndexArray.clear(); + mColorArray.clear(); + mIndexArray.clear(); + + cVertexBufferManager::instance()->Remove( this ); } void cVertexBuffer::AddVertex( const Uint32& Type, const eeVector2f& Vertex ) { diff --git a/src/graphics/cvertexbuffer.hpp b/src/graphics/cvertexbuffer.hpp index c7b7bb658..b8f51896f 100644 --- a/src/graphics/cvertexbuffer.hpp +++ b/src/graphics/cvertexbuffer.hpp @@ -57,6 +57,8 @@ class cVertexBuffer { virtual bool Compile() = 0; virtual void Update( const Uint32& Types, bool Indices ) = 0; + + virtual void Reload() = 0; protected: Uint32 mVertexFlags; EE_DRAW_MODE mDrawType; diff --git a/src/graphics/cvertexbuffermanager.cpp b/src/graphics/cvertexbuffermanager.cpp new file mode 100644 index 000000000..0be789d2f --- /dev/null +++ b/src/graphics/cvertexbuffermanager.cpp @@ -0,0 +1,20 @@ +#include "cvertexbuffermanager.hpp" + +namespace EE { namespace Graphics { namespace Private { + +cVertexBufferManager::cVertexBufferManager() +{ +} + +cVertexBufferManager::~cVertexBufferManager() +{ +} + +void cVertexBufferManager::Reload() { + std::list::iterator it; + + for ( it = mResources.begin(); it != mResources.end(); it++ ) + (*it)->Reload(); +} + +}}} diff --git a/src/graphics/cvertexbuffermanager.hpp b/src/graphics/cvertexbuffermanager.hpp new file mode 100644 index 000000000..e663eabe5 --- /dev/null +++ b/src/graphics/cvertexbuffermanager.hpp @@ -0,0 +1,22 @@ +#ifndef EE_GRAPHICSCVERTEXBUFFERMANAGER_HPP +#define EE_GRAPHICSCVERTEXBUFFERMANAGER_HPP + +#include "base.hpp" +#include "cvertexbuffer.hpp" + +namespace EE { namespace Graphics { namespace Private { + +class EE_API cVertexBufferManager : public tContainer, public tSingleton { + friend class tSingleton; + public: + cVertexBufferManager(); + + virtual ~cVertexBufferManager(); + + void Reload(); + protected: +}; + +}}} + +#endif diff --git a/src/graphics/cvertexbufferogl.cpp b/src/graphics/cvertexbufferogl.cpp index 7f0bf0f2d..9b13999b6 100644 --- a/src/graphics/cvertexbufferogl.cpp +++ b/src/graphics/cvertexbufferogl.cpp @@ -81,4 +81,7 @@ void cVertexBufferOGL::SetVertexStates() { void cVertexBufferOGL::Update( const Uint32& Types, bool Indices ) { } +void cVertexBufferOGL::Reload() { +} + }} diff --git a/src/graphics/cvertexbufferogl.hpp b/src/graphics/cvertexbufferogl.hpp index 67c5c2633..7956ef125 100644 --- a/src/graphics/cvertexbufferogl.hpp +++ b/src/graphics/cvertexbufferogl.hpp @@ -18,6 +18,8 @@ class cVertexBufferOGL : public cVertexBuffer { bool Compile(); void Update( const Uint32& Types, bool Indices ); + + void Reload(); protected: void SetVertexStates(); diff --git a/src/graphics/cvertexbuffervbo.cpp b/src/graphics/cvertexbuffervbo.cpp index 111c1f57e..92b610cc9 100644 --- a/src/graphics/cvertexbuffervbo.cpp +++ b/src/graphics/cvertexbuffervbo.cpp @@ -177,4 +177,9 @@ void cVertexBufferVBO::Update( const Uint32& Types, bool Indices ) { } } +void cVertexBufferVBO::Reload() { + mCompiled = false; + Compile(); +} + }} diff --git a/src/graphics/cvertexbuffervbo.hpp b/src/graphics/cvertexbuffervbo.hpp index 1c452a104..6a5a7bfe0 100644 --- a/src/graphics/cvertexbuffervbo.hpp +++ b/src/graphics/cvertexbuffervbo.hpp @@ -18,6 +18,8 @@ class cVertexBufferVBO : public cVertexBuffer { bool Compile(); void Update( const Uint32& Types, bool Indices ); + + void Reload(); protected: void SetVertexStates(); diff --git a/src/helper/libzip/config.h b/src/helper/libzip/config.h index a43ef7486..f464c268e 100644 --- a/src/helper/libzip/config.h +++ b/src/helper/libzip/config.h @@ -2,17 +2,18 @@ #define HAD_CONFIG_H #if !defined( __WIN32__ ) && !defined( _WIN32 ) - -#define HAVE_FSEEKO -#define HAVE_FTELLO -#define HAVE_UNISTD_H - -#if (!defined (_MSCVER) && !defined (_MSC_VER)) + #define HAVE_MKSTEMP +#define HAVE_FSEEKO +#define HAVE_FTELLO + #endif +#if (!defined (_MSCVER) && !defined (_MSC_VER)) +#define HAVE_UNISTD_H #endif + #define PACKAGE "libzip" #define VERSION "0.9.3a" #endif /* HAD_CONFIG_H */ diff --git a/src/helper/libzip/mkstemp.c b/src/helper/libzip/mkstemp.c index 17da04230..e9cc120222 100644 --- a/src/helper/libzip/mkstemp.c +++ b/src/helper/libzip/mkstemp.c @@ -55,6 +55,11 @@ typedef int pid_t; #if !defined( __WIN32__ ) && !defined( _WIN32 ) #include #endif + +#if defined( _WIN32 ) +#include +#include +#endif @@ -72,7 +77,11 @@ _zip_mkstemp(char *path) static char xtra[2] = "aa"; int xcnt = 0; + #if ( defined (_MSCVER) || defined (_MSC_VER) ) + pid = _getpid(); + #else pid = getpid(); + #endif /* Move to end of path and count trailing X's. */ for (trv = path; *trv; ++trv) diff --git a/src/system/tcontainer.hpp b/src/system/tcontainer.hpp new file mode 100644 index 000000000..f2031b691 --- /dev/null +++ b/src/system/tcontainer.hpp @@ -0,0 +1,65 @@ +#ifndef EE_SYSTEMTCONTAINER_HPP +#define EE_SYSTEMTCONTAINER_HPP + +#include "base.hpp" + +namespace EE { namespace System { + +template +class tContainer { + public: + tContainer(); + + virtual ~tContainer(); + + T * Add( T * Resource ); + + bool Remove( T * Resource ); + + Uint32 Count(); + protected: + std::list mResources; +}; + +template +tContainer::tContainer() +{ +} + +template +tContainer::~tContainer() +{ +} + +template +T * tContainer::Add( T * Resource ) { + if ( NULL != Resource ) { + mResources.push_back( Resource ); + + return Resource; + } + + return NULL; +} + +template +bool tContainer::Remove( T * Resource ) { + if ( NULL != Resource ) { + mResources.remove( Resource ); + + return true; + } + + return false; +} + +template +Uint32 tContainer::Count() { + return mResources.size(); +} + +}} + +#endif + + diff --git a/src/system/tresourcemanager.hpp b/src/system/tresourcemanager.hpp index 4fff4b961..ded7f0ec6 100644 --- a/src/system/tresourcemanager.hpp +++ b/src/system/tresourcemanager.hpp @@ -30,8 +30,6 @@ class tResourceManager { Uint32 Count( const Uint32& Id ); - void Reload(); - Uint32 Exists( const std::string& Name ); Uint32 Exists( const Uint32& Id ); diff --git a/src/utils/cinterpolation.cpp b/src/utils/cinterpolation.cpp index c4af9ccd5..195175b9d 100644 --- a/src/utils/cinterpolation.cpp +++ b/src/utils/cinterpolation.cpp @@ -79,10 +79,10 @@ bool cInterpolation::EditWaypoint( const eeUint PointNum, const eeFloat NewPos, if ( 0 == PointNum ) { if ( PointNum + (eeUint)1 < mPoints.size() ) - mTotDist += abs( mPoints[ PointNum ].p - mPoints[ PointNum + 1 ].p ); + mTotDist += std::abs( mPoints[ PointNum ].p - mPoints[ PointNum + 1 ].p ); } else - mTotDist += abs( mPoints[ PointNum ].p - mPoints[ PointNum - 1 ].p ); + mTotDist += std::abs( mPoints[ PointNum ].p - mPoints[ PointNum - 1 ].p ); return true; } @@ -170,7 +170,7 @@ void cInterpolation::SetTotalTime( const eeFloat TotTime ) { if ( mLoop ) { tdist += fabs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ); - mPoints[ mPoints.size() - 1 ].t = abs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ) * TotTime / tdist; + mPoints[ mPoints.size() - 1 ].t = std::abs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ) * TotTime / tdist; } for ( eeUint i = 0; i < mPoints.size() - 1; i++) { diff --git a/src/window/cengine.cpp b/src/window/cengine.cpp index 841c20702..552913ead 100755 --- a/src/window/cengine.cpp +++ b/src/window/cengine.cpp @@ -6,6 +6,8 @@ #include "../graphics/cglobalbatchrenderer.hpp" #include "../graphics/cshaderprogrammanager.hpp" #include "../graphics/cshapegroupmanager.hpp" +#include "../graphics/cvertexbuffermanager.hpp" +#include "../graphics/cframebuffermanager.hpp" #include "../ui/cuimanager.hpp" #include "../audio/caudiolistener.hpp" #include "../graphics/glhelper.hpp" @@ -89,6 +91,10 @@ cEngine::~cEngine() { if ( NULL != mCursor ) SDL_FreeCursor(mCursor); + cFrameBufferManager::DestroySingleton(); + + cVertexBufferManager::DestroySingleton(); + cGlobalBatchRenderer::DestroySingleton(); cTextureFactory::DestroySingleton(); @@ -371,8 +377,10 @@ void cEngine::ChangeRes( const Uint16& width, const Uint16& height, const bool& #if EE_PLATFORM == EE_PLATFORM_WIN32 || EE_PLATFORM == EE_PLATFORM_MACOSX if ( Reload ) { - cTextureFactory::instance()->UngrabTextures(); // Reload all textures - cShaderProgramManager::instance()->Reload(); // Reload all shaders + cTextureFactory::instance()->UngrabTextures(); // Reload all textures + cShaderProgramManager::instance()->Reload(); // Reload all shaders + cFrameBufferManager::instance()->Reload(); // Reload all frame buffers + cVertexBufferManager::instance()->Reload(); // Reload all vertex buffers GetMainContext(); // Recover the context } #endif