diff --git a/.ccls b/.ccls index b222101..b562f00 100644 --- a/.ccls +++ b/.ccls @@ -7,4 +7,4 @@ gcc # Macros -DASSET_FILE_NAME="$(make print-ASSET_OUTPUT)" --DDEBUG=1 +-DDEBUG=2 diff --git a/SDL3_Core b/SDL3_Core index 4dbee83..7f66cb4 160000 --- a/SDL3_Core +++ b/SDL3_Core @@ -1 +1 @@ -Subproject commit 4dbee83e8d89c965714fc521fa324e237dd35129 +Subproject commit 7f66cb41728fdea5e1f71b8a8f7212e54088f81c diff --git a/src/Makefile b/src/Makefile index 21504c9..2a5ddb9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,7 +11,7 @@ SRC_CC = gcc ifeq ($(RELEASE), 1) SRC_CFLAGS = --std=c17 --pedantic -O3 # RELEASE else -SRC_CFLAGS = --std=c17 --pedantic -O0 -g \ +SRC_CFLAGS = --std=c17 --pedantic -O0 -g -DDEBUG=2 \ -Wall -Wno-missing-braces -Wextra -Wno-missing-field-initializers \ -Wformat=2 -Wswitch-default -Wswitch-enum -Wcast-align \ -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 \ diff --git a/src/components/headers/components.def b/src/components/headers/components.def index d2830e6..d64173a 100644 --- a/src/components/headers/components.def +++ b/src/components/headers/components.def @@ -2,7 +2,12 @@ #define DRAW(PREFIX) PREFIX##_draw #define NO_DRAW(...) NULL +#if DEBUG >= 2 +COMPONENT(TRANSFORM_COMPONENT, transform_component, DRAW) +#else COMPONENT(TRANSFORM_COMPONENT, transform_component, NO_DRAW) +#endif // DEBUG >= 2 + COMPONENT(SPRITE_COMPONENT, sprite_component, DRAW) COMPONENT(ANIMATION_SYSTEM, animation_system, NO_DRAW) COMPONENT(PLAYER_SYSTEM, player_system, NO_DRAW) diff --git a/src/components/headers/transform_component.h b/src/components/headers/transform_component.h index 44fa9ff..f9c3c15 100644 --- a/src/components/headers/transform_component.h +++ b/src/components/headers/transform_component.h @@ -14,6 +14,10 @@ int transform_component_init(component_t *component); int transform_component_update(component_t *component); +#if DEBUG >= 2 +int transform_component_draw(component_t *component); +#endif + int transform_component_destroy(component_t *component); #endif // TRANSFORM_COMPONENT_H \ No newline at end of file diff --git a/src/components/transform_component.c b/src/components/transform_component.c index 4dde5c8..5cc4a3e 100644 --- a/src/components/transform_component.c +++ b/src/components/transform_component.c @@ -34,6 +34,30 @@ int transform_component_update(component_t *component) return EXIT_SUCCESS; } +#if DEBUG >= 2 +#include "display.h" +#include "errors.h" + +int transform_component_draw(component_t *component) +{ + transform_component_data_t *component_data = component->component_data; + + if(!SDL_SetRenderDrawColor(renderer, C_BLUE)) + { + error_printf("Failed to change renderer draw color : %s", SDL_GetError()); + return EXIT_FAILURE; + } + + if(!SDL_RenderRect(renderer, &component_data->bounds)) + { + error_printf("Failed to draw rectangle to renderer : %s", SDL_GetError()); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} +#endif // DEBUG >= 2 + inline int transform_component_destroy(component_t *component) { transform_component_data_t *component_data = component->component_data;