Sign in

    selene_raylib

    Native raylib backend for Selene.

    Game Engine
    Download zip
    Author
    Version
    0.30.4
    License
    Apache-2.0
    Last updated
    6 months ago
    Downloads
    1K

    #Milky2018/selene_raylib

    Native backend implementation for Selene based on tonyfettes/raylib.

    #Embed assets with MoonBit pre-build

    This is an optional optimization and packaging workflow for native binary distribution. By default, you can skip it and let raylib load textures/audio/fonts from the filesystem.

    #1. Install the asset bundling CLI

    moon install Milky2018/selene_tools/cmd/selene-embed-assets

    #2. Add pre-build hooks in your game package moon.pkg

    options(
    "pre-build": [
    {
    "input": "<assets-dir>",
    "output": "_embedded_assets.pack",
    "command": "selene-embed-assets --assets-dir $input --pack-out $output --path-prefix <runtime-prefix>",
    },
    {
    "input": "<assets-dir>",
    "output": "embedded_assets_index.mbt",
    "command": "selene-embed-assets --assets-dir $input --index-out $output --path-prefix <runtime-prefix> --blob-name embedded_assets_blob --lookup-fn get_embedded_asset",
    },
    {
    "input": "_embedded_assets.pack",
    "output": "embedded_assets_blob.mbt",
    "command": ":embed --binary -i $input -o $output --name embedded_assets_blob",
    },
    ],
    )

    Use the same <assets-dir> in both pre-build steps, and set <runtime-prefix> to match your runtime asset paths.

    This generates:
    • embedded_assets_blob.mbt (raw bytes via :embed)
    • embedded_assets_index.mbt (get_embedded_asset(path) -> Bytes?)

    #3. Install embedded lookup before App::run (only when embedding is enabled)

    import { "Milky2018/selene/asset" @asset }

    fn main {
    @asset.set_io(get_embedded_asset)
    // app.run()
    }

    When installed, selene_raylib will prefer embedded bytes for:
    • images/textures
    • sounds/music
    • fonts

    If a path is not found in embedded assets, it falls back to filesystem loading.

    If embedding is not enabled, you should not call set_io.

    AudioInstance

    type AudioInstance = Int

    draw_gradient_rect

    draw_image

    fn draw_image(command :
    ImageDrawCommand2D
    , image_path : String) -> Unit

    get_asset_bytes

    fn get_asset_bytes(path : String) -> Bytes?

    get_realtime_delta

    fn get_realtime_delta() -> Double

    get_time_scale

    fn get_time_scale() -> Double

    is_finished

    fn is_finished(instance~ : Int) -> Bool

    load_font

    fn load_font(font : String, path : String) -> Unit

    lock_mouse

    fn lock_mouse(locked :
    Ref
    [Bool]) -> Unit

    play_audio

    fn play_audio(audio_path~ : String, volume~ : Double, speed~ : Double, loop_~ : Bool, paused~ : Bool) -> Int

    pop_clip_rect

    fn pop_clip_rect() -> Unit

    preload_audio

    fn preload_audio(path : String) -> Unit

    preload_img

    fn preload_img(path : String) -> Unit

    push_clip_rect

    fn push_clip_rect(rect :
    Rect
    ) -> Unit

    register_key_events

    fn register_key_events(pressed_keys :
    Set
    [
    Code
    ]) -> Unit

    register_mouse_events

    release_image_asset

    fn release_image_asset(handle :
    ImageHandle
    ) -> Unit

    release_material_asset

    fn release_material_asset(handle :
    MaterialHandle
    ) -> Unit

    release_mesh_asset

    fn release_mesh_asset(handle :
    MeshHandle
    ) -> Unit

    render_3d_frame

    request_close

    fn request_close() -> Unit

    reset_clip_stack

    fn reset_clip_stack() -> Unit

    set_embedded_assets

    fn set_embedded_assets(lookup : (String) -> Bytes?) -> Unit

    set_loop

    fn set_loop(instance~ : Int, loop_~ : Bool) -> Unit

    set_paused

    fn set_paused(instance~ : Int, paused~ : Bool) -> Unit

    set_speed

    fn set_speed(instance~ : Int, speed~ : Double) -> Unit

    set_time_scale

    fn set_time_scale(scale : Double) -> Unit

    set_volume

    fn set_volume(instance~ : Int, volume~ : Double) -> Unit

    stop

    fn stop(instance~ : Int) -> Unit

    tick_audio

    fn tick_audio() -> Unit

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io