Merge branch 'main' into devel
This commit is contained in:
commit
896ab3597a
4
.github/workflows/appimage.yml
vendored
4
.github/workflows/appimage.yml
vendored
@ -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
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.26)
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(VoxelEngine)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<panel size="300,0" margin="0,0,0,70" max-length='300' min-length='0'
|
||||
size-func="gui.get_viewport()[1]/2,-1"
|
||||
size-func="gui.get_viewport()[1]/2,0"
|
||||
padding="0"
|
||||
min-size="0"
|
||||
color="0"
|
||||
|
||||
@ -51,7 +51,7 @@ void LabelCache::update(std::wstring_view text, bool multiline, bool wrap) {
|
||||
if (text[i] == L'\n') {
|
||||
lines.push_back(LineScheme {i+1, false});
|
||||
len = 0;
|
||||
} else if (i > 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
|
||||
|
||||
@ -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}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <unordered_set>
|
||||
|
||||
#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<std::string> 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<const char *>(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();
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user