diff --git a/.github/workflows/cmake-linux.yml b/.github/workflows/cmake-linux.yml new file mode 100644 index 0000000..66f82c3 --- /dev/null +++ b/.github/workflows/cmake-linux.yml @@ -0,0 +1,90 @@ +# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. +# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml +name: CMake on Linux + +on: + push: + branches: [ "**" ] + pull_request: + branches: [ "**" ] + +jobs: + build: + runs-on: ubuntu-latest + container: + image: archlinux:latest + options: --user root + + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + + # Set up a matrix to run the following 3 configurations: + # 1. + # 2. + # 3. + # + # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. + matrix: + build_type: [Debug, Release] + c_compiler: [gcc, clang] + include: + - c_compiler: gcc + cpp_compiler: g++ + - c_compiler: clang + cpp_compiler: clang++ + + steps: + - uses: actions/checkout@v4 + + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=$GITHUB_WORKSPACE/build" >> "$GITHUB_OUTPUT" + echo "install-dir=$GITHUB_WORKSPACE/install/archlinux-latest-${{ matrix.c_compiler }}-${{ matrix.build_type }}" >> "$GITHUB_OUTPUT" + + + - name: Install SDL windowing deps (Linux) + run: | + pacman -Syu --noconfirm + pacman -S --noconfirm --needed \ + base-devel cmake ninja pkgconf gcc clang git python3\ + alsa-lib jack libpulse \ + xorgproto libx11 libxext libxrandr libxcursor libxfixes libxi libxss libxtst \ + libxkbcommon wayland wayland-protocols \ + libdrm mesa mesa-utils + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S $GITHUB_WORKSPACE + -G "Ninja Multi-Config" + + - name: Build + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Test + working-directory: ${{ steps.strings.outputs.build-output-dir }} + # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest --build-config ${{ matrix.build_type }} + + - name: Install + run: > + cmake --install ${{ steps.strings.outputs.build-output-dir }} + --config ${{ matrix.build_type }} + --prefix "${{ steps.strings.outputs.install-dir }}" + + - name: Upload install folder + uses: actions/upload-artifact@v4 + with: + name: archlinux-latest-${{ matrix.c_compiler }}-${{ matrix.build_type }}-install-${{ github.sha }} + path: ${{ steps.strings.outputs.install-dir }}/ diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-windows.yml similarity index 92% rename from .github/workflows/cmake-multi-platform.yml rename to .github/workflows/cmake-windows.yml index 528139e..ec5e66b 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-windows.yml @@ -1,6 +1,6 @@ # This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. # See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml -name: CMake on multiple platforms +name: CMake on Windows on: push: @@ -23,28 +23,19 @@ jobs: # # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-latest, windows-latest] + os: [windows-latest] build_type: [Debug, Release] c_compiler: [gcc, clang, cl] include: - os: windows-latest c_compiler: cl cpp_compiler: cl - - os: ubuntu-latest - c_compiler: gcc - cpp_compiler: g++ - - os: ubuntu-latest - c_compiler: clang - cpp_compiler: clang++ - os: windows-latest c_compiler: gcc cpp_compiler: g++ - os: windows-latest c_compiler: clang cpp_compiler: clang++ - exclude: - - os: ubuntu-latest - c_compiler: cl steps: - uses: actions/checkout@v4 @@ -69,6 +60,7 @@ jobs: libxkbcommon-dev libwayland-dev wayland-protocols \ libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev \ libdbus-1-dev libudev-dev + - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. diff --git a/CMakeLists.txt b/CMakeLists.txt index ab0d20b..1923319 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.30) project(SDL_TEST LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) include(FetchContent) set(FETCHCONTENT_QUIET OFF CACHE BOOL "" FORCE) @@ -91,8 +92,11 @@ target_include_directories(imgui PUBLIC ) target_link_libraries(imgui PUBLIC SDL3::SDL3) +add_subdirectory(sdl_wrapper) + add_executable(SDL_TEST main.cpp) -target_link_libraries(SDL_TEST PRIVATE shaderc imgui) +target_link_libraries(SDL_TEST PRIVATE shaderc imgui sdl_wrapper) + include(GNUInstallDirs) install(TARGETS SDL_TEST diff --git a/main.cpp b/main.cpp index bf00519..3808de2 100644 --- a/main.cpp +++ b/main.cpp @@ -9,6 +9,8 @@ #include #include +import sdl_wrapper; + // the vertex input layout struct Vertex { float x, y, z; //vec3 position @@ -48,6 +50,8 @@ void main() FragColor = v_color; })WSQ"; +sopho::BufferWrapper BufferWrapper{}; + SDL_Window *window; SDL_GPUDevice *device; SDL_GPUBuffer *vertexBuffer; diff --git a/sdl_wrapper/CMakeLists.txt b/sdl_wrapper/CMakeLists.txt new file mode 100644 index 0000000..50badf6 --- /dev/null +++ b/sdl_wrapper/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.30) +project(sdl_wrapper LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 23) +add_library(sdl_wrapper STATIC) + +target_sources(sdl_wrapper + PUBLIC + FILE_SET cxx_modules TYPE CXX_MODULES FILES + ${CMAKE_CURRENT_SOURCE_DIR}/sdl_wrapper.ixx + ${CMAKE_CURRENT_SOURCE_DIR}/sdl_wrapper.buffer.ixx +) + +target_link_libraries(sdl_wrapper PUBLIC SDL3::SDL3) diff --git a/sdl_wrapper/sdl_wrapper.buffer.ixx b/sdl_wrapper/sdl_wrapper.buffer.ixx new file mode 100644 index 0000000..cb44360 --- /dev/null +++ b/sdl_wrapper/sdl_wrapper.buffer.ixx @@ -0,0 +1,13 @@ +// +// Created by sophomore on 11/8/25. +// + +export module sdl_wrapper:buffer; +#include "SDL3/SDL_gpu.h" + +namespace sopho { + export class BufferWrapper { + SDL_GPUBuffer *vertexBuffer{}; + + }; +} diff --git a/sdl_wrapper/sdl_wrapper.ixx b/sdl_wrapper/sdl_wrapper.ixx new file mode 100644 index 0000000..b57802a --- /dev/null +++ b/sdl_wrapper/sdl_wrapper.ixx @@ -0,0 +1,6 @@ +// +// Created by sophomore on 11/7/25. +// + +export module sdl_wrapper; +export import :buffer; \ No newline at end of file