Removed memory leak due to nvidia drivers...
This commit is contained in:
parent
54b15900b2
commit
ad5c3a8d44
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#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__); \
|
||||
|
|
|
|||
Loading…
Reference in New Issue