diff --git a/src/asset_manager.c b/src/asset_manager.c index 79f6c4f..1192bcc 100644 --- a/src/asset_manager.c +++ b/src/asset_manager.c @@ -279,17 +279,11 @@ texture_t *asset_manager_get_texture(asset_manager_t *asset_manager, const char int asset_manager_draw_texture(texture_t *texture, rect_t *src_rect, rect_t *dst_rect, bool flip) { - if(flip) - { - dst_rect->x = dst_rect->x + dst_rect->w; - dst_rect->w = -dst_rect->w; - } - frect_t src_frect, dst_frect; rect_to_frect(src_rect, &src_frect); rect_to_frect(dst_rect, &dst_frect); - if(!SDL_RenderTexture(renderer, texture, &src_frect, &dst_frect)) + if(!SDL_RenderTextureRotated(renderer, texture, &src_frect, &dst_frect, 0, NULL, flip)) { error_printf("Failed to copy texture to renderer : %s", SDL_GetError()); return EXIT_FAILURE; diff --git a/src/display.c b/src/display.c index 15a2e07..ef7281d 100644 --- a/src/display.c +++ b/src/display.c @@ -21,9 +21,26 @@ inline int display_init(void) return EXIT_FAILURE; } - if(!SDL_CreateWindowAndRenderer("2D_Engine", DISPLAY_WIDTH * RENDER_SCALE, DISPLAY_HEIGHT * RENDER_SCALE, SDL_WINDOW_RESIZABLE, &window, &renderer)) + window = SDL_CreateWindow("2D_Engine", DISPLAY_WIDTH * RENDER_SCALE, DISPLAY_HEIGHT * RENDER_SCALE, SDL_WINDOW_RESIZABLE); + if(!window) { - error_printf("Failed to create window or renderer : %s", SDL_GetError()); + error_printf("Failed to create window : %s", SDL_GetError()); + return EXIT_FAILURE; + } + + debug_printf("Listing available render drivers."); + const int NB_DRIVERS = SDL_GetNumRenderDrivers(); + for(int i = 0; i < NB_DRIVERS; i++) + debug_printf("%d : %s", i, SDL_GetRenderDriver(i)); + + const char *DRIVERS = "vulkan,gpu,software"; + + warning_printf("This build of 2D_Engine_C only support the following drivers : %s", DRIVERS); + + renderer = SDL_CreateRenderer(window, DRIVERS); + if(!renderer) + { + error_printf("Failed to create renderer : %s", SDL_GetError()); return EXIT_FAILURE; } diff --git a/src/headers/errors.h b/src/headers/errors.h index 5319d36..2e069a9 100644 --- a/src/headers/errors.h +++ b/src/headers/errors.h @@ -3,6 +3,7 @@ #include #include +#include #ifndef DEBUG #define DEBUG 0 @@ -19,6 +20,13 @@ #define debug_printf(...) do {} while (0) #endif +#define warning_printf(...) \ + do { \ + fprintf(stderr, "\033[35mWARNING\033[m: %s:%d:%s(): ", __FILE__, __LINE__, __func__); \ + fprintf(stderr, __VA_ARGS__); \ + fputc('\n', stderr); \ + } while (0) + #define error_printf(...) \ do { \ fprintf(stderr, "\033[31mERROR\033[m: %s:%d:%s(): ", __FILE__, __LINE__, __func__); \