Skip to content

Commit

Permalink
refactor(gfx/GraphicsEngine): changed dynamic_cast to static_cast in …
Browse files Browse the repository at this point in the history
…InitApi
  • Loading branch information
tomezpl committed Oct 13, 2024
1 parent e807ac4 commit 6d2b04a
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions src/lepus/gfx/GraphicsEngine/GraphicsEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,48 @@ using namespace lepus::gfx;

void GraphicsEngine::InitWindowing(std::shared_ptr<lepus::system::Windowing> windowing)
{
m_Windowing = windowing;
m_Windowing = windowing;
}

void GraphicsEngine::InitApi(GraphicsApiOptions* options)
{
// Check that an API wasn't initialised before. For now, only one API can be initialised at runtime.
assert(m_Api == nullptr);

// Check that windowing has been initialised. In most cases we'll need windowing to make use of the API.
assert(m_Windowing != nullptr);

switch (options->GetType())
{
case GraphicsApiType::GraphicsApiOpenGL:
m_Api = new GraphicsApiGL(*dynamic_cast<GraphicsApiGLOptions*>(options));
break;
case GraphicsApiType::GraphicsApiVulkan:
// TODO
break;
case GraphicsApiType::GraphicsApiTest:
// Ignore test/mock APIs.
break;
case GraphicsApiType::GraphicsApiUnknown:
default:
// Assert if the API type is not part of the enum.
assert(false);
break;
}
// Check that an API wasn't initialised before. For now, only one API can be initialised at runtime.
assert(m_Api == nullptr);

// Check that windowing has been initialised. In most cases we'll need windowing to make use of the API.
assert(m_Windowing != nullptr);

switch (options->GetType())
{
case GraphicsApiType::GraphicsApiOpenGL:
m_Api = new GraphicsApiGL(*static_cast<GraphicsApiGLOptions*>(options));
break;
case GraphicsApiType::GraphicsApiVulkan:
// TODO
break;
case GraphicsApiType::GraphicsApiTest:
// Ignore test/mock APIs.
break;
case GraphicsApiType::GraphicsApiUnknown:
default:
// Assert if the API type is not part of the enum.
assert(false);
break;
}
}

void GraphicsEngine::Setup()
{
m_Api->CreatePipeline();
m_Api->CreatePipeline();
}

void GraphicsEngine::Render(const float r, const float g, const float b)
{
m_Api->ClearFrameBuffer(r, g, b);
m_Api->ClearFrameBuffer(r, g, b);

m_Api->UpdateUniforms();
m_Api->Draw();
m_Api->UpdateUniforms();
m_Api->Draw();

m_Api->SwapBuffers();
m_Windowing->SwapBuffers();
m_Api->SwapBuffers();
m_Windowing->SwapBuffers();
}

0 comments on commit 6d2b04a

Please sign in to comment.