Compare commits

...

2 Commits

Author SHA1 Message Date
Ulysse Cura 02b8c4aa06 Added more debug options. 2026-08-03 20:46:02 +02:00
Ulysse Cura 9d56e73896 Fixed launch.json. 2026-08-03 20:45:06 +02:00
7 changed files with 37 additions and 4 deletions

2
.ccls
View File

@ -7,4 +7,4 @@ gcc
# Macros
-DASSET_FILE_NAME="$(make print-ASSET_OUTPUT)"
-DDEBUG=1
-DDEBUG=2

2
.vscode/launch.json vendored
View File

@ -9,7 +9,7 @@
"type": "gdb",
"request": "launch",
"target": "${workspaceFolder}/build/2D_Engine",
"cwd": "${workspaceFolder}",
"cwd": "${workspaceFolder}/build",
"valuesFormatting": "parseText",
"preLaunchTask": "Build"
}

@ -1 +1 @@
Subproject commit 4dbee83e8d89c965714fc521fa324e237dd35129
Subproject commit 7f66cb41728fdea5e1f71b8a8f7212e54088f81c

View File

@ -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 \

View File

@ -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)

View File

@ -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

View File

@ -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;