Skip to content

Commit

Permalink
Merge pull request #188 from kimkulling/kimkulling/fix_rendering_issu…
Browse files Browse the repository at this point in the history
…e-187

Fix initial rendering for linux
  • Loading branch information
kimkulling authored Sep 1, 2023
2 parents 50ba842 + eeb16c9 commit 575bbc8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/Engine/Platform/AbstractPlatformEventQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void AbstractPlatformEventQueue::processEvents(Common::EventTriggerer *triggerer
EventBus *eventBus = getEventBus();
osre_assert(nullptr != eventBus);
while (!theList->isEmpty()) {
Common::EventData *eventData = theList->front();
EventData *eventData = theList->front();
if (nullptr != eventData) {
eventBus->publish(eventData->getEvent(), eventData);
triggerer->triggerEvent(eventData->getEvent(), eventData);
Expand Down
45 changes: 15 additions & 30 deletions src/Engine/Platform/sdl2/SDL2EventQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ using namespace ::OSRE::RenderBackend;

using namespace ::cppcore;

static const c8 *Tag = "SDL2EventHandler";
static constexpr c8 Tag[] = "SDL2EventHandler";

//-------------------------------------------------------------------------------------------------
// The abstract interface for sdl2-based event updates.
//-------------------------------------------------------------------------------------------------
struct AbstractSDL2InputUpdate {
// The virtual destructor.
virtual ~AbstractSDL2InputUpdate() {
// empty
}
virtual ~AbstractSDL2InputUpdate() = default;

// Will perform the update.
virtual bool update(SDL_Event *ev) = 0;
Expand All @@ -57,19 +55,15 @@ struct AbstractSDL2InputUpdate {
//-------------------------------------------------------------------------------------------------
// Implements a get update, waits for the next event.
//-------------------------------------------------------------------------------------------------
struct SDL2GetInputUpdate : public AbstractSDL2InputUpdate {
struct SDL2GetInputUpdate final : public AbstractSDL2InputUpdate {
// The default constructor.
SDL2GetInputUpdate() {
// empty
}
SDL2GetInputUpdate() = default;

// The destructor.
~SDL2GetInputUpdate() {
// empty
}
~SDL2GetInputUpdate() override = default;

// Update implemented as a wait operation, will get the next upcoming event.
bool update(SDL_Event *ev) {
bool update(SDL_Event *ev) override {
const i32 ret = SDL_WaitEvent(ev);
if (0 == ret) {
return false;
Expand All @@ -82,19 +76,15 @@ struct SDL2GetInputUpdate : public AbstractSDL2InputUpdate {
//-------------------------------------------------------------------------------------------------
// Implements a peek update, polls for the next event.
//-------------------------------------------------------------------------------------------------
struct SDL2PeekInputUpdate : public AbstractSDL2InputUpdate {
struct SDL2PeekInputUpdate final : public AbstractSDL2InputUpdate {
// The default constructor.
SDL2PeekInputUpdate() {
// empty
}
SDL2PeekInputUpdate() = default;

// The destructor.
~SDL2PeekInputUpdate() {
// empty
}
~SDL2PeekInputUpdate() override = default;

// Update implemented as a poll operation, will check for a new event.
bool update(SDL_Event *ev) {
bool update(SDL_Event *ev) override {
const i32 ret = ::SDL_PollEvent(ev);
if (0 == ret) {
return false;
Expand Down Expand Up @@ -146,10 +136,7 @@ SDL2EventHandler::~SDL2EventHandler() {
unregisterAllMenuCommands();

delete m_eventTriggerer;
m_eventTriggerer = nullptr;

delete m_inputUpdate;
m_inputUpdate = nullptr;
}

bool SDL2EventHandler::update() {
Expand Down Expand Up @@ -193,15 +180,13 @@ bool SDL2EventHandler::update() {
case SDL_WINDOWEVENT: {
if (ev.window.windowID == windowID) {
switch (ev.window.event) {
case SDL_WINDOWEVENT_MOVED: {
ui32 x = (ui32)ev.window.data1;
ui32 y = (ui32)ev.window.data2;
getRenderBackendService()->resize(x, y, mWindow->getProperties()->m_width, mWindow->getProperties()->m_width);
case SDL_WINDOWEVENT_EXPOSED: {
getRenderBackendService()->resize(mWindow->getProperties()->m_x, mWindow->getProperties()->m_y, mWindow->getProperties()->m_width, mWindow->getProperties()->m_width);
} break;

case SDL_WINDOWEVENT_SHOWN:
case SDL_WINDOWEVENT_SIZE_CHANGED: {
ui32 w = ev.window.data1;
ui32 h = ev.window.data2;
const ui32 w = (ui32) ev.window.data1;
const ui32 h = (ui32) ev.window.data2;
getRenderBackendService()->resize(mWindow->getProperties()->m_x, mWindow->getProperties()->m_y, w, h);
} break;
}
Expand Down
1 change: 0 additions & 1 deletion src/Engine/Platform/sdl2/SDL2OGLRenderContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ 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));
Expand Down
3 changes: 1 addition & 2 deletions src/Engine/Platform/sdl2/SDL2Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,13 @@ bool SDL2Surface::onUpdateProperies() {
}

void SDL2Surface::onResize( ui32 x, ui32 y, ui32 w, ui32 h ) {
printf("resizing\n");
if ( nullptr == m_surface ) {
return;
}

SDL_SetWindowPosition( m_surface, x, y );
SDL_SetWindowSize( m_surface, w, h );
WindowsProperties *props( AbstractWindow::getProperties() );
WindowsProperties *props = AbstractWindow::getProperties();
if ( nullptr != props ) {
props->m_x = x;
props->m_y = y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void OGLRenderEventHandler::enqueueRenderCmd(OGLRenderCmd *oglRenderCmd) {
m_renderCmdBuffer->enqueueRenderCmd(oglRenderCmd);
}

void OGLRenderEventHandler::setParameter(const ::cppcore::TArray<OGLParameter *> &paramArray) {
void OGLRenderEventHandler::setParameter(const TArray<OGLParameter *> &paramArray) {
osre_assert(m_renderCmdBuffer != nullptr);

m_renderCmdBuffer->setParameter(paramArray);
Expand Down Expand Up @@ -233,7 +233,6 @@ bool OGLRenderEventHandler::onDetachView(const EventData *) {
}

bool OGLRenderEventHandler::onClearGeo(const EventData *) {
printf("OGLRenderEventHandler::onClearGeo\n");
osre_assert(nullptr != m_oglBackend);
osre_assert(nullptr != m_renderCmdBuffer);

Expand Down Expand Up @@ -300,7 +299,7 @@ bool OGLRenderEventHandler::addMeshes(const c8 *id, cppcore::TArray<size_t> &pri
return true;
}

bool OGLRenderEventHandler::onInitRenderPasses(const Common::EventData *eventData) {
bool OGLRenderEventHandler:: onInitRenderPasses(const Common::EventData *eventData) {
osre_assert(nullptr != m_oglBackend);

InitPassesEventData *frameToCommitData = (InitPassesEventData*) eventData;
Expand Down

0 comments on commit 575bbc8

Please sign in to comment.