diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9dbd6c9..05bb9e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,14 +43,14 @@ jobs: echo "name=CC::gcc-${{ matrix.version }}" >> $GITHUB_ENV echo "name=CXX::g++-${{ matrix.version }}" >> $GITHUB_ENV - sudo apt-get install libfreetype-dev libcairo2 libcairo2-dev libsdl2-dev libpng-dev git-lfs libjpeg-turbo8-dev libeigen3-dev + sudo apt-get install libfreetype-dev libcairo2 libcairo2-dev libpng-dev git-lfs libjpeg-turbo8-dev libeigen3-dev libudev-dev libdbus-1-dev libpipewire-0.3-dev libwayland-client0 pip install meson ninja - name: Install dependencies (macOS) if: runner.os == 'macOS' run: | pip3 install meson ninja - brew install freetype libjpeg-turbo cairo libpng sdl2 pkg-config eigen + brew install freetype libjpeg-turbo cairo libpng sdl3 pkg-config eigen # ls -ls /Applications/ diff --git a/Makefile b/Makefile index 1a50f83..9323295 100644 --- a/Makefile +++ b/Makefile @@ -17,9 +17,9 @@ CXXFLAGS = -Wall -std=c++17 -I include -I subprojects/eigen-3.4.0 LDFLAGS = -L. -L./build/src LDLIBS = -lpyro -PYRO_CXXFLAGS := -g -Wall `pkg-config --cflags cairo sdl2` -std=c++17 -I include -fPIC +PYRO_CXXFLAGS := -g -Wall `pkg-config --cflags cairo sdl3` -std=c++17 -I include -fPIC PYRO_LDFLAGS = -shared -LIB := `pkg-config --libs cairo sdl2` -lfreeimage -lstdc++ +LIB := `pkg-config --libs cairo sdl3` -lfreeimage -lstdc++ # INC := -I include ifeq ($(OS), Windows_NT) diff --git a/include/pyro/sdl.h b/include/pyro/sdl.h index 640feda..19f3638 100644 --- a/include/pyro/sdl.h +++ b/include/pyro/sdl.h @@ -2,7 +2,7 @@ #define PYRO_SDL_H #include "pyro/pyro.h" -#include +#include namespace Pyro { diff --git a/meson.build b/meson.build index e229fd3..a3f435a 100644 --- a/meson.build +++ b/meson.build @@ -9,7 +9,7 @@ freetype_dep = dependency('freetype2') libjpeg_dep = dependency('libjpeg') libpng_dep = dependency('libpng') cairo_dep = dependency('cairo') -sdl_dep = dependency('sdl2') +sdl_dep = dependency('sdl3') eigen_dep = dependency('eigen3') eigen_dep = subproject('eigen').get_variable('eigen_dep') diff --git a/src/sdl.cpp b/src/sdl.cpp index a047d2c..98bbc92 100644 --- a/src/sdl.cpp +++ b/src/sdl.cpp @@ -20,7 +20,12 @@ namespace Pyro if (!headless) { - if (SDL_Init(SDL_INIT_VIDEO) != 0) + if (SDL_Init(SDL_INIT_VIDEO)) + { + std::cout << "SDL_init was okay" << std::endl; + ; + } + else { std::cout << "SDL_Init error: " << SDL_GetError() << std::endl; return 1; @@ -41,8 +46,6 @@ namespace Pyro int SDLRunner::open_window() { sdl_window = SDL_CreateWindow("Pyro", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, this->width, this->height, SDL_WINDOW_OPENGL); @@ -58,7 +61,7 @@ namespace Pyro int SDLRunner::create_renderer() { - sdl_renderer = SDL_CreateRenderer(sdl_window, -1, SDL_RENDERER_ACCELERATED); + sdl_renderer = SDL_CreateRenderer(sdl_window, NULL); if (sdl_renderer == nullptr) { SDL_DestroyWindow(sdl_window); @@ -91,22 +94,22 @@ namespace Pyro SDL_UpdateTexture(sdl_texture, NULL, pg->get_data(), this->width * sizeof(uint32_t)); SDL_Event e; SDL_RenderClear(sdl_renderer); - SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL); + SDL_RenderTexture(sdl_renderer, sdl_texture, NULL, NULL); SDL_RenderPresent(sdl_renderer); while (SDL_PollEvent(&e)) { switch (e.type) { - case SDL_QUIT: + case SDL_EVENT_QUIT: this->running = false; break; - case SDL_KEYDOWN: + case SDL_EVENT_KEY_DOWN: // std::cout << "Keydown" << std::endl; this->keypressed = true; - this->key = e.key.keysym.sym; - if (e.key.keysym.sym == SDLK_ESCAPE) + this->key = e.key.key; + if (e.key.mod == SDLK_ESCAPE) this->running = false; if (this->keypressed_cb != nullptr) @@ -115,23 +118,23 @@ namespace Pyro } break; - case SDL_KEYUP: + case SDL_EVENT_KEY_UP: // std::cout << "Keyup" << std::endl; this->keypressed = false; - this->key = e.key.keysym.sym; + this->key = e.key.key; break; - case SDL_MOUSEBUTTONDOWN: + case SDL_EVENT_MOUSE_BUTTON_DOWN: this->mousepressed = true; this->mousebutton = e.button.button; break; - case SDL_MOUSEBUTTONUP: + case SDL_EVENT_MOUSE_BUTTON_UP: this->mousepressed = false; this->mousebutton = e.button.button; break; - case SDL_MOUSEMOTION: + case SDL_EVENT_MOUSE_MOTION: pmousex = mousex; pmousey = mousey; mousex = e.motion.x; diff --git a/subprojects/sdl3.wrap b/subprojects/sdl3.wrap new file mode 100644 index 0000000..a45b447 --- /dev/null +++ b/subprojects/sdl3.wrap @@ -0,0 +1,13 @@ +[wrap-file] +directory = SDL3-3.2.4 +source_url = https://github.com/libsdl-org/SDL/releases/download/release-3.2.4/SDL3-3.2.4.tar.gz +source_filename = SDL3-3.2.4.tar.gz +source_hash = 2938328317301dfbe30176d79c251733aa5e7ec5c436c800b99ed4da7adcb0f0 +patch_filename = sdl3_3.2.4-3_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/sdl3_3.2.4-3/get_patch +patch_hash = e79c9a1683ac304f86a35b91bf15435eb5fc6663c28cf73bcc16bb90fe881ccb +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/sdl3_3.2.4-3/SDL3-3.2.4.tar.gz +wrapdb_version = 3.2.4-3 + +[provide] +sdl3 = sdl3_dep diff --git a/tests/meson.build b/tests/meson.build index 37b60f1..25e7b2d 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -17,7 +17,7 @@ catch2 = subproject('catch2', default_options: 'tests=false') testexe = executable('unit-tests', test_sources, include_directories: inc, link_with: pyro, - dependencies: [catch2.get_variable('catch2_with_main_dep'), eigen_dep], + dependencies: [catch2.get_variable('catch2_with_main_dep'), eigen_dep, sdl_dep], install: false) diff --git a/tests/test-runner.cpp b/tests/test-runner.cpp index 6b23b49..027f1ef 100644 --- a/tests/test-runner.cpp +++ b/tests/test-runner.cpp @@ -3,7 +3,7 @@ #include "pyro/pyro.h" #include "pyro/runner.h" -#include +#include using namespace Pyro;