diff --git a/include/eepp/graphics/ctextureloader.hpp b/include/eepp/graphics/ctextureloader.hpp index eca594f96..48f2b3d40 100644 --- a/include/eepp/graphics/ctextureloader.hpp +++ b/include/eepp/graphics/ctextureloader.hpp @@ -19,7 +19,6 @@ class EE_API cTextureLoader : public cObjectLoader { * @param ClampMode Defines the CLAMP MODE * @param CompressTexture If use the DXT compression on the texture loading ( if the card can display them, will convert RGB to DXT1, RGBA to DXT5 ) * @param KeepLocalCopy Keep the array data copy. ( useful if want to reload the texture ) - * @return The internal Texture Id */ cTextureLoader( cIOStream& Stream, const bool& Mipmap = false, const EE_CLAMP_MODE& ClampMode = CLAMP_TO_EDGE, const bool& CompressTexture = false, const bool& KeepLocalCopy = false ); @@ -85,6 +84,14 @@ class EE_API cTextureLoader : public cObjectLoader { /** @return The texture instance ( if it was loaded ). */ cTexture * GetTexture() const; + + /** In the case that the image loading is made outside the GL context main thread, + ** you'll need to force the use of the GL Shared Context + ** @see cWindow::IsThreadedGLContext */ + void ForceUseGLSharedContext( bool force ); + + /** @return If the use of a gl shared context to load the texture is being forced */ + const bool& ForceUseGLSharedContext() const; protected: Uint32 mLoadType; // From memory, from path, from pack Uint8 * mPixels; // Texture Info @@ -100,6 +107,7 @@ class EE_API cTextureLoader : public cObjectLoader { EE_CLAMP_MODE mClampMode; bool mCompressTexture; bool mLocalCopy; + bool mForceGLThreaded; cPack * mPack; cIOStream * mStream; diff --git a/include/eepp/window/cengine.hpp b/include/eepp/window/cengine.hpp index 341ac03e9..7eedd5f4d 100755 --- a/include/eepp/window/cengine.hpp +++ b/include/eepp/window/cengine.hpp @@ -128,7 +128,6 @@ class EE_API cEngine { Backend::cBackend * mBackend; std::list mWindows; cWindow * mWindow; - cMutex mGLThreadMutex; bool mSharedGLContext; cEngine(); diff --git a/include/eepp/window/cwindow.hpp b/include/eepp/window/cwindow.hpp index 4cb109a91..60711c6c1 100644 --- a/include/eepp/window/cwindow.hpp +++ b/include/eepp/window/cwindow.hpp @@ -512,10 +512,6 @@ class EE_API cWindow { void LogSuccessfulInit( const std::string& BackendName, const std::string& ProcessPath = "" ); void LogFailureInit( const std::string& ClassName, const std::string& BackendName ); - - void GLThreadMutexLock(); - - void GLThreadMutexUnlock(); }; }} diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 53d6b38e1..e38ec8a70 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -682,6 +682,15 @@ /home/programming/eepp/make/linux + true + --with-static-backend gmake + premake4 + %{buildDir}../../../ + Custom Process Step + + ProjectExplorer.ProcessStep + + false -j4 eepp-ew @@ -691,7 +700,7 @@ Clone of GenericProjectManager.GenericMakeStep - 1 + 2 Build Clone of Build ProjectExplorer.BuildSteps.Build diff --git a/src/eepp/graphics/cconsole.cpp b/src/eepp/graphics/cconsole.cpp index 56b6a5f64..5dd2dfdce 100755 --- a/src/eepp/graphics/cconsole.cpp +++ b/src/eepp/graphics/cconsole.cpp @@ -208,14 +208,14 @@ void cConsole::Draw() { mFont->Color( eeColorA ( mFontLineColor.R(), mFontLineColor.G(), mFontLineColor.B(), static_cast(mCurAlpha) ) ); - mFont->Color( OldColor ); - if ( (eeUint)mTBuf->CurPos() == mTBuf->Buffer().size() ) { mFont->Draw( "_", mFontSize + mFont->GetTextWidth() , CurY ); } else { mFont->SetText( "> " + mTBuf->Buffer().substr( 0, mTBuf->CurPos() ) ); mFont->Draw( "_", mFontSize + mFont->GetTextWidth() , CurY ); } + + mFont->Color( OldColor ); } } diff --git a/src/eepp/graphics/ctextureloader.cpp b/src/eepp/graphics/ctextureloader.cpp index 2378a329c..fcbdc070b 100644 --- a/src/eepp/graphics/ctextureloader.cpp +++ b/src/eepp/graphics/ctextureloader.cpp @@ -76,6 +76,7 @@ cTextureLoader::cTextureLoader( cIOStream& Stream, mClampMode(ClampMode), mCompressTexture(CompressTexture), mLocalCopy(KeepLocalCopy), + mForceGLThreaded(false), mPack(NULL), mStream(&Stream), mImagePtr(NULL), @@ -107,6 +108,7 @@ cTextureLoader::cTextureLoader( const std::string& Filepath, mClampMode(ClampMode), mCompressTexture(CompressTexture), mLocalCopy(KeepLocalCopy), + mForceGLThreaded(false), mPack(NULL), mStream(NULL), mImagePtr(NULL), @@ -139,6 +141,7 @@ cTextureLoader::cTextureLoader( const unsigned char * ImagePtr, mClampMode(ClampMode), mCompressTexture(CompressTexture), mLocalCopy(KeepLocalCopy), + mForceGLThreaded(false), mPack(NULL), mStream(NULL), mImagePtr(ImagePtr), @@ -171,6 +174,7 @@ cTextureLoader::cTextureLoader( cPack * Pack, mClampMode(ClampMode), mCompressTexture(CompressTexture), mLocalCopy(KeepLocalCopy), + mForceGLThreaded(false), mPack(Pack), mStream(NULL), mImagePtr(NULL), @@ -206,6 +210,7 @@ cTextureLoader::cTextureLoader( const unsigned char * Pixels, mClampMode(ClampMode), mCompressTexture(CompressTexture), mLocalCopy(KeepLocalCopy), + mForceGLThreaded(false), mPack(NULL), mStream(NULL), mImagePtr(NULL), @@ -419,7 +424,10 @@ void cTextureLoader::LoadFromPixels() { flags = ( mClampMode == CLAMP_REPEAT) ? (flags | SOIL_FLAG_TEXTURE_REPEATS) : flags; flags = ( mCompressTexture ) ? ( flags | SOIL_FLAG_COMPRESS_TO_DXT ) : flags; - if ( mThreaded && cEngine::instance()->IsSharedGLContextEnabled() && cEngine::instance()->GetCurrentWindow()->IsThreadedGLContext() ) { + if ( ( mThreaded || mForceGLThreaded ) && + ( mForceGLThreaded || cEngine::instance()->IsSharedGLContextEnabled() ) && + cEngine::instance()->GetCurrentWindow()->IsThreadedGLContext() ) + { cEngine::instance()->GetCurrentWindow()->SetGLContextThread(); } @@ -452,7 +460,10 @@ void cTextureLoader::LoadFromPixels() { glBindTexture( GL_TEXTURE_2D, PreviousTexture ); - if ( mThreaded && cEngine::instance()->IsSharedGLContextEnabled() && cEngine::instance()->GetCurrentWindow()->IsThreadedGLContext() ) { + if ( ( mThreaded || mForceGLThreaded ) && + ( mForceGLThreaded || cEngine::instance()->IsSharedGLContextEnabled() ) && + cEngine::instance()->GetCurrentWindow()->IsThreadedGLContext() ) + { cEngine::instance()->GetCurrentWindow()->UnsetGLContextThread(); } @@ -528,6 +539,14 @@ cTexture * cTextureLoader::GetTexture() const { return NULL; } +const bool& cTextureLoader::ForceUseGLSharedContext() const { + return mForceGLThreaded; +} + +void cTextureLoader::ForceUseGLSharedContext( bool force ) { + mForceGLThreaded = force; +} + void cTextureLoader::Unload() { if ( mLoaded ) { cTextureFactory::instance()->Remove( mTexId ); @@ -549,6 +568,7 @@ void cTextureLoader::Reset() { mSize = 0; mTexLoaded = false; mDirectUpload = false; + mForceGLThreaded = false; mImgType = STBI_unknown; mIsCompressed = 0; } diff --git a/src/eepp/window/backend/SDL2/cwindowsdl2.cpp b/src/eepp/window/backend/SDL2/cwindowsdl2.cpp index 5b207d2da..82549bc46 100644 --- a/src/eepp/window/backend/SDL2/cwindowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/cwindowsdl2.cpp @@ -295,13 +295,11 @@ bool cWindowSDL::IsThreadedGLContext() { } void cWindowSDL::SetGLContextThread() { - GLThreadMutexLock(); SDL_GL_MakeCurrent( mSDLWindow, mGLContextThread ); } void cWindowSDL::UnsetGLContextThread() { SDL_GL_MakeCurrent( mSDLWindow, NULL ); - GLThreadMutexUnlock(); } std::string cWindowSDL::GetVersion() { diff --git a/src/eepp/window/cwindow.cpp b/src/eepp/window/cwindow.cpp index ac4af57df..d4984ef78 100644 --- a/src/eepp/window/cwindow.cpp +++ b/src/eepp/window/cwindow.cpp @@ -536,14 +536,6 @@ void cWindow::SetGLContextThread() { void cWindow::UnsetGLContextThread() { } -void cWindow::GLThreadMutexLock() { - cEngine::instance()->mGLThreadMutex.Lock(); -} - -void cWindow::GLThreadMutexUnlock() { - cEngine::instance()->mGLThreadMutex.Unlock(); -} - #if EE_PLATFORM == EE_PLATFORM_ANDROID void * cWindow::GetJNIEnv() { return NULL;