Compare commits

...

2 Commits

Author SHA1 Message Date
329925ea54 Asset 2025-08-23 17:43:22 -05:00
c8a3ebfcec FindSDL2 2025-08-23 15:53:08 -05:00
8 changed files with 211 additions and 1 deletions

View File

@@ -57,7 +57,7 @@ if(DUSK_TARGET_SYSTEM STREQUAL "linux")
find_package(SDL2 REQUIRED)
find_package(OpenGL REQUIRED)
target_link_libraries(${DUSK_TARGET_NAME} PRIVATE
SDL2::SDL2
SDL2
OpenGL::GL
GL
)

View File

@@ -0,0 +1,42 @@
# Try to find SDL2 in common locations
find_path(SDL2_INCLUDE_DIR SDL.h
PATHS
/usr/include/SDL2
/usr/local/include/SDL2
$ENV{SDL2_DIR}/include
PATH_SUFFIXES SDL2
)
find_library(SDL2_LIBRARY
NAMES SDL2
PATHS
/usr/lib
/usr/local/lib
$ENV{SDL2_DIR}/lib
)
if(SDL2_INCLUDE_DIR AND SDL2_LIBRARY)
set(SDL2_FOUND TRUE)
set(SDL2_LIBRARIES ${SDL2_LIBRARY})
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
endif()
# If not found, use FetchContent to acquire SDL2
if(NOT SDL2_FOUND)
include(FetchContent)
FetchContent_Declare(
SDL2
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG release-2.28.5 # Change to desired version
)
FetchContent_MakeAvailable(SDL2)
set(SDL2_FOUND TRUE)
set(SDL2_LIBRARIES SDL2)
set(SDL2_INCLUDE_DIRS ${sdl2_SOURCE_DIR}/include)
endif()
# Provide variables for downstream usage
if(SDL2_FOUND)
set(SDL2_INCLUDE_DIR ${SDL2_INCLUDE_DIRS} CACHE PATH "SDL2 include directory")
set(SDL2_LIBRARY ${SDL2_LIBRARIES} CACHE FILEPATH "SDL2 library")
endif()

0
src/asset/CMakeLists.txt Normal file
View File

65
src/asset/asset.c Normal file
View File

@@ -0,0 +1,65 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "asset.h"
assetcallbacks_t ASSET_CALLBACKS[ASSET_TYPE_COUNT] = {
{
.init = assetRawInit,
.loadAsync = assetRawLoadAsync,
.loadSync = assetRawLoadSync,
.dispose = assetRawDispose
},
{
.init = NULL,
.loadAsync = NULL,
.loadSync = NULL,
.dispose = NULL
},
{
.init = NULL,
.loadAsync = NULL,
.loadSync = NULL,
.dispose = NULL
},
{
.init = NULL,
.loadAsync = NULL,
.loadSync = NULL,
.dispose = NULL
},
{
.init = NULL,
.loadAsync = NULL,
.loadSync = NULL,
.dispose = NULL
},
{
.init = NULL,
.loadAsync = NULL,
.loadSync = NULL,
.dispose = NULL
},
{
.init = NULL,
.loadAsync = NULL,
.loadSync = NULL,
.dispose = NULL
},
{
.init = NULL,
.loadAsync = NULL,
.loadSync = NULL,
.dispose = NULL
}
};
void assetInit() {
}

36
src/asset/asset.h Normal file
View File

@@ -0,0 +1,36 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "assetraw.h"
typedef enum {
ASSET_TYPE_RAW,
ASSET_TYPE_TEXTURE,
ASSET_TYPE_JSON,
ASSET_TYPE_MODEL,
ASSET_TYPE_AUDIO,
ASSET_TYPE_COUNT
} assettype_t;
typedef struct {
void (*init)(asset_t *asset);
void (*loadAsync)(asset_t *asset);
void (*loadSync)(asset_t *asset);
void (*dispose)(asset_t *asset);
} assetcallbacks_t;
typedef struct asset_s {
void *arg;
} asset_t;
extern assetcallbacks_t ASSET_CALLBACKS[];
void assetInit(void);
void assetDispose(void);

24
src/asset/assetraw.c Normal file
View File

@@ -0,0 +1,24 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "assetraw.h"
void assetRawInit(asset_t *asset) {
}
void assetRawLoadAsync(asset_t *asset) {
}
void assetRawLoadSync(asset_t *asset) {
}
void assetRawDispose(asset_t *asset) {
}

16
src/asset/assetraw.h Normal file
View File

@@ -0,0 +1,16 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
typedef struct asset_s asset_t;
void assetRawInit(asset_t *asset);
void assetRawLoadAsync(asset_t *asset);
void assetRawLoadSync(asset_t *asset);
void assetRawDispose(asset_t *asset);

27
src/asset/assetsystem.h Normal file
View File

@@ -0,0 +1,27 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "asset.h"
#include "thread/thread.h"
typedef struct {
void *args;
thread_t loadThread;
} assetsystem_t;
extern assetsystem_t ASSET_SYSTEM;
/**
* Initializes the asset system.
*/
void assetSystemInit(void);
/**
* Disposes/cleans up the asset system.
*/
void assetSystemDispose(void);