From b0a3ba8407842413cc00d63672217e5f76fff9f5 Mon Sep 17 00:00:00 2001 From: herbglitch Date: Thu, 8 Feb 2024 16:53:31 -0700 Subject: [PATCH] merging herglitch/main --- cmake/archeus_sdl2.cmake | 50 +++++++++++++---------------- include/arc/graphics/sdl/renderer.h | 4 +-- include/arc/graphics/sdl/sprite.h | 4 +-- include/arc/input/sdl/keyboard.h | 4 +-- include/arc/input/sdl/mouse.h | 4 +-- src/engine/engine.c | 5 +-- src/input/sdl/keyboard.c | 5 ++- src/input/sdl/mouse.c | 4 +-- 8 files changed, 36 insertions(+), 44 deletions(-) diff --git a/cmake/archeus_sdl2.cmake b/cmake/archeus_sdl2.cmake index fbdfe9b..f5b076d 100644 --- a/cmake/archeus_sdl2.cmake +++ b/cmake/archeus_sdl2.cmake @@ -1,4 +1,5 @@ set(ARCHEUS_STD_SDL2_WINDOW_SOURCES + src/graphics/sdl/window.c ) set(ARCHEUS_STD_SDL2_INPUT_SOURCES @@ -16,49 +17,44 @@ set(ARCHEUS_STD_SDL2_GRAPHICS_SOURCES src/graphics/sdl/sprite.c src/graphics/sdl/spritesheet.c src/graphics/sdl/text.c - src/graphics/sdl/window.c ) function(sdl2_check_and_init_needed ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ARCHEUS_STD_WINDOW_BACKEND ARCHEUS_STD_INPUT_BACKEND ARCHEUS_STD_GRAPHICS_BACKEND) #if no backend uses sdl return - if(NOT ARCHEUS_STD_WINDOW_BACKEND STREQUAL "SDL2" AND NOT ARCHEUS_STD_INPUT_BACKEND STREQUAL "SDL2" AND NOT ARCHEUS_STD_GRAPHICS_BACKEND STREQUAL "SDL2") + if(NOT ${ARCHEUS_STD_WINDOW_BACKEND} STREQUAL "SDL2" AND NOT ${ARCHEUS_STD_INPUT_BACKEND} STREQUAL "SDL2" AND NOT ${ARCHEUS_STD_GRAPHICS_BACKEND} STREQUAL "SDL2") return() endif() - string(APPEND ARCHEUS_STD_FLAGS "-DARC_SDL ") - #get needed libraries for backends find_package(SDL2 REQUIRED) - if(ARCHEUS_STD_GRAPHICS_BACKEND STREQUAL "SDL2") - if(NOT PNG AND WIN32 AND NOT MSVC) - set(PNG_LIBRARY "C:/Program Files(x86)/libpng") - set(PNG_PNG_INCLUDE_DIR "C:/Program Files(x86)/libpng/include") - endif() + #add matching files for the selected backends + if(${ARCHEUS_STD_WINDOW_BACKEND} STREQUAL "SDL2") + string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_SDL2_WINDOW ") + list(APPEND ${_ARCHEUS_STD_SOURCES} ${ARCHEUS_STD_SDL2_WINDOW_SOURCES}) + endif() + if(${ARCHEUS_STD_INPUT_BACKEND} STREQUAL "SDL2") + string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_SDL2_INPUT ") + list(APPEND ${_ARCHEUS_STD_SOURCES} ${ARCHEUS_STD_SDL2_INPUT_SOURCES}) + endif() + + if(${ARCHEUS_STD_GRAPHICS_BACKEND} STREQUAL "SDL2") find_package(SDL2_image REQUIRED) find_package(SDL2_ttf REQUIRED) + + string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_SDL2_GRAPHICS ") + list(APPEND ${_ARCHEUS_STD_SOURCES} ${ARCHEUS_STD_SDL2_GRAPHICS_SOURCES}) endif() - #add matching files for the selected backends - if(ARCHEUS_STD_INPUT_BACKEND STREQUAL "SDL2") - list(APPEND ARCHEUS_STD_SOURCES ${ARCHEUS_STD_SDL2_INPUT_SOURCES}) - endif() + set(${_ARCHEUS_STD_FLAGS} ${${_ARCHEUS_STD_FLAGS}} PARENT_SCOPE) + set(${_ARCHEUS_STD_SOURCES} ${${_ARCHEUS_STD_SOURCES}} PARENT_SCOPE) - if(ARCHEUS_STD_INPUT_BACKEND STREQUAL "SDL2") - list(APPEND ARCHEUS_STD_SOURCES ${ARCHEUS_STD_SDL2_INPUT_SOURCES}) - endif() - if(ARCHEUS_STD_GRAPHICS_BACKEND STREQUAL "SDL2") - list(APPEND ARCHEUS_STD_SOURCES ${ARCHEUS_STD_SDL2_GRAPHICS_SOURCES}) - endif() + # target_include_directories(archeus_std + # PRIVATE ${SDL2_INCLUDE_DIRS} + # PRIVATE ${SDL2IMAGE_INCLUDE_DIRS} + # ) - target_include_directories(archeus_std - PRIVATE ${SDL2_INCLUDE_DIRS} - PRIVATE ${SDL2IMAGE_INCLUDE_DIRS} - ) - - target_link_libraries(archeus_std PUBLIC ${SDL2_LIBRARIES} SDL2_image::SDL2_image SDL2_ttf::SDL2_ttf) - - return(ARCHEUS_STD_SDL2_SOURCES) + # target_link_libraries(archeus_std PUBLIC ${SDL2_LIBRARIES} SDL2_image::SDL2_image SDL2_ttf::SDL2_ttf) endfunction() \ No newline at end of file diff --git a/include/arc/graphics/sdl/renderer.h b/include/arc/graphics/sdl/renderer.h index 14d967f..3ee8e8d 100644 --- a/include/arc/graphics/sdl/renderer.h +++ b/include/arc/graphics/sdl/renderer.h @@ -1,7 +1,7 @@ #ifndef ARC_SDL_RENDERER_H_ #define ARC_SDL_RENDERER_H_ -#ifdef ARC_SDL +#ifdef ARC_SDL2_GRAPHICS #include "arc/graphics/renderer.h" #include "arc/graphics/window.h" #include @@ -20,6 +20,6 @@ struct ARC_RenderInfo { Uint32 flags; }; -#endif // !ARC_SDL +#endif // !ARC_SDL2_GRAPHICS #endif // !ARC_SDL_RENDERER_H_ diff --git a/include/arc/graphics/sdl/sprite.h b/include/arc/graphics/sdl/sprite.h index 6e7cb59..a181bb6 100644 --- a/include/arc/graphics/sdl/sprite.h +++ b/include/arc/graphics/sdl/sprite.h @@ -1,7 +1,7 @@ #ifndef ARC_SDL_SPRITE_H_ #define ARC_SDL_SPRITE_H_ -#ifdef ARC_SDL +#ifdef ARC_SDL2_GRAPHICS #include "arc/graphics/sprite.h" #include @@ -13,6 +13,6 @@ struct ARC_Sprite { uint8_t opacity; }; -#endif // !ARC_SDL +#endif // !ARC_SDL2_GRAPHICS #endif // !ARC_SDL_SPRITE_H_ diff --git a/include/arc/input/sdl/keyboard.h b/include/arc/input/sdl/keyboard.h index 74a88f8..0003aea 100644 --- a/include/arc/input/sdl/keyboard.h +++ b/include/arc/input/sdl/keyboard.h @@ -1,7 +1,7 @@ #ifndef ARC_SDL_KEYBOARD_H_ #define ARC_SDL_KEYBOARD_H_ -#ifdef ARC_SDL +#ifdef ARC_SDL2_INPUT #include "arc/input/keyboard.h" #include @@ -16,6 +16,6 @@ struct ARC_KeyboardInfo { SDL_Event *event; }; -#endif // ARC_SDL +#endif // ARC_SDL2_INPUT #endif // !ARC_SDL_KEYBOARD_H_ \ No newline at end of file diff --git a/include/arc/input/sdl/mouse.h b/include/arc/input/sdl/mouse.h index 0f1e971..d534946 100644 --- a/include/arc/input/sdl/mouse.h +++ b/include/arc/input/sdl/mouse.h @@ -1,7 +1,7 @@ #ifndef ARC_SDL_MOUSE_H_ #define ARC_SDL_MOUSE_H_ -#ifdef ARC_SDL +#ifdef ARC_SDL2_INPUT #include #include "arc/input/mouse.h" #include "arc/math/point.h" @@ -19,6 +19,6 @@ struct ARC_MouseInfo { SDL_Event *event; }; -#endif // ARC_SDL +#endif // ARC_SDL2_INPUT #endif // !ARC_SDL_MOUSE_H_ \ No newline at end of file diff --git a/src/engine/engine.c b/src/engine/engine.c index 558f07c..591524f 100644 --- a/src/engine/engine.c +++ b/src/engine/engine.c @@ -14,14 +14,11 @@ #include "arc/input/none/mouse.h" #include "arc/input/none/keyboard.h" -#ifdef ARC_SDL #include "arc/graphics/sdl/window.h" #include "arc/graphics/sdl/renderer.h" #include "arc/input/sdl/mouse.h" #include "arc/input/sdl/keyboard.h" -#include -#include -#include +#ifdef ARC_SDL #elif ARC_OPENGL #include "arc/graphics/opengl/window.h" #include "arc/graphics/opengl/renderer.h" diff --git a/src/input/sdl/keyboard.c b/src/input/sdl/keyboard.c index a827536..6231577 100644 --- a/src/input/sdl/keyboard.c +++ b/src/input/sdl/keyboard.c @@ -1,5 +1,4 @@ -#include "SDL_keycode.h" -#ifdef ARC_SDL +#ifdef ARC_SDL2_INPUT #include "arc/input/sdl/keyboard.h" #include "arc/input/keyboard.h" #include "arc/math/point.h" @@ -99,4 +98,4 @@ ARC_KeyboardState ARC_Keyboard_GetState(ARC_Keyboard *keyboard, enum ARC_Keyboar } -#endif // ARC_SDL \ No newline at end of file +#endif // ARC_SDL2_INPUT \ No newline at end of file diff --git a/src/input/sdl/mouse.c b/src/input/sdl/mouse.c index 230b053..3a983e1 100644 --- a/src/input/sdl/mouse.c +++ b/src/input/sdl/mouse.c @@ -1,4 +1,4 @@ -#ifdef ARC_SDL +#ifdef ARC_SDL2_INPUT #include "arc/input/sdl/mouse.h" #include "arc/input/mouse.h" #include "arc/math/point.h" @@ -105,4 +105,4 @@ int32_t *ARC_Mouse_GetScrollY(ARC_Mouse *mouse){ return mouse->scrollY; } -#endif // ARC_SDL \ No newline at end of file +#endif // ARC_SDL2_INPUT \ No newline at end of file