From 1686a01b6ae7467e71eac247078248de4a3b3423 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 13 Dec 2021 23:47:30 +0000 Subject: Refactor to start splitting out UI components --- ui/gameMainWindow.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ui/gameMainWindow.cpp (limited to 'ui/gameMainWindow.cpp') diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp new file mode 100644 index 0000000..4421098 --- /dev/null +++ b/ui/gameMainWindow.cpp @@ -0,0 +1,43 @@ +#include "gameMainWindow.h" +#include "collection.hpp" +#include "gfx/camera_controller.h" +#include "manualCameraController.h" +#include "ui/window.h" +#include +#include +#include +#include // IWYU pragma: keep +#include +#include +#include +#include + +GameMainWindow::GameMainWindow(size_t w, size_t h) : + Window {static_cast(w), static_cast(h), "I Like Trains"}, uiShader {w, h}, camera {{-1250.0F, -1250.0F, + 35.0F}, + 70.0F, rdiv(w, h), + 0.1F, 10000.0F} +{ + inputStack.create(glm::vec2 {-1150, -1150}); + + shader.setUniform("lightDirection", glm::normalize(glm::vec3 {1, 0, -1})); + shader.setUniform("lightColor", {.6, .6, .6}); + shader.setUniform("ambientColor", {0.5, 0.5, 0.5}); +} + +void +GameMainWindow::tick(TickDuration) +{ + inputStack.apply(&CameraController::updateCamera, &camera); + shader.setView(camera.GetViewProjection()); +} + +void +GameMainWindow::Refresh(const GameState * gameState) const +{ + SDL_GL_MakeCurrent(m_window, m_glContext); + glEnable(GL_DEPTH_TEST); + gameState->world.apply(&Renderable::render, shader); + glDisable(GL_DEPTH_TEST); + // do ui bits +} -- cgit v1.2.3