From 0fc9eb828c0236d759698186dcbdefb2370e61b7 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 14 Oct 2024 17:49:20 +0200 Subject: upgrade SDL2 -> SDL3 --- CMakeLists.txt | 4 ++-- View.cpp | 20 +++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 681aae6..7aa3fd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_EXPORT_COMPILE_COMMANDS 1) set(CMAKE_BUILD_TYPE Debug) -find_package(SDL2 REQUIRED) +find_package(SDL3 REQUIRED) find_package(cpr REQUIRED) find_package(pugixml REQUIRED) # add_subdirectory(lib/SDL) @@ -45,7 +45,7 @@ add_executable(main ) target_link_libraries(main - SDL2 + SDL3 cpr pugixml ) diff --git a/View.cpp b/View.cpp index c269643..fd80b79 100644 --- a/View.cpp +++ b/View.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include "View.h" @@ -22,7 +22,7 @@ void View::work() { while (this->open) { for (SDL_Event e; SDL_PollEvent(&e);) { - if (e.type == SDL_QUIT) { + if (e.type == SDL_EVENT_QUIT) { this->open = false; return; } @@ -40,13 +40,11 @@ void View::window_init() { SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS); this->window = SDL_CreateWindow( "dpa", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, this->width, this->height, - SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL + SDL_WINDOW_OPENGL ); - this->renderer = SDL_CreateRenderer(this->window, -1, SDL_RENDERER_ACCELERATED); + this->renderer = SDL_CreateRenderer(this->window, NULL); } void View::window_deinit() { @@ -81,11 +79,11 @@ void View::draw_end() { void View::draw_rect(Rectangle r, Color c) { SDL_SetRenderDrawColor(this->renderer, c.red, c.green, c.blue, 255); - SDL_Rect rect = { - .x = static_cast(r.x), - .y = static_cast(r.y), - .w = static_cast(r.width), - .h = static_cast(r.height), + SDL_FRect rect = { + .x = static_cast(r.x), + .y = static_cast(r.y), + .w = static_cast(r.width), + .h = static_cast(r.height), }; SDL_RenderFillRect(this->renderer, &rect); } -- cgit v1.2.3