blob: edac69b29230ddde15ad95f44f190ee637fbb0f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
//! The `assets` crate stores all audio and image assets that need to be
//! loaded during runtime
use raylib::{RaylibHandle, RaylibThread, audio::RaylibAudio};
#[expect(dead_code)]
type Sound = raylib::audio::Sound<'static>;
/// The `AudioData` container initalizes the audio subsystem
/// for raylib, leaks it (to gurentee audio is statically loaded),
/// then loads all needed audio samples
#[derive(Debug)]
pub struct AudioData {}
impl AudioData {
pub(crate) fn load() -> crate::Result<Self> {
// Phantom handle to the raylib audio subsystem
// Raylib doesnt use a handle, but the rust bindings
// have one to ensure memory safety.
//
// We must leak this handle after allocating it,
// if we dont then all audio will be unloaded :(
//
// NOTE: would this cause issues if `AudioData::load` was
// called multiple times?
let _handle = Box::leak(Box::new(RaylibAudio::init_audio_device()?));
// TODO: load audio samples
//let example = handle.new_sound("example.ogg")?;
Ok(Self {})
}
}
/// The `ImageData` container loads all game sprites, and other images into memory.
#[derive(Debug)]
pub(crate) struct ImageData {}
impl ImageData {
pub(crate) fn load(
_handle: &mut RaylibHandle,
_thread: &RaylibThread,
) -> crate::Result<Self> {
// TODO: load image data
//let example = handle.load_texture(&thread, "example.png");
Ok(Self {})
}
}
|