From 50ba84254c4b2b69298e80d7a41b30444d4bf99d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 1 Sep 2023 11:41:25 +0200 Subject: [PATCH] Fix: Ensure that all infos will be shown. --- contrib/cppcore | 2 +- src/Engine/App/AppBase.cpp | 4 +- src/Engine/Common/Logger.cpp | 2 +- src/Engine/Platform/PlatformInterface.cpp | 5 +-- .../Platform/sdl2/SDL2OGLRenderContext.cpp | 45 +++++++++---------- .../Platform/sdl2/SDL2OGLRenderContext.h | 26 +++++------ .../RenderBackend/OGLRenderer/OGLShader.cpp | 6 +-- 7 files changed, 42 insertions(+), 48 deletions(-) diff --git a/contrib/cppcore b/contrib/cppcore index ffcc14420..3ea6da792 160000 --- a/contrib/cppcore +++ b/contrib/cppcore @@ -1 +1 @@ -Subproject commit ffcc14420501cd761d2c6b862a56eeaef45ae82a +Subproject commit 3ea6da792d33ef4eab4bcf189e3a31f71f536423 diff --git a/src/Engine/App/AppBase.cpp b/src/Engine/App/AppBase.cpp index 899dd4904..642275d4c 100644 --- a/src/Engine/App/AppBase.cpp +++ b/src/Engine/App/AppBase.cpp @@ -250,7 +250,7 @@ bool AppBase::onCreate() { // register any available platform-specific log streams Common::AbstractLogStream *stream = Platform::PlatformPluginFactory::createPlatformLogStream(); - if (nullptr != stream) { + if (stream != nullptr) { Logger::getInstance()->registerLogStream(stream); } @@ -283,6 +283,7 @@ bool AppBase::onCreate() { MaterialBuilder::create(); ResourceCacheService *rcSrv = new ResourceCacheService; ServiceProvider::setService(ServiceType::ResourceService, rcSrv); + // Setup onMouse event-listener AbstractPlatformEventQueue *evHandler = mPlatformInterface->getPlatformEventHandler(); if (nullptr != evHandler) { @@ -351,7 +352,6 @@ bool AppBase::onDestroy() { delete mKeyboardEvListener; mKeyboardEvListener = nullptr; - osre_debug(Tag, "Set application state to destroyed."); mAppState = State::Destroyed; Logger::kill(); diff --git a/src/Engine/Common/Logger.cpp b/src/Engine/Common/Logger.cpp index a89f00e3f..1ffbfd17e 100644 --- a/src/Engine/Common/Logger.cpp +++ b/src/Engine/Common/Logger.cpp @@ -120,7 +120,7 @@ void Logger::debug(const String &domain, const String &msg) { } void Logger::info(const String &domain, const String &msg) { - if (getVerboseMode() == VerboseMode::Verbose || getVerboseMode() == VerboseMode::Debug || getVerboseMode() == VerboseMode::Trace) { + if (getVerboseMode() == VerboseMode::Normal || getVerboseMode() == VerboseMode::Verbose || getVerboseMode() == VerboseMode::Debug || getVerboseMode() == VerboseMode::Trace) { String logMsg; logMsg += "Info: "; diff --git a/src/Engine/Platform/PlatformInterface.cpp b/src/Engine/Platform/PlatformInterface.cpp index e1bfab237..87cb1f35e 100644 --- a/src/Engine/Platform/PlatformInterface.cpp +++ b/src/Engine/Platform/PlatformInterface.cpp @@ -25,7 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #ifdef OSRE_WINDOWS -#include +# include #endif // OSRE_WINDOWS #include #include @@ -72,7 +72,7 @@ static const c8 *PlatformPluginName[static_cast(PluginType::MaxPlugin)] = { #endif // OSRE_WINDOWS }; -static const c8 *Tag = "PlatformInterface"; +static constexpr c8 Tag[] = "PlatformInterface"; PlatformInterface::PlatformInterface(const Settings *config) : AbstractService("platform/platforminterface"), mContext(nullptr) { @@ -81,7 +81,6 @@ PlatformInterface::PlatformInterface(const Settings *config) : PlatformInterface::~PlatformInterface() { delete mContext; - mContext = nullptr; } PlatformInterface *PlatformInterface::create(const Settings *config) { diff --git a/src/Engine/Platform/sdl2/SDL2OGLRenderContext.cpp b/src/Engine/Platform/sdl2/SDL2OGLRenderContext.cpp index 40a0825c6..ba36a9b72 100644 --- a/src/Engine/Platform/sdl2/SDL2OGLRenderContext.cpp +++ b/src/Engine/Platform/sdl2/SDL2OGLRenderContext.cpp @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------------------------- The MIT License (MIT) -Copyright (c) 2015-2020 OSRE ( Open Source Render Engine ) by Kim Kulling +Copyright (c) 2015-2023 OSRE ( Open Source Render Engine ) by Kim Kulling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -30,29 +30,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace OSRE { namespace Platform { -static const c8 *Tag = "SDL2RenderContext"; +static constexpr c8 Tag[] = "SDL2RenderContext"; -SDL2RenderContext::SDL2RenderContext() -: AbstractOGLRenderContext() -, m_renderContext( nullptr ) -, m_surface( nullptr ) -, m_isActive( false ) { +SDL2RenderContext::SDL2RenderContext() : + AbstractOGLRenderContext(), mRenderContext( nullptr ), mSurface( nullptr ), mIsActive( false ) { // empty } -SDL2RenderContext::~SDL2RenderContext( ) { - // empty -} - -bool SDL2RenderContext::onCreate( AbstractWindow *window ) { - if( !window ) { +bool SDL2RenderContext::onCreate(AbstractWindow *window) { + printf("SDL2RenderContext::onCreate(AbstractWindow *window)\n"); + if (window == nullptr) { osre_error( Tag, "Surface pointer is a nullptr." ); return false; } - m_surface = reinterpret_cast< SDL2Surface* >( window ); - m_renderContext = SDL_GL_CreateContext( m_surface->getSDLSurface() ); - if( !m_renderContext ) { + mSurface = reinterpret_cast( window ); + mRenderContext = SDL_GL_CreateContext( mSurface->getSDLSurface() ); + if( mRenderContext == nullptr) { osre_error( Tag, "Error while creating GL-context.!" ); return false; } @@ -64,40 +58,41 @@ bool SDL2RenderContext::onCreate( AbstractWindow *window ) { return false; } + printf("Creating\n"); const GLubyte *version = glGetString( GL_VERSION ); - osre_info( Tag, "OpenGL renderer initiated.") - osre_info( Tag, "Version : " + String( (c8*) version ) ); + osre_info(Tag, "OpenGL renderer initiated."); + osre_info(Tag, "Version : " + String((c8*)version)); return true; } //------------------------------------------------------------------------------------------------- bool SDL2RenderContext::onDestroy( ) { - if( !m_renderContext ) { + if (mRenderContext == nullptr) { osre_error( Tag, "Context pointer is a nullptr." ); return false; } - SDL_GL_DeleteContext( m_renderContext ); - m_renderContext = nullptr; + SDL_GL_DeleteContext( mRenderContext ); + mRenderContext = nullptr; return true; } //------------------------------------------------------------------------------------------------- bool SDL2RenderContext::onUpdate( ) { - if ( !m_isActive ) { + if ( !mIsActive ) { osre_debug( Tag, "No active render context." ); } - SDL_GL_SwapWindow( m_surface->getSDLSurface() ); + SDL_GL_SwapWindow( mSurface->getSDLSurface() ); return true; } //------------------------------------------------------------------------------------------------- bool SDL2RenderContext::onActivate( ) { - m_isActive = true; - const i32 retCode( SDL_GL_MakeCurrent( m_surface->getSDLSurface(), m_renderContext ) ); + mIsActive = true; + const i32 retCode = SDL_GL_MakeCurrent( mSurface->getSDLSurface(), mRenderContext ); return ( retCode == 0 ); } diff --git a/src/Engine/Platform/sdl2/SDL2OGLRenderContext.h b/src/Engine/Platform/sdl2/SDL2OGLRenderContext.h index 8f554d2aa..2c4c49e5d 100644 --- a/src/Engine/Platform/sdl2/SDL2OGLRenderContext.h +++ b/src/Engine/Platform/sdl2/SDL2OGLRenderContext.h @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------------------------- The MIT License (MIT) -Copyright (c) 2015-2020 OSRE ( Open Source Render Engine ) by Kim Kulling +Copyright (c) 2015-2023 OSRE ( Open Source Render Engine ) by Kim Kulling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -32,28 +32,28 @@ namespace Platform { class SDL2Surface; //------------------------------------------------------------------------------------------------- -/// @class ::OSRE::Platform::SDL2RenderContext /// @ingroup Engine /// -/// @brief +/// @brief This class implements the SDL2 OpenGL render context generation. //------------------------------------------------------------------------------------------------- class SDL2RenderContext : public AbstractOGLRenderContext { public: - /// The class constructor. + /// @brief The class constructor. SDL2RenderContext(); - /// The class destructor. - virtual ~SDL2RenderContext(); + + /// @brief The class destructor. + ~SDL2RenderContext() override = default; protected: - virtual bool onCreate( AbstractWindow *pSurface ); - virtual bool onDestroy(); - virtual bool onUpdate( ); - virtual bool onActivate( ); + bool onCreate( AbstractWindow *pSurface ) override; + bool onDestroy() override; + bool onUpdate( ) override; + bool onActivate() override; private: - SDL_GLContext m_renderContext; - SDL2Surface *m_surface; - bool m_isActive; + SDL_GLContext mRenderContext; + SDL2Surface *mSurface; + bool mIsActive; }; } // Namespace Platform diff --git a/src/Engine/RenderBackend/OGLRenderer/OGLShader.cpp b/src/Engine/RenderBackend/OGLRenderer/OGLShader.cpp index 6121cfa1d..84032814f 100644 --- a/src/Engine/RenderBackend/OGLRenderer/OGLShader.cpp +++ b/src/Engine/RenderBackend/OGLRenderer/OGLShader.cpp @@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace OSRE { namespace RenderBackend { -static const c8 *Tag = "OGLShader"; +static constexpr c8 Tag[] = "OGLShader"; OGLShader::OGLShader(const String &name) : Object(name), @@ -90,7 +90,7 @@ bool OGLShader::loadFromStream(ShaderType type, IO::Stream &stream) { c8 *data = new c8[filesize]; stream.read(data, filesize); - const bool retCode(loadFromSource(type, String(data))); + const bool retCode = loadFromSource(type, String(data)); delete[] data; return retCode; @@ -242,7 +242,7 @@ void OGLShader::logCompileOrLinkError(ui32 shaderprog) { ::memset(infoLog, 0, infoLogLength); glGetProgramInfoLog(shaderprog, infoLogLength, NULL, infoLog); String error(infoLog); - osre_debug(Tag, "Link log: " + error + "\n"); + Common::Logger::getInstance()->print("Link log:\n" + error + "\n"); delete[] infoLog; }