sdl2 now working again I think, but with better cmake
This commit is contained in:
parent
c822075173
commit
3e15b6dfd0
16 changed files with 78 additions and 52 deletions
|
|
@ -31,6 +31,14 @@ set_property(CACHE ARCHEUS_STD_GRAPHICS_BACKEND PROPERTY STRINGS NONE SDL2 OPENG
|
|||
set(ARCHEUS_STD_FLAGS "")
|
||||
set(ARCHEUS_STD_LIBRARIES "")
|
||||
|
||||
set(ARCHEUS_STD_INCLUDE_DIRECTORIES
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
)
|
||||
|
||||
set(ARCHEUS_STD_LINK_LIBRARIES
|
||||
PUBLIC m
|
||||
)
|
||||
|
||||
# ~ ARCHEUS_SOURCES ~ #
|
||||
set(ARCHEUS_STD_SOURCES
|
||||
src/std/config.c
|
||||
|
|
@ -71,7 +79,7 @@ none_check_and_init_needed(ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ${ARCHEUS_STD_W
|
|||
|
||||
# ~ SDL2 ~ #
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/archeus_sdl2.cmake)
|
||||
sdl2_check_and_init_needed(ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ${ARCHEUS_STD_WINDOW_BACKEND} ${ARCHEUS_STD_INPUT_BACKEND} ${ARCHEUS_STD_GRAPHICS_BACKEND})
|
||||
sdl2_check_and_init_needed(ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ARCHEUS_STD_INCLUDE_DIRECTORIES ARCHEUS_STD_LINK_LIBRARIES ${ARCHEUS_STD_WINDOW_BACKEND} ${ARCHEUS_STD_INPUT_BACKEND} ${ARCHEUS_STD_GRAPHICS_BACKEND})
|
||||
|
||||
# ~ OPENGL ~ #
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/archeus_opengl.cmake)
|
||||
|
|
@ -93,13 +101,9 @@ else()
|
|||
add_library(archeus_std SHARED ${ARCHEUS_STD_SOURCES})
|
||||
endif()
|
||||
|
||||
target_include_directories(archeus_std
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
)
|
||||
target_include_directories(archeus_std ${ARCHEUS_STD_INCLUDE_DIRECTORIES})
|
||||
|
||||
target_link_libraries(archeus_std
|
||||
PUBLIC m
|
||||
)
|
||||
target_link_libraries(archeus_std ${ARCHEUS_STD_LINK_LIBRARIES})
|
||||
|
||||
install(TARGETS archeus_std EXPORT archeus_std_Exports
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
set(ARCHEUS_STD_SDL2_WINDOW_SOURCES
|
||||
src/graphics/sdl/window.c
|
||||
src/graphics/sdl/renderer.c
|
||||
)
|
||||
|
||||
set(ARCHEUS_STD_SDL2_INPUT_SOURCES
|
||||
|
|
@ -13,13 +14,12 @@ set(ARCHEUS_STD_SDL2_GRAPHICS_SOURCES
|
|||
src/graphics/sdl/line.c
|
||||
src/graphics/sdl/obround.c
|
||||
src/graphics/sdl/rectangle.c
|
||||
src/graphics/sdl/renderer.c
|
||||
src/graphics/sdl/sprite.c
|
||||
src/graphics/sdl/spritesheet.c
|
||||
src/graphics/sdl/text.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)
|
||||
function(sdl2_check_and_init_needed _ARCHEUS_STD_FLAGS _ARCHEUS_STD_SOURCES _ARCHEUS_STD_INCLUDE_DIRECTORIES _ARCHEUS_STD_LINK_LIBRARIES 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")
|
||||
return()
|
||||
|
|
@ -28,6 +28,16 @@ function(sdl2_check_and_init_needed ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ARCHEU
|
|||
#get needed libraries for backends
|
||||
find_package(SDL2 REQUIRED)
|
||||
|
||||
#add to include directories
|
||||
list(APPEND ${_ARCHEUS_STD_INCLUDE_DIRECTORIES}
|
||||
PRIVATE ${SDL2_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
#add to link libraries
|
||||
list(APPEND ${_ARCHEUS_STD_LINK_LIBRARIES}
|
||||
PUBLIC ${SDL2_LIBRARIES}
|
||||
)
|
||||
|
||||
#add matching files for the selected backends
|
||||
if(${ARCHEUS_STD_WINDOW_BACKEND} STREQUAL "SDL2")
|
||||
string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_SDL2_WINDOW ")
|
||||
|
|
@ -45,16 +55,21 @@ function(sdl2_check_and_init_needed ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ARCHEU
|
|||
|
||||
string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_SDL2_GRAPHICS ")
|
||||
list(APPEND ${_ARCHEUS_STD_SOURCES} ${ARCHEUS_STD_SDL2_GRAPHICS_SOURCES})
|
||||
|
||||
#add to include directories
|
||||
list(APPEND ${_ARCHEUS_STD_INCLUDE_DIRECTORIES}
|
||||
PRIVATE ${SDL2IMAGE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
#add to link libraries
|
||||
list(APPEND ${_ARCHEUS_STD_LINK_LIBRARIES}
|
||||
PUBLIC SDL2_image::SDL2_image
|
||||
PUBLIC SDL2_ttf::SDL2_ttf
|
||||
)
|
||||
endif()
|
||||
|
||||
set(${_ARCHEUS_STD_FLAGS} ${${_ARCHEUS_STD_FLAGS}} PARENT_SCOPE)
|
||||
set(${_ARCHEUS_STD_SOURCES} ${${_ARCHEUS_STD_SOURCES}} PARENT_SCOPE)
|
||||
|
||||
|
||||
# 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)
|
||||
set(${_ARCHEUS_STD_INCLUDE_DIRECTORIES} ${${_ARCHEUS_STD_INCLUDE_DIRECTORIES}} PARENT_SCOPE)
|
||||
set(${_ARCHEUS_STD_LINK_LIBRARIES} ${${_ARCHEUS_STD_LINK_LIBRARIES}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef ARC_SDL_SPRITESHEET_H_
|
||||
#define ARC_SDL_SPRITESHEET_H_
|
||||
|
||||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_GRAPHICS
|
||||
#include "arc/graphics/spritesheet.h"
|
||||
#include <SDL.h>
|
||||
|
||||
|
|
@ -10,6 +10,6 @@ struct ARC_Spritesheet {
|
|||
uint32_t *size;
|
||||
};
|
||||
|
||||
#endif // !ARC_SDL
|
||||
#endif // !ARC_SDL2_GRPAHCIS
|
||||
|
||||
#endif // !ARC_SDL_SPRITESHEET_H_
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "arc/graphics/color.h"
|
||||
#include "arc/math/rectangle.h"
|
||||
|
||||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_GRAPHICS
|
||||
#include <SDL.h>
|
||||
|
||||
typedef struct ARC_Text {
|
||||
|
|
@ -18,6 +18,6 @@ typedef struct ARC_Text {
|
|||
ARC_Rect bounds;
|
||||
} ARC_Text;
|
||||
|
||||
#endif // !ARC_SDL
|
||||
#endif // !ARC_SDL2_Graphics
|
||||
|
||||
#endif // !ARC_SDL_TEXT_H_
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef ARC_SDL_WINDOW_H_
|
||||
#define ARC_SDL_WINDOW_H_
|
||||
|
||||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_GRAPHICS
|
||||
#include "arc/graphics/window.h"
|
||||
#include <SDL.h>
|
||||
|
||||
|
|
@ -21,6 +21,6 @@ struct ARC_WindowInfo {
|
|||
Uint32 flags;
|
||||
};
|
||||
|
||||
#endif // !ARC_SDL
|
||||
#endif // !ARC_SDL2_GRAPHICS
|
||||
|
||||
#endif // !ARC_SDL_WINDOW_H_
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_GRAPHICS
|
||||
#include "arc/graphics/circle.h"
|
||||
#include "arc/graphics/sdl/renderer.h"
|
||||
#include <stdlib.h>
|
||||
|
|
@ -49,4 +49,4 @@ void ARC_Circle_RenderFill(ARC_Circle *circle, ARC_Renderer *renderer, ARC_Color
|
|||
}
|
||||
}
|
||||
|
||||
#endif // ARC_SDL
|
||||
#endif // ARC_SDL2_GRAPHICS
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_GRAPHICS
|
||||
#include "arc/graphics/config.h"
|
||||
|
||||
#include <SDL_image.h>
|
||||
|
|
@ -71,7 +71,7 @@ uint8_t ARC_SDL_Texture_Read(ARC_Config* config, ARC_String *string, void **valu
|
|||
}
|
||||
|
||||
ARC_String *tempStr, *textureStr;
|
||||
ARC_String_StripEndsWhitespace(string, &tempStr);
|
||||
ARC_String_StripEndsWhitespace(&tempStr, string);
|
||||
|
||||
ARC_String_CopySubstring(&textureStr, tempStr, 1, tempStr->length - 2);
|
||||
ARC_String_Destroy(tempStr);
|
||||
|
|
@ -86,7 +86,7 @@ void ARC_Spritesheet_ReadTexture(ARC_Config *config, ARC_String *string, uint32_
|
|||
SDL_Texture *texture;
|
||||
|
||||
ARC_String *tempStr, *textureStr;
|
||||
ARC_String_StripEndsWhitespace(string, &tempStr);
|
||||
ARC_String_StripEndsWhitespace(&tempStr, string);
|
||||
|
||||
//check for reference
|
||||
ARC_Config_Get(config, tempStr, (void **)&texture);
|
||||
|
|
@ -125,11 +125,11 @@ uint8_t ARC_Spritesheet_Read(ARC_Config* config, ARC_String *string, void **valu
|
|||
|
||||
ARC_String *temp, *textureStr, *sizeStr;
|
||||
ARC_String_CopySubstring(&temp, string, 1, split - 2);
|
||||
ARC_String_StripEndsWhitespace(temp, &textureStr);
|
||||
ARC_String_StripEndsWhitespace(&textureStr, temp);
|
||||
ARC_String_Destroy(temp);
|
||||
|
||||
ARC_String_CopySubstring(&temp, string, split + 1, string->length - (split + 1));
|
||||
ARC_String_StripEndsWhitespace(temp, &sizeStr);
|
||||
ARC_String_StripEndsWhitespace(&sizeStr, temp);
|
||||
ARC_String_Destroy(temp);
|
||||
|
||||
uint32_t *size;
|
||||
|
|
@ -169,11 +169,11 @@ uint8_t ARC_Sprite_Read(ARC_Config* config, ARC_String *string, void **value){
|
|||
|
||||
ARC_String *temp, *spritesheetStr, *framesStr;
|
||||
ARC_String_CopySubstring(&temp, string, 1, split - 2);
|
||||
ARC_String_StripEndsWhitespace(temp, &spritesheetStr);
|
||||
ARC_String_StripEndsWhitespace(&spritesheetStr, temp);
|
||||
ARC_String_Destroy(temp);
|
||||
|
||||
ARC_String_CopySubstring(&temp, string, split + 1, string->length - (split + 2));
|
||||
ARC_String_StripEndsWhitespace(temp, &framesStr);
|
||||
ARC_String_StripEndsWhitespace(&framesStr, temp);
|
||||
ARC_String_Destroy(temp);
|
||||
|
||||
//spritesheet
|
||||
|
|
@ -253,11 +253,11 @@ void ARC_Spritesheet_Delete(ARC_Config* config, ARC_String *string, void *value)
|
|||
//check if texture and size are references
|
||||
ARC_String *tempStr, *textureStr, *sizeStr;
|
||||
ARC_String_CopySubstring(&tempStr, string, 1, split - 1);
|
||||
ARC_String_StripEndsWhitespace(tempStr, &textureStr);
|
||||
ARC_String_StripEndsWhitespace(&textureStr, tempStr);
|
||||
ARC_String_Destroy(tempStr);
|
||||
|
||||
ARC_String_CopySubstring(&tempStr, string, split + 1, string->length - (split + 1));
|
||||
ARC_String_StripEndsWhitespace(tempStr, &sizeStr);
|
||||
ARC_String_StripEndsWhitespace(&sizeStr, tempStr);
|
||||
ARC_String_Destroy(tempStr);
|
||||
|
||||
ARC_Config_Get(config, sizeStr, (void **)&temp);
|
||||
|
|
@ -289,11 +289,11 @@ void ARC_Sprite_Delete(ARC_Config* config, ARC_String *string, void *value){
|
|||
//check if texture and size are references
|
||||
ARC_String *tempStr, *spritesheetStr, *framesStr;
|
||||
ARC_String_CopySubstring(&tempStr, string, 1, split - 1);
|
||||
ARC_String_StripEndsWhitespace(tempStr, &spritesheetStr);
|
||||
ARC_String_StripEndsWhitespace(&spritesheetStr, tempStr);
|
||||
ARC_String_Destroy(tempStr);
|
||||
|
||||
ARC_String_CopySubstring(&tempStr, string, split + 1, string->length - (split + 1));
|
||||
ARC_String_StripEndsWhitespace(tempStr, &framesStr);
|
||||
ARC_String_StripEndsWhitespace(&framesStr, tempStr);
|
||||
ARC_String_Destroy(tempStr);
|
||||
|
||||
ARC_Config_Get(config, spritesheetStr, (void **)&temp);
|
||||
|
|
@ -311,4 +311,4 @@ void ARC_Sprite_Delete(ARC_Config* config, ARC_String *string, void *value){
|
|||
free(spriteValue);
|
||||
}
|
||||
|
||||
#endif //ARC_SDL
|
||||
#endif //ARC_SDL2_GRAPHICS
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_GRAPHICS
|
||||
#include "arc/graphics/line.h"
|
||||
#include "arc/graphics/sdl/renderer.h"
|
||||
#include <stdlib.h>
|
||||
|
|
@ -8,4 +8,4 @@ void ARC_Line_Render(int32_t *x1, int32_t *y1, int32_t *x2, int32_t *y2, ARC_Ren
|
|||
SDL_RenderDrawLine((SDL_Renderer *)renderer, *x1, *y1, *x2, *y2);
|
||||
}
|
||||
|
||||
#endif // ARC_SDL
|
||||
#endif // ARC_SDL2_GRAPHCIS
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_GRAPHICS
|
||||
#include "arc/graphics/obround.h"
|
||||
#include "arc/graphics/sdl/renderer.h"
|
||||
#include <stdlib.h>
|
||||
|
|
@ -48,4 +48,4 @@ void ARC_FObround_Render(ARC_FObround *obround, ARC_Renderer *renderer, ARC_Colo
|
|||
ARC_Obround_Render(&casted, renderer, color);
|
||||
}
|
||||
|
||||
#endif // ARC_SDL
|
||||
#endif // ARC_SDL2_GRAPHICS
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_GRAPHICS
|
||||
#include "arc/graphics/rectangle.h"
|
||||
#include "arc/graphics/sdl/renderer.h"
|
||||
#include <stdlib.h>
|
||||
|
|
@ -23,4 +23,4 @@ void ARC_FRect_RenderFill(ARC_FRect *rect, ARC_Renderer *renderer, ARC_Color *co
|
|||
ARC_Rect_RenderFill(&casted, renderer, color);
|
||||
}
|
||||
|
||||
#endif // ARC_SDL
|
||||
#endif // ARC_SDL2_GRAPHICS
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_WINDOW
|
||||
#include "arc/graphics/renderer.h"
|
||||
#include "arc/graphics/sdl/renderer.h"
|
||||
|
||||
|
|
@ -38,4 +38,4 @@ void ARC_Renderer_Render(ARC_Renderer *renderer){
|
|||
SDL_RenderPresent((SDL_Renderer *)renderer);
|
||||
}
|
||||
|
||||
#endif //ARC_SDL
|
||||
#endif //ARC_SDL2_WINDOW
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_GRAPHICS
|
||||
#include "arc/graphics/sprite.h"
|
||||
#include "arc/graphics/sdl/sprite.h"
|
||||
#include "arc/graphics/sdl/spritesheet.h"
|
||||
|
|
@ -89,4 +89,4 @@ ARC_Array *ARC_Sprite_GetAllBounds(ARC_Sprite *sprite){
|
|||
return sprite->frames;
|
||||
}
|
||||
|
||||
#endif // ARC_SDL
|
||||
#endif // ARC_SDL2_GRAPHICS
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_GRAPHICS
|
||||
#include "arc/graphics/spritesheet.h"
|
||||
#include "arc/graphics/sdl/spritesheet.h"
|
||||
#include "arc/graphics/sdl/renderer.h"
|
||||
|
|
@ -18,4 +18,5 @@ ARC_Point ARC_Spritesheet_GetSize(ARC_Spritesheet *spritesheet){
|
|||
uint32_t *ARC_Spritesheet_GetTileSize(ARC_Spritesheet *spritesheet){
|
||||
return spritesheet->size;
|
||||
}
|
||||
#endif //ARC_SDL
|
||||
|
||||
#endif //ARC_SDL2_GRAPHICS
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
#ifdef ARC_SDL2_GRAPHICS
|
||||
#include "arc/graphics/text.h"
|
||||
#include "arc/graphics/sdl/text.h"
|
||||
#include "arc/graphics/color.h"
|
||||
|
|
@ -53,4 +54,6 @@ void ARC_Text_Render(ARC_Text *text, ARC_Renderer *renderer){
|
|||
void ARC_Text_SetPos(ARC_Text *text, ARC_Point pos){
|
||||
text->bounds.x = pos.x;
|
||||
text->bounds.y = pos.y;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //ARC_SDL2_GRAPHICS
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
#ifdef ARC_SDL2_GRAPHICS
|
||||
#include "arc/graphics/view.h"
|
||||
|
||||
#include "arc/std/errno.h"
|
||||
|
|
@ -33,3 +34,5 @@ void ARC_View_Render(ARC_View *view, ARC_View_RenderFn renderFn, void *data){
|
|||
ARC_Rect ARC_View_GetBounds(ARC_View *view){
|
||||
return view->bounds;
|
||||
}
|
||||
|
||||
#endif //ARC_SDL2_GRAPHICS
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_WINDOW
|
||||
#include "arc/graphics/window.h"
|
||||
#include "arc/graphics/sdl/window.h"
|
||||
|
||||
|
|
@ -31,4 +31,4 @@ void ARC_Window_Destroy(ARC_Window *window){
|
|||
SDL_DestroyWindow((SDL_Window *) window);
|
||||
}
|
||||
|
||||
#endif //ARC_SDL
|
||||
#endif //ARC_SDL2_WINDOW
|
||||
Loading…
Add table
Add a link
Reference in a new issue