Skip to content

Asset Pipeline

Matthew LaRocca edited this page Nov 23, 2022 · 3 revisions

The framework64 Asset pipeline is responsible for taking raw assets and converting them into a platform specific format. The pipeline takes as input a JSON manifest file and will output both the converted assets and a header file for use in your game.

Currently, the following asset types are supported:

JSON Manifest File

The assets for your project are described using an asset manifest file. Each asset type has a corresponding section of the manifest file. All sections are optional and may be omitted if you do not need to use assets of that type. Note, all paths in this file are relative to the assent manifest file. The following defines a very simple asset manifest file:

{
    "images": [
        {
            "src": "grass.png",
            "hslices": 1,
            "vslices": 1
        }
    ],
    "meshes": [
        {
            "src": "blue_cube/blue_cube.gltf"
        }
    ],
    "fonts": [
        {
            "src": "Consolas.ttf",
            "size": 12,
            "name": "Consolas12"
        }
    ],
    "soundBanks": [
        {
            "name": "soundbank1",
            "dir": "sound_effects/bank1"
        }
    ],
    "musicBanks": [
        {
            "name": "musicbank1",
            "dir": "music/bank1"
        }
    ],
    "raw": [
        "sample.txt"
    ]
}

Asset Header File

When the pipeline has completed, in addition to the converted assets, an assets.h header file will also be created. The project is automatically configured to include this file. This header file contains definitions that the various asset loading functions use to load files from ROM / disk / etc.

Example assets.h file:

#pragma once

#define FW64_ASSET_COUNT 31

#define FW64_ASSET_mesh_blue_cube 0
#define FW64_ASSET_image_grass 11
#define FW64_ASSET_font_Consolas12 16
#define FW64_ASSET_soundbank_soundbank1 18
#define FW64_ASSET_musicbank_musicbank1 21
#define FW64_ASSET_raw_sample 30

These defines should be passed into the corresponding load function.
An example to load a mesh:

fw64_mesh_load(engine->assets, FW64_ASSET_mesh_blue_cube)
Clone this wiki locally