This commit is contained in:
Xertis
2024-06-06 13:00:51 +03:00
7 changed files with 123 additions and 65 deletions
+48
View File
@@ -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/*'
+1 -1
View File
@@ -58,7 +58,7 @@ inline void create_channel(Engine* engine, std::string name, NumberSetting& sett
} }
engine->keepAlive(setting.observe([=](auto value) { engine->keepAlive(setting.observe([=](auto value) {
audio::get_channel(name)->setVolume(value*value); audio::get_channel(name)->setVolume(value*value);
})); }, true));
} }
Engine::Engine(EngineSettings& settings, SettingsHandler& settingsHandler, EnginePaths* paths) Engine::Engine(EngineSettings& settings, SettingsHandler& settingsHandler, EnginePaths* paths)
+11 -10
View File
@@ -13,19 +13,18 @@ Batch2D::Batch2D(size_t capacity) : capacity(capacity), color(1.0f){
{2}, {2}, {4}, {0} {2}, {2}, {4}, {0}
}; };
buffer = new float[capacity * B2D_VERTEX_SIZE]; buffer = std::make_unique<float[]>(capacity * B2D_VERTEX_SIZE);
mesh = std::make_unique<Mesh>(buffer, 0, attrs); mesh = std::make_unique<Mesh>(buffer.get(), 0, attrs);
index = 0; index = 0;
ubyte pixels[] = { ubyte pixels[] = {
0xFF, 0xFF, 0xFF, 0xFF 0xFF, 0xFF, 0xFF, 0xFF
}; };
blank = std::make_unique<Texture>(pixels, 1, 1, ImageFormat::rgba8888); blank = std::make_unique<Texture>(pixels, 1, 1, ImageFormat::rgba8888);
_texture = nullptr; currentTexture = nullptr;
} }
Batch2D::~Batch2D(){ Batch2D::~Batch2D(){
delete[] buffer;
} }
void Batch2D::setPrimitive(DrawPrimitive primitive) { void Batch2D::setPrimitive(DrawPrimitive primitive) {
@@ -37,7 +36,7 @@ void Batch2D::setPrimitive(DrawPrimitive primitive) {
} }
void Batch2D::begin(){ void Batch2D::begin(){
_texture = nullptr; currentTexture = nullptr;
blank->bind(); blank->bind();
color = glm::vec4(1.0f); color = glm::vec4(1.0f);
primitive = DrawPrimitive::triangle; primitive = DrawPrimitive::triangle;
@@ -73,14 +72,16 @@ void Batch2D::vertex(
} }
void Batch2D::texture(Texture* new_texture){ void Batch2D::texture(Texture* new_texture){
if (_texture == new_texture) if (currentTexture == new_texture) {
return; return;
}
flush(); flush();
_texture = new_texture; currentTexture = new_texture;
if (new_texture == nullptr) if (new_texture == nullptr) {
blank->bind(); blank->bind();
else } else {
new_texture->bind(); new_texture->bind();
}
} }
void Batch2D::untexture() { 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() { void Batch2D::flush() {
if (index == 0) if (index == 0)
return; return;
mesh->reload(buffer, index / B2D_VERTEX_SIZE); mesh->reload(buffer.get(), index / B2D_VERTEX_SIZE);
mesh->draw(gl::to_glenum(primitive)); mesh->draw(gl::to_glenum(primitive));
index = 0; index = 0;
} }
+2 -2
View File
@@ -12,13 +12,13 @@ class Texture;
struct UVRegion; struct UVRegion;
class Batch2D { class Batch2D {
float* buffer; std::unique_ptr<float[]> buffer;
size_t capacity; size_t capacity;
std::unique_ptr<Mesh> mesh; std::unique_ptr<Mesh> mesh;
std::unique_ptr<Texture> blank; std::unique_ptr<Texture> blank;
size_t index; size_t index;
glm::vec4 color; glm::vec4 color;
Texture* _texture; Texture* currentTexture;
DrawPrimitive primitive = DrawPrimitive::triangle; DrawPrimitive primitive = DrawPrimitive::triangle;
void setPrimitive(DrawPrimitive primitive); void setPrimitive(DrawPrimitive primitive);
+23 -16
View File
@@ -14,28 +14,29 @@ Batch3D::Batch3D(size_t capacity)
{3}, {2}, {4}, {0} {3}, {2}, {4}, {0}
}; };
buffer = new float[capacity * B3D_VERTEX_SIZE]; buffer = std::make_unique<float[]>(capacity * B3D_VERTEX_SIZE);
mesh = std::make_unique<Mesh>(buffer, 0, attrs); mesh = std::make_unique<Mesh>(buffer.get(), 0, attrs);
index = 0; index = 0;
ubyte pixels[] = { ubyte pixels[] = {
255, 255, 255, 255, 255, 255, 255, 255,
}; };
blank = std::make_unique<Texture>(pixels, 1, 1, ImageFormat::rgba8888); blank = std::make_unique<Texture>(pixels, 1, 1, ImageFormat::rgba8888);
_texture = nullptr; currentTexture = nullptr;
} }
Batch3D::~Batch3D(){ Batch3D::~Batch3D(){
delete[] buffer;
} }
void Batch3D::begin(){ void Batch3D::begin(){
_texture = nullptr; currentTexture = nullptr;
blank->bind(); blank->bind();
} }
void Batch3D::vertex(float x, float y, float z, float u, float v, void Batch3D::vertex(
float r, float g, float b, float a) { float x, float y, float z, float u, float v,
float r, float g, float b, float a
) {
buffer[index++] = x; buffer[index++] = x;
buffer[index++] = y; buffer[index++] = y;
buffer[index++] = z; 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++] = b;
buffer[index++] = a; buffer[index++] = a;
} }
void Batch3D::vertex(glm::vec3 coord, float u, float v, void Batch3D::vertex(
float r, float g, float b, float a) { glm::vec3 coord, float u, float v,
float r, float g, float b, float a
) {
buffer[index++] = coord.x; buffer[index++] = coord.x;
buffer[index++] = coord.y; buffer[index++] = coord.y;
buffer[index++] = coord.z; buffer[index++] = coord.z;
@@ -58,9 +61,11 @@ void Batch3D::vertex(glm::vec3 coord, float u, float v,
buffer[index++] = b; buffer[index++] = b;
buffer[index++] = a; buffer[index++] = a;
} }
void Batch3D::vertex(glm::vec3 point, void Batch3D::vertex(
glm::vec3 point,
glm::vec2 uvpoint, glm::vec2 uvpoint,
float r, float g, float b, float a) { float r, float g, float b, float a
) {
buffer[index++] = point.x; buffer[index++] = point.x;
buffer[index++] = point.y; buffer[index++] = point.y;
buffer[index++] = point.z; buffer[index++] = point.z;
@@ -99,10 +104,10 @@ void Batch3D::face(
} }
void Batch3D::texture(Texture* new_texture){ void Batch3D::texture(Texture* new_texture){
if (_texture == new_texture) if (currentTexture == new_texture)
return; return;
flush(); flush();
_texture = new_texture; currentTexture = new_texture;
if (new_texture == nullptr) if (new_texture == nullptr)
blank->bind(); blank->bind();
else else
@@ -166,7 +171,9 @@ inline glm::vec4 do_tint(float value) {
return glm::vec4(value, value, value, 1.0f); 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( face(
glm::vec3(-w * 0.25f, 0.0f, -w * 0.25f), glm::vec3(-w * 0.25f, 0.0f, -w * 0.25f),
w, h, w, h,
@@ -244,13 +251,13 @@ void Batch3D::point(glm::vec3 coord, glm::vec4 tint) {
} }
void Batch3D::flush() { void Batch3D::flush() {
mesh->reload(buffer, index / B3D_VERTEX_SIZE); mesh->reload(buffer.get(), index / B3D_VERTEX_SIZE);
mesh->draw(); mesh->draw();
index = 0; index = 0;
} }
void Batch3D::flushPoints() { void Batch3D::flushPoints() {
mesh->reload(buffer, index / B3D_VERTEX_SIZE); mesh->reload(buffer.get(), index / B3D_VERTEX_SIZE);
mesh->draw(GL_POINTS); mesh->draw(GL_POINTS);
index = 0; index = 0;
} }
+18 -11
View File
@@ -12,28 +12,35 @@ class Mesh;
class Texture; class Texture;
class Batch3D { class Batch3D {
float* buffer; std::unique_ptr<float[]> buffer;
size_t capacity; size_t capacity;
std::unique_ptr<Mesh> mesh; std::unique_ptr<Mesh> mesh;
std::unique_ptr<Texture> blank; std::unique_ptr<Texture> blank;
size_t index; size_t index;
Texture* _texture; Texture* currentTexture;
void vertex(float x, float y, float z, void vertex(
float x, float y, float z,
float u, float v, float u, float v,
float r, float g, float b, float a); float r, float g, float b, float a
void vertex(glm::vec3 coord, );
void vertex(
glm::vec3 coord,
float u, float v, float u, float v,
float r, float g, float b, float a); 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 vertex(
glm::vec3 point, glm::vec2 uvpoint,
void face(const glm::vec3& coord, float w, float h, 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& axisX,
const glm::vec3& axisY, const glm::vec3& axisY,
const UVRegion& region, const UVRegion& region,
const glm::vec4& tint); const glm::vec4& tint
);
public: public:
Batch3D(size_t capacity); Batch3D(size_t capacity);
-5
View File
@@ -68,8 +68,6 @@ void GUI::updateTooltip(float delta) {
if (hover == nullptr || !hover->isInside(Events::cursor)) { if (hover == nullptr || !hover->isInside(Events::cursor)) {
return resetTooltip(); return resetTooltip();
} }
float mouseDelta = glm::length(Events::delta);
if (mouseDelta < 1.0f || tooltipTimer >= hover->getTooltipDelay()) {
if (tooltipTimer + delta >= hover->getTooltipDelay()) { if (tooltipTimer + delta >= hover->getTooltipDelay()) {
auto label = std::dynamic_pointer_cast<gui::Label>(get("tooltip.label")); auto label = std::dynamic_pointer_cast<gui::Label>(get("tooltip.label"));
const auto& text = hover->getTooltip(); const auto& text = hover->getTooltip();
@@ -89,9 +87,6 @@ void GUI::updateTooltip(float delta) {
} }
} }
tooltipTimer += delta; tooltipTimer += delta;
} else {
resetTooltip();
}
} }
/// @brief Mouse related input and logic handling /// @brief Mouse related input and logic handling