Compare commits

..

2 Commits

Author SHA1 Message Date
Ulysse Cura f599b85b67 Fixed to build on Debian. 2026-09-23 18:46:59 +02:00
Ulysse Cura c737cf2f86 Moved back to microslop's c cpp extension... 2026-09-23 18:46:24 +02:00
19 changed files with 103 additions and 81 deletions

3
.ccls
View File

@ -1,3 +0,0 @@
gcc
# Macros
-DDEBUG=2

33
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,33 @@
{
"configurations": [
{
"name": "Linux",
"intelliSenseMode": "linux-gcc-arm",
"includePath": [
"${workspaceFolder}/src",
"${workspaceFolder}/src/components",
"${workspaceFolder}/core",
"${workspaceFolder}/core/host/generic",
"/usr/include/lua5.4",
"/usr/include/pipewire-0.3",
"/usr/include/spa-0.2",
"/usr/include/libdrm",
"/usr/include/libdecor-0",
"/usr/include/x86_64-linux-gnu"
],
"compilerPath": "/usr/bin/gcc",
"defines": [
"-D_REENTRANT"
],
"cStandard": "c17",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}

9
.vscode/launch.json vendored
View File

@ -4,14 +4,5 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{
"name": "Debug",
"type": "gdb",
"request": "launch",
"target": "${workspaceFolder}/build/linux/2D_Engine",
"cwd": "${workspaceFolder}/build/linux",
"valuesFormatting": "parseText",
"preLaunchTask": "Build"
}
] ]
} }

View File

@ -1,11 +1,7 @@
{ {
"nixEnvSelector.suggestion": false,
"nixEnvSelector.nixFile": "${workspaceFolder}/shell.nix",
"nixEnvSelector.useFlakes": false,
"files.associations": { "files.associations": {
"*.tsx": "xml", "*.tsx": "xml",
"*.map": "json", "*.map": "json",
"configure": "shellscript" "configure": "shellscript",
} }
} }

57
.vscode/tasks.json vendored
View File

@ -54,6 +54,25 @@
"clear": true "clear": true
} }
}, },
{
"label": "Run",
"detail": "Build project and run",
"type": "shell",
"command": "make",
"args": [
"-j$(nproc)",
"run"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
},
{ {
"label": "Build Verbose", "label": "Build Verbose",
"detail": "Build project with verbosity on", "detail": "Build project with verbosity on",
@ -72,6 +91,25 @@
"clear": true "clear": true
} }
}, },
{
"label": "Build Debug",
"detail": "Build project in debug mode",
"type": "shell",
"command": "make",
"args": [
"-j$(nproc)",
"DEBUG=2"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
},
{ {
"label": "Run Debug", "label": "Run Debug",
"detail": "Build project in debug mode and run", "detail": "Build project in debug mode and run",
@ -91,25 +129,6 @@
"showReuseMessage": true, "showReuseMessage": true,
"clear": true "clear": true
} }
},
{
"label": "Build Debug",
"detail": "Build project in debug mode",
"type": "shell",
"command": "make",
"args": [
"-j$(nproc)",
"DEBUG=2"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
} }
] ]
} }

View File

@ -34,6 +34,13 @@ TARGET_HOST_CFLAGS += -O1 -g -DDEBUG=$(DEBUG) -Wextra -Wall --pedantic -Wno-miss
-Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual \ -Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual \
-Wshadow -Wunreachable-code -Wlogical-op -Wfloat-equal -Wstrict-aliasing=2 \ -Wshadow -Wunreachable-code -Wlogical-op -Wfloat-equal -Wstrict-aliasing=2 \
-Wredundant-decls -Wold-style-definition -Wredundant-decls -Wold-style-definition
ASSET_BUILDER_CFLAGS += -O1 -g -DDEBUG=$(DEBUG) -Wextra -Wall --pedantic -Wno-missing-braces \
-Wno-missing-field-initializers -Wformat=2 -Wswitch-default -Wswitch \
-Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 \
-Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual \
-Wshadow -Wunreachable-code -Wlogical-op -Wfloat-equal -Wstrict-aliasing=2 \
-Wredundant-decls -Wold-style-definition
endif endif
# #
@ -85,5 +92,5 @@ clean-all:
run: all run: all
$(Q)cd $(BUILD_DIR) && ./$(notdir $(OUTPUT)) $(Q)cd $(BUILD_DIR) && ./$(notdir $(OUTPUT))
print-var-% : print-var-% :
@echo $($*) @echo $($*)

View File

@ -1,7 +0,0 @@
gcc
# Headers
-Iassets/asset_builder/src/headers
-Isrc/components
# Macros
-DDEBUG=2

View File

@ -17,14 +17,14 @@ endif
$(ASSET_BUILDER_OUTPUT): $(OBJECTS) $(ASSET_BUILDER_OUTPUT): $(OBJECTS)
$(Q)mkdir -p $(dir $@) $(Q)mkdir -p $(dir $@)
@echo -e "[100%] $(YELLOW)Linking $(notdir $(ASSET_BUILDER_OUTPUT))$(RESET)" @echo "[100%] $(YELLOW)Linking $(notdir $(ASSET_BUILDER_OUTPUT))$(RESET)"
$(Q)$(ASSET_BUILDER_CC) $(ASSET_BUILDER_CFLAGS) $(ASSET_BUILDER_LDFLAGS) $(OBJECTS) -o $@ $(Q)$(ASSET_BUILDER_CC) $(ASSET_BUILDER_CFLAGS) $(OBJECTS) -o $@ $(ASSET_BUILDER_LDFLAGS)
$(BUILD_DIR)/$(notdir $(ASSET_BUILDER_DIR))/%.o: $(ASSET_BUILDER_DIR)/% $(BUILD_DIR)/$(notdir $(ASSET_BUILDER_DIR))/%.o: $(ASSET_BUILDER_DIR)/%
$(Q)mkdir -p $(dir $@) $(Q)mkdir -p $(dir $@)
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE)+1)))) $(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE)+1))))
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE)*100/$(TOTAL_BUILD_FILES))))) $(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE)*100/$(TOTAL_BUILD_FILES)))))
@echo -e "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)" @echo "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)"
$(Q)$(ASSET_BUILDER_CC) $(ASSET_BUILDER_CFLAGS) $(INCLUDES:%=-I%) -MMD -MP -c $< -o $@ $(Q)$(ASSET_BUILDER_CC) $(ASSET_BUILDER_CFLAGS) $(INCLUDES:%=-I%) -MMD -MP -c $< -o $@
-include $(ASSET_BUILDER_OBJECTS:.o=.d) -include $(ASSET_BUILDER_OBJECTS:.o=.d)

View File

@ -19,14 +19,14 @@ TOTAL_BUILD_FILES := $(shell echo $$(($$($(MAKE) -n $(OBJECTS) TOTAL_BUILD_FILES
endif endif
$(ASSET_OUTPUT): $(OBJECTS) $(ASSET_BUILDER_OUTPUT) $(ASSET_OUTPUT): $(OBJECTS) $(ASSET_BUILDER_OUTPUT)
@echo -e "[100%] $(YELLOW)Building $(notdir $(ASSET_OUTPUT))$(RESET)" @echo "[100%] $(YELLOW)Building $(notdir $(ASSET_OUTPUT))$(RESET)"
$(Q)$(ASSET_BUILDER_OUTPUT) $@ $(OBJECTS) $(Q)$(ASSET_BUILDER_OUTPUT) $@ $(OBJECTS)
$(BUILD_DIR)/$(notdir $(ASSETS_DIR))/%.o: $(ASSETS_DIR)/% $(ASSET_BUILDER_OUTPUT) $(BUILD_DIR)/$(notdir $(ASSETS_DIR))/%.o: $(ASSETS_DIR)/% $(ASSET_BUILDER_OUTPUT)
$(Q)mkdir -p $(dir $@) $(Q)mkdir -p $(dir $@)
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1)))) $(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1))))
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES))))) $(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES)))))
@echo -e "[$(PERCENTAGE)%] $(GREEN)Building ASSET object $@$(RESET)" @echo "[$(PERCENTAGE)%] $(GREEN)Building ASSET object $@$(RESET)"
$(Q)$(ASSET_BUILDER_OUTPUT) $@ -c $< $(Q)$(ASSET_BUILDER_OUTPUT) $@ -c $<
$(ASSET_BUILDER_OUTPUT): FORCE $(ASSET_BUILDER_OUTPUT): FORCE

4
configure vendored
View File

@ -125,8 +125,8 @@ case "${TARGET_HOST}" in
TARGET_CC="gcc" TARGET_CC="gcc"
TARGET_AR="ar" TARGET_AR="ar"
TARGET_CFLAGS="--std=c17 -Os -DASSET_FILE_NAME=\\\"\$(notdir \$(ASSET_OUTPUT))\\\" -D_GNU_SOURCE=1 \$(shell pkg-config --cflags sdl3)" TARGET_CFLAGS="--std=c17 -Os -DASSET_FILE_NAME=\\\"\$(notdir \$(ASSET_OUTPUT))\\\" -D_GNU_SOURCE=1 \$(shell pkg-config --cflags sdl3 lua)"
TARGET_LDFLAGS="\$(shell pkg-config --libs sdl3) -lm" TARGET_LDFLAGS="\$(shell pkg-config --libs sdl3 lua) -lm"
TARGET_LIBCORE="libcore.a" TARGET_LIBCORE="libcore.a"
;; ;;

View File

@ -1,8 +0,0 @@
gcc
# Headers
-Icore
-Icore/host/generic
-Isrc/components
# Macros
-DASSET_FILE_NAME="$(make print-var-ASSET_OUTPUT)"

View File

@ -24,14 +24,14 @@ endif
$(LIBCORE): $(OBJECTS) $(LIBCORE): $(OBJECTS)
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1)))) $(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1))))
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES))))) $(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES)))))
@echo -e "[$(PERCENTAGE)%] $(YELLOW)Creating Static Lib $@$(RESET)" @echo "[$(PERCENTAGE)%] $(YELLOW)Creating Static Lib $@$(RESET)"
$(Q)$(TARGET_HOST_AR) rcs $@ $(OBJECTS) $(Q)$(TARGET_HOST_AR) rcs $@ $(OBJECTS)
$(BUILD_DIR)/$(notdir $(CORE_DIR))/%.o: $(CORE_DIR)/% $(BUILD_DIR)/$(notdir $(CORE_DIR))/%.o: $(CORE_DIR)/%
$(Q)mkdir -p $(dir $@) $(Q)mkdir -p $(dir $@)
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1)))) $(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1))))
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES))))) $(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES)))))
@echo -e "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)" @echo "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)"
$(Q)$(TARGET_HOST_CC) $(TARGET_HOST_CFLAGS) $(INCLUDES:%=-I%) -MMD -MP -c $< -o $@ $(Q)$(TARGET_HOST_CC) $(TARGET_HOST_CFLAGS) $(INCLUDES:%=-I%) -MMD -MP -c $< -o $@
-include $(OBJECTS:.o=.d) -include $(OBJECTS:.o=.d)

View File

@ -1,5 +0,0 @@
gcc
# Headers
-Icore
-Icore/host/linux
-Isrc/components

View File

@ -28,14 +28,19 @@ inline int display_init(void)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
#ifdef DRIVERS
debug_printf("Listing available render drivers."); debug_printf("Listing available render drivers.");
const int NB_DRIVERS = SDL_GetNumRenderDrivers(); const int NB_DRIVERS = SDL_GetNumRenderDrivers();
for(int i = 0; i < NB_DRIVERS; i++) for(int i = 0; i < NB_DRIVERS; i++)
debug_printf("%d : %s", i, SDL_GetRenderDriver(i)); debug_printf("%d : %s", i, SDL_GetRenderDriver(i));
if(DRIVERS) warning_printf("This build of 2D_Engine_C only support the following drivers : %s", DRIVERS); warning_printf("This build of 2D_Engine_C only support the following drivers : %s", DRIVERS);
game.display.renderer = SDL_CreateRenderer(game.display.window, DRIVERS); game.display.renderer = SDL_CreateRenderer(game.display.window, DRIVERS);
#else
game.display.renderer = SDL_CreateRenderer(game.display.window, NULL);
#endif // DRIVERS
if(!game.display.renderer) if(!game.display.renderer)
{ {
error_printf("Failed to create renderer : %s", SDL_GetError()); error_printf("Failed to create renderer : %s", SDL_GetError());
@ -53,13 +58,13 @@ inline int display_init(void)
error_printf("Failed to set renderer draw blend mode : %s", SDL_GetError()); error_printf("Failed to set renderer draw blend mode : %s", SDL_GetError());
return EXIT_FAILURE; return EXIT_FAILURE;
} }
/*
if(!SDL_SetDefaultTextureScaleMode(game.display.renderer, SDL_SCALEMODE_NEAREST)) if(!SDL_SetDefaultTextureScaleMode(game.display.renderer, SDL_SCALEMODE_NEAREST))
{ {
error_printf("Failed to set default texture scale mode : %s", SDL_GetError()); error_printf("Failed to set default texture scale mode : %s", SDL_GetError());
return EXIT_FAILURE; return EXIT_FAILURE;
} }
*/
debug_printf("Initialized display."); debug_printf("Initialized display.");
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -14,7 +14,6 @@
#define DISPLAY_WIDTH 720 #define DISPLAY_WIDTH 720
#define DISPLAY_HEIGHT 480 #define DISPLAY_HEIGHT 480
//#define DRIVERS NULL
#define DRIVERS "vulkan,gpu,software" #define DRIVERS "vulkan,gpu,software"
typedef struct display_t { typedef struct display_t {

View File

@ -1,5 +0,0 @@
gcc
# Headers
-Isrc/components
-Icore
-Icore/host/generic

View File

@ -23,14 +23,14 @@ TOTAL_BUILD_FILES := $(shell echo $$(($$($(MAKE) -n $(OBJECTS) TOTAL_BUILD_FILES
endif endif
$(OUTPUT): $(OBJECTS) $(LIBCORE) $(OUTPUT): $(OBJECTS) $(LIBCORE)
@echo -e "[100%] $(YELLOW)Linking $(notdir $(OUTPUT))$(RESET)" @echo "[100%] $(YELLOW)Linking $(notdir $(OUTPUT))$(RESET)"
$(Q)$(TARGET_HOST_CC) $(TARGET_HOST_CFLAGS) $(TARGET_HOST_LDFLAGS) $(OBJECTS) -L$(BUILD_DIR) -lcore -o $@ $(Q)$(TARGET_HOST_CC) $(TARGET_HOST_CFLAGS) $(OBJECTS) -o $@ -L$(BUILD_DIR) -lcore $(TARGET_HOST_LDFLAGS)
$(BUILD_DIR)/$(notdir $(SOURCE_DIR))/%.o: $(SOURCE_DIR)/% $(BUILD_DIR)/$(notdir $(SOURCE_DIR))/%.o: $(SOURCE_DIR)/%
$(Q)mkdir -p $(dir $@) $(Q)mkdir -p $(dir $@)
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1)))) $(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE) + 1))))
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES))))) $(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE) * 100 / $(TOTAL_BUILD_FILES)))))
@echo -e "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)" @echo "[$(PERCENTAGE)%] $(GREEN)Building C object $@$(RESET)"
$(Q)$(TARGET_HOST_CC) $(TARGET_HOST_CFLAGS) $(INCLUDES:%=-I%) -MMD -MP -c $< -o $@ $(Q)$(TARGET_HOST_CC) $(TARGET_HOST_CFLAGS) $(INCLUDES:%=-I%) -MMD -MP -c $< -o $@
$(LIBCORE): FORCE $(LIBCORE): FORCE

View File

@ -1,8 +1,8 @@
#ifndef LUA_COMPONENT_H #ifndef LUA_COMPONENT_H
#define LUA_COMPONENT_H #define LUA_COMPONENT_H
#include <lua.h>
#include "ecs.h" #include "ecs.h"
#include "lua.h"
#include "errors.h" #include "errors.h"
typedef struct lua_component_data_t { typedef struct lua_component_data_t {

View File

@ -118,15 +118,15 @@ int game_init(void)
if(!entity_new_component(player_entity, PLAYER_SYSTEM)) return_failure_int; if(!entity_new_component(player_entity, PLAYER_SYSTEM)) return_failure_int;
} }
/* ======== Enemy ======== */ /* ======== Enemy ======== */
/*
{ {
entity_t *enemy_entity = entity_manager_new_entity(1); entity_t *enemy_entity = entity_manager_new_entity(1);
if(!enemy_entity) return_failure_int; if(!enemy_entity) return_failure_int;
if(!entity_new_component(enemy_entity, LUA_COMPONENT)) return_failure_int; if(!entity_new_component(enemy_entity, LUA_COMPONENT)) return_failure_int;
} }
*/
game.is_running = true; game.is_running = true;
return EXIT_SUCCESS; return EXIT_SUCCESS;