From 459a25162e452e3de3a310892dbd4b08f6356b80 Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Thu, 29 Aug 2024 21:24:28 +0200 Subject: [PATCH] Use title passed to showWindow as display name if none has been set --- examples/videoplayer.cpp | 1 + src/App.cpp | 2 +- src/jngl/Vec2.hpp | 2 +- src/jngl/window.hpp | 3 +++ src/main.cpp | 3 +++ 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/videoplayer.cpp b/examples/videoplayer.cpp index 55110a02..0b45fdb2 100644 --- a/examples/videoplayer.cpp +++ b/examples/videoplayer.cpp @@ -18,4 +18,5 @@ JNGL_MAIN_BEGIN { } jngl::swapBuffers(); } + jngl::trace("quit"); } JNGL_MAIN_END diff --git a/src/App.cpp b/src/App.cpp index 6afa90e2..b1cabbfc 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -76,7 +76,7 @@ void App::callAtExitFunctions() { } std::string App::getDisplayName() const { - return impl->displayName; + return impl ? impl->displayName : ""; } void App::setDisplayName(const std::string& displayName) { diff --git a/src/jngl/Vec2.hpp b/src/jngl/Vec2.hpp index 158400a6..3ff600d3 100644 --- a/src/jngl/Vec2.hpp +++ b/src/jngl/Vec2.hpp @@ -46,7 +46,7 @@ class Vec2 { /// returns true if both x and y are exactly 0 bool isNull() const; - /// rotates the vector clock-wise + /// rotates the vector clock-wise by \a angle (radian) void rotate(float angle); /// Helper function to use with cereal or Boost.Serialization diff --git a/src/jngl/window.hpp b/src/jngl/window.hpp index d0bff310..1abc8c86 100644 --- a/src/jngl/window.hpp +++ b/src/jngl/window.hpp @@ -16,6 +16,9 @@ namespace jngl { /// Creates the main window +/// +/// If you haven't set a display name for your app using AppParameters::displayName, \a title will +/// set for the display name. void showWindow(const std::string& title, int width, int height, bool fullscreen = false, std::pair minAspectRatio = { 4, 3 }, std::pair maxAspectRatio = { 16, 9 }); diff --git a/src/main.cpp b/src/main.cpp index 8ac5e8a2..c2a71601 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -264,6 +264,9 @@ void showWindow(const std::string& title, const int width, const int height, boo throw std::runtime_error("Height Is 0"); } pWindow.Set(new Window(title, width, height, fullscreen, minAspectRatio, maxAspectRatio)); + if (App::instance().getDisplayName().empty()) { + App::instance().setDisplayName(title); + } pWindow->SetMouseVisible(isMouseVisible); setAntiAliasing(antiAliasingEnabled); pWindow->initGlObjects();