Add DEBUG_ENGINE as compile definition instead of using build_config

This commit is contained in:
abdelrahman committed 2023-11-04 22:11:54 +00:00
1 parent 5c0f2702ae
commit b74f7c6e3a
10 files changed
+233 -104

No files matched your search

+13 -14
View File
@@ -22,14 +22,13 @@
#include "Window.h"
#include "aliases.h"
#include "constants.h"
#include "engine_build_config.h"
#include "reusable_ids.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#ifdef DEBUG_ENGINE
#if DEBUG_ENGINE
#include <stdio.h>
#endif /* DEBUG_ENGINE */
@@ -54,7 +53,7 @@ bool init_engine(const char *game_name, WindowSize window_size,
}
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
#ifdef DEBUG_ENGINE
#if DEBUG_ENGINE
printf("Failed to initialise SDL. Error: %s\n", SDL_GetError());
#endif /* DEBUG_ENGINE */
@@ -71,14 +70,14 @@ bool init_engine(const char *game_name, WindowSize window_size,
}
if ((IMG_Init(img_flags) & img_flags) != img_flags) {
#ifdef DEBUG_ENGINE
#if DEBUG_ENGINE
printf("Failed to initialise SDL_image. Error: %s\n", IMG_GetError());
#endif /* DEBUG_ENGINE */
initialisation_complete = false;
}
if (TTF_Init() < 0) {
#ifdef DEBUG_ENGINE
#if DEBUG_ENGINE
printf("Failed to initialise SDL_ttf. Error: %s\n", TTF_GetError());
#endif /* DEBUG_ENGINE */
initialisation_complete = false;
@@ -87,14 +86,14 @@ bool init_engine(const char *game_name, WindowSize window_size,
// We're only interested in initialising SDL_mixer with WAVE files, so no
// need to pass any flags
if (Mix_Init(0) != 0) {
#ifdef DEBUG_ENGINE
#if DEBUG_ENGINE
printf("Failed to initialise SDL_mixer. Error: %s\n", Mix_GetError());
#endif /* DEBUG_ENGINE */
initialisation_complete = false;
}
if (Mix_OpenAudio(48000, MIX_DEFAULT_FORMAT, 2, 2048) < 0) {
#ifdef DEBUG_ENGINE
#if DEBUG_ENGINE
printf("Failed to open audio device. Error: %s\n", Mix_GetError());
#endif /* DEBUG_ENGINE */
initialisation_complete = false;
@@ -102,7 +101,7 @@ bool init_engine(const char *game_name, WindowSize window_size,
if (audio_tracks > 0) {
if (Mix_AllocateChannels(audio_tracks) != audio_tracks) {
#ifdef DEBUG_ENGINE
#if DEBUG_ENGINE
printf("Failed to allocate the required tracks.\n");
#endif /* DEBUG_ENGINE */
initialisation_complete = false;
@@ -111,7 +110,7 @@ bool init_engine(const char *game_name, WindowSize window_size,
if (!init_window(&(GameEngine.window), game_name, window_size,
window_background_color, full_screen)) {
#ifdef DEBUG_ENGINE
#if DEBUG_ENGINE
printf("Failed to initialise window\n");
#endif /* DEBUG_ENGINE */
@@ -138,11 +137,11 @@ bool init_engine(const char *game_name, WindowSize window_size,
GameEngine.delta = 0.0f;
GameEngine.last_time = SDL_GetTicks64();
#ifdef DEBUG_ENGINE
#if DEBUG_ENGINE
GameEngine.delta = 1.0f / 60.0f;
#endif /* DEBUG_ENGINE */
#ifdef DEBUG_ENGINE
#if DEBUG_ENGINE
printf("Game initialised successfully\n");
#endif /* DEBUG_ENGINE */
@@ -176,7 +175,7 @@ void close_engine() {
SDL_Quit();
#ifdef DEBUG_ENGINE
#if DEBUG_ENGINE
printf("Game closed successfully\n");
#endif /* DEBUG_ENGINE */
}
@@ -210,8 +209,8 @@ void remove_object(ObjectID *id) {
AssetID load_asset(const char *path, AssetType type) {
return type == ASSET_TYPE_IMAGE
? load_asset_to_manager(GameEngine.asset_manager, path, type,
GameEngine.window.renderer)
: load_asset_to_manager(GameEngine.asset_manager, path, type,
GameEngine.window.renderer, NULL)
: load_asset_to_manager(GameEngine.asset_manager, path, type, NULL,
NULL);
}