From 6744b592b2f6a2e6f2b1971bbe28aa481eb838fb Mon Sep 17 00:00:00 2001 From: LumperBumper <130532332+callfishxt@users.noreply.github.com> Date: Wed, 5 Jun 2024 23:15:14 +0500 Subject: [PATCH 1/6] Create windows --- .github/workflows/windows | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/windows diff --git a/.github/workflows/windows b/.github/workflows/windows new file mode 100644 index 000000000..46fe71221 --- /dev/null +++ b/.github/workflows/windows @@ -0,0 +1,48 @@ +name: Windows Build + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build-windows: + + strategy: + matrix: + include: + - os: windows-latest + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + with: + submodules: 'true' + + - name: Set up vcpkg + run: | + git clone https://github.com/microsoft/vcpkg.git + cd vcpkg + .\bootstrap-vcpkg.bat + .\vcpkg integrate install + cd .. + - name: Configure and build project with CMake and vcpkg + run: | + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_WINDOWS_VCPKG=ON .. + Remove-Item -Path CMakeFiles -Recurse -Force + cmake -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_WINDOWS_VCPKG=ON .. + cmake --build . --config Release + - name: Package for Windows + run: | + mkdir packaged + cp -r build/* packaged/ + working-directory: ${{ github.workspace }} + + - uses: actions/upload-artifact@v2 + with: + name: Windows-Build + path: 'packaged/Release/*' From b549023bdaf6684fcfcf789eab322e1ed9649a6b Mon Sep 17 00:00:00 2001 From: LumperBumper <130532332+callfishxt@users.noreply.github.com> Date: Wed, 5 Jun 2024 23:15:34 +0500 Subject: [PATCH 2/6] Delete .github/workflows/windows --- .github/workflows/windows | 48 --------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 .github/workflows/windows diff --git a/.github/workflows/windows b/.github/workflows/windows deleted file mode 100644 index 46fe71221..000000000 --- a/.github/workflows/windows +++ /dev/null @@ -1,48 +0,0 @@ -name: Windows Build - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - build-windows: - - strategy: - matrix: - include: - - os: windows-latest - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v2 - with: - submodules: 'true' - - - name: Set up vcpkg - run: | - git clone https://github.com/microsoft/vcpkg.git - cd vcpkg - .\bootstrap-vcpkg.bat - .\vcpkg integrate install - cd .. - - name: Configure and build project with CMake and vcpkg - run: | - mkdir build - cd build - cmake -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_WINDOWS_VCPKG=ON .. - Remove-Item -Path CMakeFiles -Recurse -Force - cmake -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_WINDOWS_VCPKG=ON .. - cmake --build . --config Release - - name: Package for Windows - run: | - mkdir packaged - cp -r build/* packaged/ - working-directory: ${{ github.workspace }} - - - uses: actions/upload-artifact@v2 - with: - name: Windows-Build - path: 'packaged/Release/*' From 6e4c6b63e91c3f60c62506176154054765ca8684 Mon Sep 17 00:00:00 2001 From: LumperBumper <130532332+callfishxt@users.noreply.github.com> Date: Wed, 5 Jun 2024 23:15:50 +0500 Subject: [PATCH 3/6] Create windows.yml --- .github/workflows/windows.yml | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 000000000..46fe71221 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,48 @@ +name: Windows Build + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build-windows: + + strategy: + matrix: + include: + - os: windows-latest + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + with: + submodules: 'true' + + - name: Set up vcpkg + run: | + git clone https://github.com/microsoft/vcpkg.git + cd vcpkg + .\bootstrap-vcpkg.bat + .\vcpkg integrate install + cd .. + - name: Configure and build project with CMake and vcpkg + run: | + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_WINDOWS_VCPKG=ON .. + Remove-Item -Path CMakeFiles -Recurse -Force + cmake -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_WINDOWS_VCPKG=ON .. + cmake --build . --config Release + - name: Package for Windows + run: | + mkdir packaged + cp -r build/* packaged/ + working-directory: ${{ github.workspace }} + + - uses: actions/upload-artifact@v2 + with: + name: Windows-Build + path: 'packaged/Release/*' From 8700f892c655bff2773fe4b143447f1996e95df0 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 5 Jun 2024 22:52:13 +0300 Subject: [PATCH 4/6] fix: audio volume setting not applied on load --- src/engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine.cpp b/src/engine.cpp index 8b57a2378..4720f9094 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -58,7 +58,7 @@ inline void create_channel(Engine* engine, std::string name, NumberSetting& sett } engine->keepAlive(setting.observe([=](auto value) { audio::get_channel(name)->setVolume(value*value); - })); + }, true)); } Engine::Engine(EngineSettings& settings, SettingsHandler& settingsHandler, EnginePaths* paths) From 7db76a0e6acf92ee2f5ac075320a240088481644 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 6 Jun 2024 11:24:16 +0300 Subject: [PATCH 5/6] refactor: Batch2D and Batch3D --- src/graphics/core/Batch2D.cpp | 21 +++++++++--------- src/graphics/core/Batch2D.hpp | 4 ++-- src/graphics/core/Batch3D.cpp | 41 ++++++++++++++++++++--------------- src/graphics/core/Batch3D.hpp | 35 ++++++++++++++++++------------ 4 files changed, 58 insertions(+), 43 deletions(-) diff --git a/src/graphics/core/Batch2D.cpp b/src/graphics/core/Batch2D.cpp index c07c6632e..6e80af51b 100644 --- a/src/graphics/core/Batch2D.cpp +++ b/src/graphics/core/Batch2D.cpp @@ -13,19 +13,18 @@ Batch2D::Batch2D(size_t capacity) : capacity(capacity), color(1.0f){ {2}, {2}, {4}, {0} }; - buffer = new float[capacity * B2D_VERTEX_SIZE]; - mesh = std::make_unique(buffer, 0, attrs); + buffer = std::make_unique(capacity * B2D_VERTEX_SIZE); + mesh = std::make_unique(buffer.get(), 0, attrs); index = 0; ubyte pixels[] = { 0xFF, 0xFF, 0xFF, 0xFF }; blank = std::make_unique(pixels, 1, 1, ImageFormat::rgba8888); - _texture = nullptr; + currentTexture = nullptr; } Batch2D::~Batch2D(){ - delete[] buffer; } void Batch2D::setPrimitive(DrawPrimitive primitive) { @@ -37,7 +36,7 @@ void Batch2D::setPrimitive(DrawPrimitive primitive) { } void Batch2D::begin(){ - _texture = nullptr; + currentTexture = nullptr; blank->bind(); color = glm::vec4(1.0f); primitive = DrawPrimitive::triangle; @@ -73,14 +72,16 @@ void Batch2D::vertex( } void Batch2D::texture(Texture* new_texture){ - if (_texture == new_texture) + if (currentTexture == new_texture) { return; + } flush(); - _texture = new_texture; - if (new_texture == nullptr) + currentTexture = new_texture; + if (new_texture == nullptr) { blank->bind(); - else + } else { new_texture->bind(); + } } void Batch2D::untexture() { @@ -327,7 +328,7 @@ void Batch2D::sprite(float x, float y, float w, float h, int atlasRes, int index void Batch2D::flush() { if (index == 0) return; - mesh->reload(buffer, index / B2D_VERTEX_SIZE); + mesh->reload(buffer.get(), index / B2D_VERTEX_SIZE); mesh->draw(gl::to_glenum(primitive)); index = 0; } diff --git a/src/graphics/core/Batch2D.hpp b/src/graphics/core/Batch2D.hpp index cbd569088..18095cff8 100644 --- a/src/graphics/core/Batch2D.hpp +++ b/src/graphics/core/Batch2D.hpp @@ -12,13 +12,13 @@ class Texture; struct UVRegion; class Batch2D { - float* buffer; + std::unique_ptr buffer; size_t capacity; std::unique_ptr mesh; std::unique_ptr blank; size_t index; glm::vec4 color; - Texture* _texture; + Texture* currentTexture; DrawPrimitive primitive = DrawPrimitive::triangle; void setPrimitive(DrawPrimitive primitive); diff --git a/src/graphics/core/Batch3D.cpp b/src/graphics/core/Batch3D.cpp index 105c86231..7481ec6f9 100644 --- a/src/graphics/core/Batch3D.cpp +++ b/src/graphics/core/Batch3D.cpp @@ -14,28 +14,29 @@ Batch3D::Batch3D(size_t capacity) {3}, {2}, {4}, {0} }; - buffer = new float[capacity * B3D_VERTEX_SIZE]; - mesh = std::make_unique(buffer, 0, attrs); + buffer = std::make_unique(capacity * B3D_VERTEX_SIZE); + mesh = std::make_unique(buffer.get(), 0, attrs); index = 0; ubyte pixels[] = { 255, 255, 255, 255, }; blank = std::make_unique(pixels, 1, 1, ImageFormat::rgba8888); - _texture = nullptr; + currentTexture = nullptr; } Batch3D::~Batch3D(){ - delete[] buffer; } void Batch3D::begin(){ - _texture = nullptr; + currentTexture = nullptr; blank->bind(); } -void Batch3D::vertex(float x, float y, float z, float u, float v, - float r, float g, float b, float a) { +void Batch3D::vertex( + float x, float y, float z, float u, float v, + float r, float g, float b, float a +) { buffer[index++] = x; buffer[index++] = y; buffer[index++] = z; @@ -46,8 +47,10 @@ void Batch3D::vertex(float x, float y, float z, float u, float v, buffer[index++] = b; buffer[index++] = a; } -void Batch3D::vertex(glm::vec3 coord, float u, float v, - float r, float g, float b, float a) { +void Batch3D::vertex( + glm::vec3 coord, float u, float v, + float r, float g, float b, float a +) { buffer[index++] = coord.x; buffer[index++] = coord.y; buffer[index++] = coord.z; @@ -58,9 +61,11 @@ void Batch3D::vertex(glm::vec3 coord, float u, float v, buffer[index++] = b; buffer[index++] = a; } -void Batch3D::vertex(glm::vec3 point, - glm::vec2 uvpoint, - float r, float g, float b, float a) { +void Batch3D::vertex( + glm::vec3 point, + glm::vec2 uvpoint, + float r, float g, float b, float a +) { buffer[index++] = point.x; buffer[index++] = point.y; buffer[index++] = point.z; @@ -99,10 +104,10 @@ void Batch3D::face( } void Batch3D::texture(Texture* new_texture){ - if (_texture == new_texture) + if (currentTexture == new_texture) return; flush(); - _texture = new_texture; + currentTexture = new_texture; if (new_texture == nullptr) blank->bind(); else @@ -166,7 +171,9 @@ inline glm::vec4 do_tint(float value) { return glm::vec4(value, value, value, 1.0f); } -void Batch3D::xSprite(float w, float h, const UVRegion& uv, const glm::vec4 tint, bool shading) { +void Batch3D::xSprite( + float w, float h, const UVRegion& uv, const glm::vec4 tint, bool shading +) { face( glm::vec3(-w * 0.25f, 0.0f, -w * 0.25f), w, h, @@ -244,13 +251,13 @@ void Batch3D::point(glm::vec3 coord, glm::vec4 tint) { } void Batch3D::flush() { - mesh->reload(buffer, index / B3D_VERTEX_SIZE); + mesh->reload(buffer.get(), index / B3D_VERTEX_SIZE); mesh->draw(); index = 0; } void Batch3D::flushPoints() { - mesh->reload(buffer, index / B3D_VERTEX_SIZE); + mesh->reload(buffer.get(), index / B3D_VERTEX_SIZE); mesh->draw(GL_POINTS); index = 0; } diff --git a/src/graphics/core/Batch3D.hpp b/src/graphics/core/Batch3D.hpp index d6cda86b6..6ff42caad 100644 --- a/src/graphics/core/Batch3D.hpp +++ b/src/graphics/core/Batch3D.hpp @@ -12,28 +12,35 @@ class Mesh; class Texture; class Batch3D { - float* buffer; + std::unique_ptr buffer; size_t capacity; std::unique_ptr mesh; std::unique_ptr blank; size_t index; - Texture* _texture; - - void vertex(float x, float y, float z, - float u, float v, - float r, float g, float b, float a); - void vertex(glm::vec3 coord, - float u, float v, - float r, float g, float b, float a); - void vertex(glm::vec3 point, glm::vec2 uvpoint, - float r, float g, float b, float a); - - void face(const glm::vec3& coord, float w, float h, + Texture* currentTexture; + + void vertex( + float x, float y, float z, + float u, float v, + float r, float g, float b, float a + ); + void vertex( + glm::vec3 coord, + float u, float v, + float r, float g, float b, float a + ); + void vertex( + glm::vec3 point, glm::vec2 uvpoint, + float r, float g, float b, float a + ); + void face( + const glm::vec3& coord, float w, float h, const glm::vec3& axisX, const glm::vec3& axisY, const UVRegion& region, - const glm::vec4& tint); + const glm::vec4& tint + ); public: Batch3D(size_t capacity); From a57f8f41bb145f2af5f2d9e2b706ebbe88875d2d Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 6 Jun 2024 11:29:30 +0300 Subject: [PATCH 6/6] update: tooltip conditions --- src/graphics/ui/GUI.cpp | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/graphics/ui/GUI.cpp b/src/graphics/ui/GUI.cpp index ac32af786..c7ef8a1fe 100644 --- a/src/graphics/ui/GUI.cpp +++ b/src/graphics/ui/GUI.cpp @@ -68,30 +68,25 @@ void GUI::updateTooltip(float delta) { if (hover == nullptr || !hover->isInside(Events::cursor)) { return resetTooltip(); } - float mouseDelta = glm::length(Events::delta); - if (mouseDelta < 1.0f || tooltipTimer >= hover->getTooltipDelay()) { - if (tooltipTimer + delta >= hover->getTooltipDelay()) { - auto label = std::dynamic_pointer_cast(get("tooltip.label")); - const auto& text = hover->getTooltip(); - if (text.empty() && tooltip->isVisible()) { - return resetTooltip(); - } - if (label && !text.empty()) { - tooltip->setVisible(true); - label->setText(langs::get(text)); - auto size = label->getSize()+glm::vec2(4.0f); - auto pos = Events::cursor+glm::vec2(10.0f); - auto rootSize = container->getSize(); - pos.x = glm::min(pos.x, rootSize.x-size.x); - pos.y = glm::min(pos.y, rootSize.y-size.y); - tooltip->setSize(size); - tooltip->setPos(pos); - } + if (tooltipTimer + delta >= hover->getTooltipDelay()) { + auto label = std::dynamic_pointer_cast(get("tooltip.label")); + const auto& text = hover->getTooltip(); + if (text.empty() && tooltip->isVisible()) { + return resetTooltip(); + } + if (label && !text.empty()) { + tooltip->setVisible(true); + label->setText(langs::get(text)); + auto size = label->getSize()+glm::vec2(4.0f); + auto pos = Events::cursor+glm::vec2(10.0f); + auto rootSize = container->getSize(); + pos.x = glm::min(pos.x, rootSize.x-size.x); + pos.y = glm::min(pos.y, rootSize.y-size.y); + tooltip->setSize(size); + tooltip->setPos(pos); } - tooltipTimer += delta; - } else { - resetTooltip(); } + tooltipTimer += delta; } /// @brief Mouse related input and logic handling