Skip to content

Commit

Permalink
Fix: Ensure that all infos will be shown.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim Kulling committed Sep 1, 2023
1 parent 13a25fe commit 50ba842
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 48 deletions.
2 changes: 1 addition & 1 deletion contrib/cppcore
Submodule cppcore updated 239 files
4 changes: 2 additions & 2 deletions src/Engine/App/AppBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -351,7 +352,6 @@ bool AppBase::onDestroy() {
delete mKeyboardEvListener;
mKeyboardEvListener = nullptr;


osre_debug(Tag, "Set application state to destroyed.");
mAppState = State::Destroyed;
Logger::kill();
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Common/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: ";
Expand Down
5 changes: 2 additions & 3 deletions src/Engine/Platform/PlatformInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <osre/Properties/Settings.h>
#include <src/Engine/Platform/PlatformPluginFactory.h>
#ifdef OSRE_WINDOWS
#include <src/Engine/Platform/win32/Win32OGLRenderContext.h>
# include <src/Engine/Platform/win32/Win32OGLRenderContext.h>
#endif // OSRE_WINDOWS
#include <src/Engine/Platform/sdl2/SDL2EventQueue.h>
#include <src/Engine/Platform/sdl2/SDL2Window.h>
Expand Down Expand Up @@ -72,7 +72,7 @@ static const c8 *PlatformPluginName[static_cast<i32>(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) {
Expand All @@ -81,7 +81,6 @@ PlatformInterface::PlatformInterface(const Settings *config) :

PlatformInterface::~PlatformInterface() {
delete mContext;
mContext = nullptr;
}

PlatformInterface *PlatformInterface::create(const Settings *config) {
Expand Down
45 changes: 20 additions & 25 deletions src/Engine/Platform/sdl2/SDL2OGLRenderContext.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<SDL2Surface*>( window );
mRenderContext = SDL_GL_CreateContext( mSurface->getSDLSurface() );
if( mRenderContext == nullptr) {
osre_error( Tag, "Error while creating GL-context.!" );
return false;
}
Expand All @@ -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 );
}

Expand Down
26 changes: 13 additions & 13 deletions src/Engine/Platform/sdl2/SDL2OGLRenderContext.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Engine/RenderBackend/OGLRenderer/OGLShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 50ba842

Please sign in to comment.