64 lines
1.7 KiB
C
64 lines
1.7 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "asset/assetfile.h"
|
|
#include "display/mesh/mesh.h"
|
|
|
|
#define ASSET_MESH_FILE_VERSION 1
|
|
|
|
typedef struct assetloading_s assetloading_t;
|
|
typedef struct assetentry_s assetentry_t;
|
|
|
|
typedef enum {
|
|
ASSET_MESH_LOADING_STATE_INITIAL,
|
|
ASSET_MESH_LOADING_STATE_READ_FILE,
|
|
ASSET_MESH_LOADING_STATE_CREATE_MESH,
|
|
ASSET_MESH_LOADING_STATE_DONE
|
|
} assetmeshloadingstate_t;
|
|
|
|
typedef struct {
|
|
assetfile_t file;
|
|
assetmeshloadingstate_t state;
|
|
uint32_t vertCount;
|
|
uint8_t *data;
|
|
} assetmeshloaderloading_t;
|
|
|
|
typedef struct {
|
|
mesh_t mesh;
|
|
bool_t meshInitialized;
|
|
meshvertex_t *vertices;
|
|
} assetmeshoutput_t;
|
|
|
|
/**
|
|
* Asynchronous loader for DMF mesh assets. Reads the file, validates the
|
|
* header, and prepares a ready-to-use vertex buffer so the sync phase only
|
|
* needs to upload to the GPU.
|
|
*
|
|
* @param loading Loading information for the asset being loaded.
|
|
* @return Error code indicating success or failure.
|
|
*/
|
|
errorret_t assetMeshLoaderAsync(assetloading_t *loading);
|
|
|
|
/**
|
|
* Synchronous loader for DMF mesh assets. Initializes the mesh from the
|
|
* vertex buffer prepared by the async phase and flushes it to the GPU.
|
|
*
|
|
* @param loading Loading information for the asset being loaded.
|
|
* @return Error code indicating success or failure.
|
|
*/
|
|
errorret_t assetMeshLoaderSync(assetloading_t *loading);
|
|
|
|
/**
|
|
* Disposer for DMF mesh assets. Disposes the mesh and frees the vertex
|
|
* buffer.
|
|
*
|
|
* @param entry Asset entry containing the mesh data to dispose.
|
|
* @return Error code indicating success or failure.
|
|
*/
|
|
errorret_t assetMeshDispose(assetentry_t *entry);
|