Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion include/pyro/sdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define PYRO_SDL_H

#include "pyro/pyro.h"
#include <SDL2/SDL.h>
#include <SDL3/SDL.h>

namespace Pyro
{
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
31 changes: 17 additions & 14 deletions src/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions subprojects/sdl3.wrap
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion tests/test-runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "pyro/pyro.h"
#include "pyro/runner.h"
#include <SDL2/SDL_events.h>
#include <sdl3/SDL_events.h>

using namespace Pyro;

Expand Down
Loading