Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Linux

on:
push:
branches: [ main, refactor/dod_ecs ]
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
branches: [ main, refactor/dod_ecs ]

jobs:
build-and-test:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false || github.event_name == 'push'
strategy:
fail-fast: false
matrix:
include:
# Linux with GCC
- name: "Linux GCC"
compiler: gcc
cmake-generator: 'Ninja'
cmake-options: '-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DGAMECOE_USE_TESTCOE=ON -DGAMECOE_GLFW_WAYLAND=OFF'

# Linux with Clang
- name: "Linux Clang"
compiler: clang
cmake-generator: 'Ninja'
cmake-options: '-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DGAMECOE_USE_TESTCOE=ON -DGAMECOE_GLFW_WAYLAND=OFF'

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y ninja-build xorg-dev libgl1-mesa-dev libglu1-mesa-dev
shell: bash

- name: Configure CMake
run: |
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }}

- name: Build
run: |
cmake --build build --config Release

- name: Run tests
working-directory: build
run: |
echo "Running gamecoe tests"
./tests/gamecoe_tests
shell: bash
49 changes: 49 additions & 0 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: macOS

on:
push:
branches: [ main, refactor/dod_ecs ]
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
branches: [ main, refactor/dod_ecs ]

jobs:
build-and-test:
name: ${{ matrix.name }}
runs-on: macos-latest
if: github.event.pull_request.draft == false || github.event_name == 'push'
strategy:
fail-fast: false
matrix:
include:
# macOS with Apple Clang
- name: "macOS Clang"
compiler: clang
cmake-generator: 'Ninja'
cmake-options: '-DGAMECOE_USE_TESTCOE=ON'

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install ninja-build
run: |
brew install ninja
shell: bash

- name: Configure CMake
run: |
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }}

- name: Build
run: |
cmake --build build --config Release

- name: Run tests
working-directory: build
run: |
echo "Running gamecoe tests"
./tests/gamecoe_tests
shell: bash
74 changes: 74 additions & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Windows

on:
push:
branches: [ main, refactor/dod_ecs ]
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
branches: [ main, refactor/dod_ecs ]

jobs:
build-and-test:
name: ${{ matrix.name }}
runs-on: windows-latest
if: github.event.pull_request.draft == false || github.event_name == 'push'
strategy:
fail-fast: false
matrix:
include:
# Windows with MSVC
- name: "Windows MSVC"
compiler: msvc
cmake-generator: 'Visual Studio 17 2022'
cmake-options: '-DGAMECOE_USE_TESTCOE=ON'

# Windows with MinGW (GCC)
- name: "Windows MinGW"
compiler: gcc
cmake-generator: 'MinGW Makefiles'
cmake-options: '-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DGAMECOE_USE_TESTCOE=ON'

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install Windows build tools
if: matrix.compiler != 'msvc'
run: |
if [ "${{ matrix.compiler }}" == "clang" ]; then
choco install ninja
elif [ "${{ matrix.compiler }}" == "gcc" ]; then
choco install mingw
fi
shell: bash


- name: Configure CMake
run: |
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }}

- name: Build
run: |
cmake --build build --config Release

- name: Run tests
working-directory: build
run: |
if [ "${{ matrix.compiler }}" == "gcc" ]; then
# For MinGW - copy DLLs directly (no PATH manipulation)
GCC_DIR=$(dirname $(which gcc))
echo "GCC directory: $GCC_DIR"
echo "Copying DLLs from $GCC_DIR"
cp "$GCC_DIR"/libgcc*.dll tests/ 2>/dev/null || echo "No libgcc DLLs found"
cp "$GCC_DIR"/libstdc*.dll tests/ 2>/dev/null || echo "No libstdc DLLs found"
cp "$GCC_DIR"/libwinpthread*.dll tests/ 2>/dev/null || echo "No libwinpthread DLLs found"
echo "Running gamecoe tests"
cd tests
./gamecoe_tests.exe
else # MSVC
echo "Running gamecoe tests"
./tests/Release/gamecoe_tests.exe
fi
shell: bash
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ include(FetchContent)

# Fetching gamecoe toolkit libraries:
fetch_logcoe()
fetch_testcoe()
fetch_soundcoe()

# Fetching external libraries for gamecoe:
Expand All @@ -33,6 +34,10 @@ message(STATUS "[gamecoe] Building gamecoe library...")
add_subdirectory(include)
add_subdirectory(src)

if(GAMECOE_USE_TESTCOE)
add_subdirectory(tests)
endif()

# gamecoe tester executable
# add_executable(tester main.cpp)

Expand Down
1 change: 1 addition & 0 deletions cmake/gamecoe_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/glfw.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/glad.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/glm.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/logcoe.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/testcoe.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/soundcoe.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/utils.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/config_header.cmake)
Expand Down
24 changes: 24 additions & 0 deletions cmake/testcoe.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function(fetch_testcoe)
if(NOT DEFINED GAMECOE_USE_TESTCOE)
set(GAMECOE_USE_TESTCOE OFF)
endif()

if(GAMECOE_USE_TESTCOE)
message(STATUS "[gamecoe] Using testcoe for testing")
message(STATUS "[gamecoe] To disable: \"set(GAMECOE_USE_TESTCOE OFF)\" before fetching gamecoe")
set(GAMECOE_USE_TESTCOE 1 PARENT_SCOPE)

message(STATUS "[gamecoe] Fetching testcoe from source...")

FetchContent_Declare(
testcoe
GIT_REPOSITORY https://github.com/nircoe/testcoe.git
GIT_TAG v0.1.1
)
FetchContent_MakeAvailable(testcoe)
else()
message(STATUS "[gamecoe] testcoe disabled")
message(STATUS "[gamecoe] To enable: \"set(GAMECOE_USE_TESTCOE ON)\" before fetching gamecoe")
set(GAMECOE_USE_TESTCOE 0 PARENT_SCOPE)
endif()
endfunction()
14 changes: 3 additions & 11 deletions include/gamecoe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@
#include <gamecoe_config.hpp>

// gamecoe headers
#include <gamecoe/core/game.hpp>
#include <gamecoe/core/window.hpp>
#include <gamecoe/core/scene.hpp>

#include <gamecoe/graphics/shader.hpp>
#include <gamecoe/graphics/texture.hpp>

#include <gamecoe/entity/game_object.hpp>
#include <gamecoe/entity/renderer/renderer.hpp>
#include <gamecoe/entity/renderer/shape_renderer.hpp>
#include <gamecoe/entity/camera.hpp>
#include <gamecoe/entity/entity.hpp>
#include <gamecoe/entity/sparse_set.hpp>
#include <gamecoe/entity/component_pool.hpp>

// gamecoe toolkit libraries headers
#include <colorcoe.hpp>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion include/gamecoe/entity/component_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <vector>
#include <optional>
#include <functional>
#include <cstdint>
#include <cassert>

namespace gamecoe
Expand Down
8 changes: 4 additions & 4 deletions include/gamecoe/entity/entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ namespace gamecoe

bool valid() const noexcept { return *this != invalid(); }

std::uint32_t id() const noexcept { return m_value >> GEN_BITS; }
std::uint16_t generation() const noexcept { return m_value & GEN_MASK; }
std::uint32_t id() const noexcept { return m_handle >> GEN_BITS; }
std::uint16_t generation() const noexcept { return m_handle & GEN_MASK; }

private:
std::uint32_t m_value;
std::uint32_t m_handle;

explicit entity(std::uint32_t value) noexcept : m_value(value) { }
explicit constexpr entity(std::uint32_t value) noexcept : m_handle(value) { }
};
} // namespace gamecoe
Empty file.
Empty file removed include/gamecoe/graphics/mesh.hpp
Empty file.
Empty file.
24 changes: 12 additions & 12 deletions src/colorcoe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace gamecoe
return m_red == other.m_red && m_green == other.m_green && m_blue == other.m_blue && m_alpha == other.m_alpha;
}

bool Color::operator!=(const Color &other) const
bool Color::operator!=(const Color &other) const
{
return !(*this == other);
}
Expand All @@ -18,7 +18,7 @@ namespace gamecoe
std::uint8_t Color::green() const { return m_green; }

std::uint8_t Color::blue() const { return m_blue; }

std::uint8_t Color::alpha() const { return m_alpha; }

glm::vec4 Color::normalized() const
Expand Down Expand Up @@ -62,8 +62,8 @@ namespace gamecoe
};

std::uint8_t values[4] = { 0U, 0U, 0U, 255U };
int iterations = (hex.length() - 1) / 2; // 3 or 4
for(int i = 0; i < iterations; ++i)
std::size_t iterations = (hex.length() - 1) / 2; // 3 or 4
for(std::size_t i = 0; i < iterations; ++i)
{
char first = hex[(2 * i) + 1];
char second = hex[(2 * i) + 2];
Expand All @@ -79,15 +79,15 @@ namespace gamecoe
if (t < 0.0f) t = 0.0f;
else if (t > 1.0f) t = 1.0f;

int redDiff = b.m_red - a.m_red;
int greenDiff = b.m_green - a.m_green;
int blueDiff = b.m_blue - a.m_blue;
int alphaDiff = b.m_alpha - a.m_alpha;
std::int16_t redDiff = b.m_red - a.m_red;
std::int16_t greenDiff = b.m_green - a.m_green;
std::int16_t blueDiff = b.m_blue - a.m_blue;
std::int16_t alphaDiff = b.m_alpha - a.m_alpha;

return Color(a.m_red + (t * redDiff),
a.m_green + (t * greenDiff),
a.m_blue + (t * blueDiff),
a.m_alpha + (t * alphaDiff));
return Color(static_cast<std::uint8_t>(a.m_red + static_cast<std::int16_t>(t * redDiff)),
static_cast<std::uint8_t>(a.m_green + static_cast<std::int16_t>(t * greenDiff)),
static_cast<std::uint8_t>(a.m_blue + static_cast<std::int16_t>(t * blueDiff)),
static_cast<std::uint8_t>(a.m_alpha + static_cast<std::int16_t>(t * alphaDiff)));
}

} // namespace gamecoe
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed src/gamecoe/graphics/material.cpp
Empty file.
Empty file removed src/gamecoe/graphics/mesh.cpp
Empty file.
File renamed without changes.
Empty file removed src/gamecoe/graphics/sprite.cpp
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 4 additions & 5 deletions src/inputcoe.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <inputcoe.hpp>
#include <gamecoe/core/game.hpp>
#include <GLFW/glfw3.h>
#include <unordered_map>
#include <gamecoe_config.hpp>
Expand Down Expand Up @@ -96,14 +95,14 @@ namespace inputcoe
{
void mousePositionCallback(GLFWwindow *window, double xpos, double ypos)
{
g_currentMousePosition[0] = xpos;
g_currentMousePosition[1] = ypos;
g_currentMousePosition[0] = static_cast<float>(xpos);
g_currentMousePosition[1] = static_cast<float>(ypos);

int width, height;
glfwGetFramebufferSize(window, &width, &height);

g_currentMousePositionNormalized[0] = xpos / width;
g_currentMousePositionNormalized[1] = ypos / height;
g_currentMousePositionNormalized[0] = static_cast<float>(xpos) / width;
g_currentMousePositionNormalized[1] = static_cast<float>(ypos) / height;
}

void keyCallback([[maybe_unused]] GLFWwindow *window, int key, [[maybe_unused]] int scancode, int action, [[maybe_unused]] int mods)
Expand Down
2 changes: 1 addition & 1 deletion src/timecoe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace timecoe
{
void update()
{
float time = glfwGetTime();
float time = static_cast<float>(glfwGetTime());

if (g_lastFrameTime < 0.0f) g_lastFrameTime = time;

Expand Down
13 changes: 13 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
add_executable(gamecoe_tests
main.cpp
entity/entity_tests.cpp
entity/sparse_set_tests.cpp
entity/component_pool_tests.cpp
integration/ecs_integration_tests.cpp
)

target_link_libraries(gamecoe_tests
PRIVATE
gamecoe
testcoe
)
Loading
Loading