From 01c26b9e1694b719381cd6e66b669275cc73b026 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Fri, 27 Aug 2021 20:30:53 -0700 Subject: [PATCH] Added additional settings to control assets prefix. --- CMakeLists.txt | 11 ++++++++--- config.h.in | 3 +++ include/dawn/file/asset.h | 3 --- src/file/asset.c | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a7a35d7..cd64f883 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,18 +26,20 @@ set(SETTING_GAME_NAME "DawnGame") set(SETTING_TARGET_WIN32 1) set(SETTING_TARGET_RG351 2) -set(SETTING_TARGET SETTING_TARGET_RG351) +set(SETTING_TARGET SETTING_TARGET_WIN32) # Win32 if(${SETTING_TARGET} EQUAL ${SETTING_TARGET_WIN32}) set(SETTING_PLATFORM SETTING_PLATFORM_GLFW) set(SETTING_PLATFORM_USE_GLAD 1) + set(SETTING_ASSET_PREFIX "../assets/") endif() # RG351 if(${SETTING_TARGET} EQUAL ${SETTING_TARGET_RG351}) set(SETTING_PLATFORM SETTING_PLATFORM_SDL) set(SETTING_PLATFORM_USE_GLAD 1) + set(SETTING_ASSET_PREFIX "assets/") endif() # Configuring @@ -129,9 +131,12 @@ target_link_libraries(${PROJECT_NAME} cglm) # OpenGL find_package(OpenGL REQUIRED) -target_link_libraries(${PROJECT_NAME} OpenGL::OpenGL) -message(WARNING ${OpenGL_OpenGL_FOUND}) +if(${SETTING_TARGET} EQUAL ${SETTING_TARGET_RG351}) + target_link_libraries(${PROJECT_NAME} OpenGL::OpenGL) +else() + target_link_libraries(${PROJECT_NAME} OpenGL::GL) +endif() # CMake diff --git a/config.h.in b/config.h.in index e875a3c9..2f9ce58b 100644 --- a/config.h.in +++ b/config.h.in @@ -19,6 +19,9 @@ #cmakedefine SETTING_PLATFORM_USE_GLAD @SETTING_PLATFORM_USE_GLAD@ +// Additional settings +#cmakedefine SETTING_ASSET_PREFIX "@SETTING_ASSET_PREFIX@" + // Game Settings #cmakedefine SETTING_GAME_POKER @SETTING_GAME_POKER@ #cmakedefine SETTING_GAME_DAWN @SETTING_GAME_DAWN@ diff --git a/include/dawn/file/asset.h b/include/dawn/file/asset.h index 4524abec..5ada4d5b 100644 --- a/include/dawn/file/asset.h +++ b/include/dawn/file/asset.h @@ -6,8 +6,5 @@ #pragma once #include "../libs.h" -/** Prefix of all asset load methods, may be customizable in future. */ -#define ASSET_PREFIX "assets/" - /** Definition of an asset ready to be buffered */ typedef FILE assetbuffer_t; \ No newline at end of file diff --git a/src/file/asset.c b/src/file/asset.c index caf44cc2..536cbdb2 100644 --- a/src/file/asset.c +++ b/src/file/asset.c @@ -35,14 +35,14 @@ char * assetStringLoad(char *assetName) { assetbuffer_t * assetBufferOpen(char *assetName) { // Get the directory based on the raw input by creating a new string. size_t lenAsset = strlen(assetName);// Get the length of asset - size_t lenPrefix = strlen(ASSET_PREFIX);// Get the length of the prefix + size_t lenPrefix = strlen(SETTING_ASSET_PREFIX);// Get the length of the prefix // Create str to house both the prefix and asset, and null terminator char *joined = malloc(lenAsset + lenPrefix + 1); if(joined == NULL) return NULL;// Mem okay? joined[0] = '\0';//Start at null - strcat(joined, ASSET_PREFIX);//Add prefix + strcat(joined, SETTING_ASSET_PREFIX);//Add prefix strcat(joined, assetName);//Add body printf("Opening up %s\n", joined);