diff options
author | LaG1924 <lag1924@gmail.com> | 2021-11-19 20:29:28 +0100 |
---|---|---|
committer | LaG1924 <lag1924@gmail.com> | 2021-11-19 20:29:28 +0100 |
commit | 83c61036966c4c358a094cabe27c8de60082200d (patch) | |
tree | 6947537bd6af8a1e0d16de6a75f3e07f7db3b268 /src/Render.cpp | |
parent | Added framebuffer to Gal (diff) | |
download | AltCraft-83c61036966c4c358a094cabe27c8de60082200d.tar AltCraft-83c61036966c4c358a094cabe27c8de60082200d.tar.gz AltCraft-83c61036966c4c358a094cabe27c8de60082200d.tar.bz2 AltCraft-83c61036966c4c358a094cabe27c8de60082200d.tar.lz AltCraft-83c61036966c4c358a094cabe27c8de60082200d.tar.xz AltCraft-83c61036966c4c358a094cabe27c8de60082200d.tar.zst AltCraft-83c61036966c4c358a094cabe27c8de60082200d.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Render.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/Render.cpp b/src/Render.cpp index e6eb673..b1277b2 100644 --- a/src/Render.cpp +++ b/src/Render.cpp @@ -109,8 +109,9 @@ void Render::InitSdl(unsigned int WinWidth, unsigned int WinHeight, std::string throw std::runtime_error("OpenGl context creation failed: " + std::string(SDL_GetError())); SetMouseCapture(false); - renderState.WindowWidth = WinWidth; - renderState.WindowHeight = WinHeight; + + windowWidth = WinWidth; + windowHeight = WinHeight; SDL_GL_SetSwapInterval(0); } @@ -221,7 +222,7 @@ void Render::RenderFrame() { //if (isWireframe) //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); if (renderWorld) - world->Render(renderState); + world->Render(static_cast<float>(windowWidth) / static_cast<float>(windowHeight)); //if (isWireframe) //glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); @@ -257,8 +258,8 @@ void Render::HandleEvents() { case SDL_WINDOWEVENT_RESIZED: { int width, height; SDL_GL_GetDrawableSize(window, &width, &height); - renderState.WindowWidth = width; - renderState.WindowHeight = height; + windowWidth = width; + windowHeight = height; rmlRender->Update(width, height); rmlContext->SetDimensions(Rml::Vector2i(width, height)); PrepareToRendering(); @@ -491,7 +492,6 @@ void Render::InitEvents() { stateString = "Playing"; renderWorld = true; SetState(State::Playing); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); GetGameState()->GetPlayer()->isFlying = Settings::ReadBool("flight", false); PUSH_EVENT("SetMinLightLevel", (float)Settings::ReadDouble("brightness", 0.2f)); }); @@ -501,7 +501,6 @@ void Render::InitEvents() { renderWorld = false; world.reset(); SetState(State::MainMenu); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); PluginSystem::CallOnDisconnected("Connection failed: " + eventData.get <std::string>()); }); @@ -510,7 +509,6 @@ void Render::InitEvents() { renderWorld = false; world.reset(); SetState(State::MainMenu); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); PluginSystem::CallOnDisconnected("Disconnected: " + eventData.get<std::string>()); }); @@ -602,9 +600,9 @@ void Render::InitRml() { rmlSystem = std::make_unique<RmlSystemInterface>(); Rml::SetSystemInterface(rmlSystem.get()); - rmlRender = std::make_unique<RmlRenderInterface>(renderState); + rmlRender = std::make_unique<RmlRenderInterface>(); Rml::SetRenderInterface(rmlRender.get()); - rmlRender->Update(renderState.WindowWidth, renderState.WindowHeight); + rmlRender->Update(windowWidth, windowHeight); rmlFile = std::make_unique<RmlFileInterface>(); Rml::SetFileInterface(rmlFile.get()); @@ -614,7 +612,7 @@ void Render::InitRml() { Rml::Lua::Initialise(PluginSystem::GetLuaState()); - rmlContext = Rml::CreateContext("default", Rml::Vector2i(renderState.WindowWidth, renderState.WindowHeight)); + rmlContext = Rml::CreateContext("default", Rml::Vector2i(windowWidth, windowHeight)); if (!Rml::Debugger::Initialise(rmlContext)) LOG(WARNING) << "Rml debugger not initialized"; |