diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index 0c2f4c0f..7f2049fe 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -32,11 +32,11 @@ jobs: # install EnTT git clone https://github.com/skypjack/entt.git cd entt/build - cmake -DCMAKE_BUILD_TYPE=Release -DENTT_INSTALL=on .. + cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release -DENTT_INSTALL=on .. sudo make install cd ../.. - name: Configure - run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_APPDIR=1 -DVOXELENGINE_BUILD_TESTS=ON + run: cmake -S . -B build -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_APPDIR=1 -DVOXELENGINE_BUILD_TESTS=ON - name: Build run: cmake --build build -t install - name: Run tests diff --git a/CMakeLists.txt b/CMakeLists.txt index f64a574e..6966e81f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.26) +cmake_minimum_required(VERSION 3.5) project(VoxelEngine) set(CMAKE_CXX_STANDARD 17) diff --git a/res/layouts/ingame_chat.xml b/res/layouts/ingame_chat.xml index 45ad4749..e7c3a52c 100644 --- a/res/layouts/ingame_chat.xml +++ b/res/layouts/ingame_chat.xml @@ -1,5 +1,5 @@ 0 && wrap && text[i+1] != L'\n') { + } else if (i > 0 && i+1 < text.length() && wrap && text[i+1] != L'\n') { size_t width = font->calcWidth(text, i-len-1, i-(i-len)+2); if (width >= wrapWidth) { // starting a fake line diff --git a/src/graphics/ui/elements/UINode.cpp b/src/graphics/ui/elements/UINode.cpp index d975315a..ac59fbb5 100644 --- a/src/graphics/ui/elements/UINode.cpp +++ b/src/graphics/ui/elements/UINode.cpp @@ -160,9 +160,9 @@ CursorShape UINode::getCursor() const { glm::vec2 UINode::calcPos() const { if (parent) { - return pos + parent->calcPos() + parent->getContentOffset(); + return glm::ivec2(pos + parent->calcPos() + parent->getContentOffset()); } - return pos; + return glm::ivec2(pos); } void UINode::scrolled(int value) { @@ -300,11 +300,13 @@ const std::string& UINode::getId() const { void UINode::reposition() { if (sizefunc) { - auto newSize = sizefunc(); - auto defsize = newSize; + glm::ivec2 newSize = sizefunc(); + glm::ivec2 defsize = newSize; if (parent) { defsize = parent->getSize(); } + newSize.x = newSize.x == 0 ? size.x : newSize.x; + newSize.y = newSize.y == 0 ? size.y : newSize.y; setSize( {newSize.x < 0 ? defsize.x + (newSize.x + 1) : newSize.x, newSize.y < 0 ? defsize.y + (newSize.y + 1) : newSize.y} diff --git a/src/window/Window.cpp b/src/window/Window.cpp index 0c1cccee..4e68877f 100644 --- a/src/window/Window.cpp +++ b/src/window/Window.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "debug/Logger.hpp" #include "graphics/core/ImageData.hpp" @@ -32,6 +33,7 @@ bool Window::fullscreen = false; CursorShape Window::cursor = CursorShape::ARROW; static util::ObjectsKeeper observers_keeper; +static std::unordered_set extensionsCache; static const char* gl_error_name(int error) { switch (error) { @@ -223,8 +225,10 @@ int Window::initialize(DisplaySettings* settings) { } } - glEnable(GL_DEBUG_OUTPUT); - glDebugMessageCallback(gl_message_callback, 0); + if (isGlExtensionSupported("GL_KHR_debug")) { + glEnable(GL_DEBUG_OUTPUT); + glDebugMessageCallback(gl_message_callback, nullptr); + } glViewport(0, 0, width, height); glClearColor(0.0f, 0.0f, 0.0f, 1); @@ -501,3 +505,29 @@ void Window::setIcon(const ImageData* image) { image->getData()}; glfwSetWindowIcon(window, 1, &icon); } + +static void initGlExtensionsCache() { + if (!extensionsCache.empty()) { + return; + } + + GLint numExtensions = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); + + for (GLint i = 0; i < numExtensions; ++i) { + const char *ext = reinterpret_cast(glGetStringi(GL_EXTENSIONS, i)); + if (ext) { + extensionsCache.insert(ext); + } + } +} + +bool Window::isGlExtensionSupported(const char *extension) { + if (!extension || !*extension) { + return false; + } + + initGlExtensionsCache(); + + return extensionsCache.find(extension) != extensionsCache.end(); +} diff --git a/src/window/Window.hpp b/src/window/Window.hpp index 77fd7076..b81da395 100644 --- a/src/window/Window.hpp +++ b/src/window/Window.hpp @@ -24,6 +24,7 @@ class Window { static CursorShape cursor; static bool tryToMaximize(GLFWwindow* window, GLFWmonitor* monitor); + static bool isGlExtensionSupported(const char *extension); public: static int posX; static int posY;