From a93687d2bdb88efaac6e41e8bf491fac547a81fc Mon Sep 17 00:00:00 2001 From: bailwillharr Date: Sat, 29 Apr 2023 15:57:32 +0100 Subject: [PATCH] commit more files --- include/util.hpp | 2 +- src/application.cpp | 8 ++--- src/input_manager.cpp | 12 ++++---- src/systems/render.cpp | 2 +- src/vulkan/instance.cpp | 4 +-- src/window.cpp | 56 +++++++++++++++++----------------- test/src/camera_controller.cpp | 10 +++--- test/src/game.cpp | 2 +- 8 files changed, 48 insertions(+), 48 deletions(-) diff --git a/include/util.hpp b/include/util.hpp index e7c0169..276fb97 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -5,7 +5,7 @@ namespace engine { -inline bool versionFromCharArray(const char* version, int* major, int* minor, +inline bool VersionFromCharArray(const char* version, int* major, int* minor, int* patch) { if (sscanf(version, "%d.%d.%d", major, minor, patch) != 3) { *major = 0; diff --git a/src/application.cpp b/src/application.cpp index 1448892..ba34ec1 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -75,7 +75,7 @@ namespace engine { RegisterResourceManager(); // initialise the render data - render_data_.gfxdev = std::make_unique(appName, appVersion, window_->getHandle(), graphicsSettings); + render_data_.gfxdev = std::make_unique(appName, appVersion, window_->GetHandle(), graphicsSettings); std::vector globalSetBindings; { @@ -178,12 +178,12 @@ namespace engine { auto lastTick = window_->getNanos(); // single-threaded game loop - while (window_->isRunning()) { + while (window_->IsRunning()) { /* logic */ scene_manager_->UpdateActiveScene(window_->dt()); - if(window_->getKeyPress(inputs::Key::K_F)) [[unlikely]] { + if(window_->GetKeyPress(inputs::Key::K_F)) [[unlikely]] { window_->infoBox("fps", std::to_string(window_->getFPS()) + " fps " + std::to_string(window_->dt() * 1000.0f) + " ms"); } @@ -196,7 +196,7 @@ namespace engine { } /* poll events */ - window_->getInputAndEvents(); + window_->GetInputAndEvents(); /* fps limiter */ if (enable_frame_limiter_) { diff --git a/src/input_manager.cpp b/src/input_manager.cpp index 7860c9d..dba8853 100644 --- a/src/input_manager.cpp +++ b/src/input_manager.cpp @@ -104,9 +104,9 @@ bool InputManager::GetDeviceButton(enum InputDevice device, int button) const { switch (device) { case InputDevice::kMouse: - return win_->getButton(static_cast(button)); + return win_->GetButton(static_cast(button)); case InputDevice::kKeyboard: - return win_->getKey(static_cast(button)); + return win_->GetKey(static_cast(button)); case InputDevice::kController: break; default: break; @@ -118,9 +118,9 @@ bool InputManager::getDeviceButtonDown(enum InputDevice device, int button) cons { switch (device) { case InputDevice::kMouse: - return win_->getButtonPress(static_cast(button)); + return win_->GetButtonPress(static_cast(button)); case InputDevice::kKeyboard: - return win_->getKeyPress(static_cast(button)); + return win_->GetKeyPress(static_cast(button)); case InputDevice::kController: break; default: break; @@ -132,9 +132,9 @@ bool InputManager::GetDeviceButtonUp(enum InputDevice device, int button) const { switch (device) { case InputDevice::kMouse: - return win_->getButtonRelease(static_cast(button)); + return win_->GetButtonRelease(static_cast(button)); case InputDevice::kKeyboard: - return win_->getKeyRelease(static_cast(button)); + return win_->GetKeyRelease(static_cast(button)); case InputDevice::kController: break; default: break; diff --git a/src/systems/render.cpp b/src/systems/render.cpp index dbee604..823659c 100644 --- a/src/systems/render.cpp +++ b/src/systems/render.cpp @@ -38,7 +38,7 @@ namespace engine { glm::mat4 viewMatrix = glm::inverse(cameraTransform->worldMatrix); - if (scene_->app()->window()->getWindowResized()) { + if (scene_->app()->window()->GetWindowResized()) { uint32_t w, h; m_gfx->GetViewportSize(&w, &h); m_viewportAspectRatio = (float)w / (float)h; diff --git a/src/vulkan/instance.cpp b/src/vulkan/instance.cpp index 8570fd6..171e1bf 100644 --- a/src/vulkan/instance.cpp +++ b/src/vulkan/instance.cpp @@ -130,9 +130,9 @@ namespace engine { // get the both the engine and application versions int appVersionMajor = 0, appVersionMinor = 0, appVersionPatch = 0; - versionFromCharArray(appVersion, &appVersionMajor, &appVersionMinor, &appVersionPatch); + VersionFromCharArray(appVersion, &appVersionMajor, &appVersionMinor, &appVersionPatch); int engineVersionMajor = 0, engineVersionMinor = 0, engineVersionPatch = 0; - versionFromCharArray(ENGINE_VERSION, &engineVersionMajor, &engineVersionMinor, &engineVersionPatch); + VersionFromCharArray(ENGINE_VERSION, &engineVersionMajor, &engineVersionMinor, &engineVersionPatch); VkApplicationInfo applicationInfo{ .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, diff --git a/src/window.cpp b/src/window.cpp index efcccc1..5d3adfc 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -171,17 +171,17 @@ namespace engine { // public methods - SDL_Window* Window::getHandle() const + SDL_Window* Window::GetHandle() const { return m_handle; } - std::string Window::getTitle() const + std::string Window::GetTitle() const { return m_title; } - void Window::getInputAndEvents() + void Window::GetInputAndEvents() { m_frames++; @@ -197,7 +197,7 @@ namespace engine { switch (e.type) { case SDL_QUIT: - setCloseFlag(); + SetCloseFlag(); break; case SDL_WINDOWEVENT: @@ -227,53 +227,53 @@ namespace engine { } - void Window::setTitle(std::string title) + void Window::SetTitle(std::string title) { SDL_SetWindowTitle(m_handle, title.c_str()); } - bool Window::getWindowResized() const + bool Window::GetWindowResized() const { return m_justResized; } - void Window::setResizedFlag() + void Window::SetResizedFlag() { m_justResized = true; } - void Window::show() + void Window::Show() { SDL_ShowWindow(m_handle); } - void Window::hide() + void Window::Hide() { SDL_HideWindow(m_handle); } - void Window::focus() + void Window::Focus() { SDL_RaiseWindow(m_handle); m_keyboardFocus = true; } - bool Window::hasFocus() const + bool Window::HasFocus() const { return m_keyboardFocus; } - void Window::setCloseFlag() + void Window::SetCloseFlag() { m_shouldClose = true; } - bool Window::isRunning() const + bool Window::IsRunning() const { return !m_shouldClose; } - void Window::setFullscreen(bool fullscreen, bool exclusive) + void Window::SetFullscreen(bool fullscreen, bool exclusive) { if (m_resizable) { @@ -295,17 +295,17 @@ namespace engine { } } - void Window::toggleFullscreen() + void Window::ToggleFullscreen() { - setFullscreen(!m_fullscreen, true); + SetFullscreen(!m_fullscreen, true); } - bool Window::isFullscreen() const + bool Window::IsFullscreen() const { return m_fullscreen; } - bool Window::setRelativeMouseMode(bool enabled) + bool Window::SetRelativeMouseMode(bool enabled) { m_mouse.captured = enabled; int code = SDL_SetRelativeMouseMode(static_cast(enabled)); @@ -317,51 +317,51 @@ namespace engine { } } - bool Window::mouseCaptured() + bool Window::MouseCaptured() { return m_mouse.captured; } // getting input - bool Window::getKey(inputs::Key key) const + bool Window::GetKey(inputs::Key key) const { return m_keyboard.keys[static_cast(key)]; } - bool Window::getKeyPress(inputs::Key key) const + bool Window::GetKeyPress(inputs::Key key) const { return m_keyboard.deltas[static_cast(key)] == ButtonDelta::PRESSED; } - bool Window::getKeyRelease(inputs::Key key) const + bool Window::GetKeyRelease(inputs::Key key) const { return m_keyboard.deltas[static_cast(key)] == ButtonDelta::RELEASED; } // TODO mouse input - bool Window::getButton(inputs::MouseButton button) const + bool Window::GetButton(inputs::MouseButton button) const { return m_mouse.buttons[static_cast(button)]; } - bool Window::getButtonPress(inputs::MouseButton button) const + bool Window::GetButtonPress(inputs::MouseButton button) const { return m_mouse.deltas[static_cast(button)] == ButtonDelta::PRESSED; } - bool Window::getButtonRelease(inputs::MouseButton button) const + bool Window::GetButtonRelease(inputs::MouseButton button) const { return m_mouse.deltas[static_cast(button)] == ButtonDelta::RELEASED; } - int Window::getMouseX() const + int Window::GetMouseX() const { return static_cast(m_mouse.x); } - int Window::getMouseY() const + int Window::GetMouseY() const { return static_cast(m_mouse.y); } @@ -453,7 +453,7 @@ namespace engine { bool Window::infoBox(const std::string& title, const std::string& msg) { - if (isFullscreen() == false) { + if (IsFullscreen() == false) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, title.c_str(), msg.c_str(), m_handle); return true; } diff --git a/test/src/camera_controller.cpp b/test/src/camera_controller.cpp index dcc719a..0539472 100644 --- a/test/src/camera_controller.cpp +++ b/test/src/camera_controller.cpp @@ -82,7 +82,7 @@ void CameraControllerSystem::OnUpdate(float ts) c->dy = JUMPVEL; } - if (scene_->app()->window()->getButton(engine::inputs::MouseButton::M_LEFT)) { + if (scene_->app()->window()->GetButton(engine::inputs::MouseButton::M_LEFT)) { c->dy += dt * c->thrust; } @@ -148,7 +148,7 @@ void CameraControllerSystem::OnUpdate(float ts) /* user interface inputs */ - if (scene_->app()->window()->getKeyPress(engine::inputs::Key::K_P)) { + if (scene_->app()->window()->GetKeyPress(engine::inputs::Key::K_P)) { std::string pos_string{ "x: " + std::to_string(t->position.x) + " y: " + std::to_string(t->position.y) + @@ -158,17 +158,17 @@ void CameraControllerSystem::OnUpdate(float ts) LOG_INFO("position: " + pos_string); } - if (scene_->app()->window()->getKeyPress(engine::inputs::Key::K_R)) { + if (scene_->app()->window()->GetKeyPress(engine::inputs::Key::K_R)) { t->position = { 0.0f, 5.0f, 0.0f }; c->dy = 0.0f; } if (scene_->app()->input_manager()->GetButtonPress("fullscreen")) { - scene_->app()->window()->toggleFullscreen(); + scene_->app()->window()->ToggleFullscreen(); } if (scene_->app()->input_manager()->GetButtonPress("exit")) { - scene_->app()->window()->setCloseFlag(); + scene_->app()->window()->SetCloseFlag(); } c->justCollided = false; diff --git a/test/src/game.cpp b/test/src/game.cpp index 509a1ee..448aa00 100644 --- a/test/src/game.cpp +++ b/test/src/game.cpp @@ -56,7 +56,7 @@ void playGame(GameSettings settings) app.SetFrameLimiter(settings.enableFrameLimiter); // configure window - app.window()->setRelativeMouseMode(true); + app.window()->SetRelativeMouseMode(true); configureInputs(app.input_manager());