-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.odin
More file actions
30 lines (26 loc) · 1.03 KB
/
preload.odin
File metadata and controls
30 lines (26 loc) · 1.03 KB
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
//This File allows you to embed data into your game binary, most of these require the file format because raylib can't autodetect it for some reason
package extra
import rl "vendor:raylib"
//Embeds a texture into your binary
@(require_results)
PreLoadTexture :: proc($imagePath: string, format: cstring = ".png") -> rl.Texture {
DATA := #load(imagePath)
image := rl.LoadImageFromMemory(format, raw_data(DATA), i32(len(DATA)))
rl.LoadTextureFromImage(image)
texture := rl.LoadTextureFromImage(image)
rl.UnloadImage(image)
return texture
}
//Embeds music into your binary
@(require_results)
PreLoadMusic :: proc($imagePath: string, format: cstring = ".wav") -> rl.Music {
DATA := #load(imagePath)
music := rl.LoadMusicStreamFromMemory(format, raw_data(DATA), i32(len(DATA)))
return music
}
//Embeds a font into your binary
PreLoadFont :: proc($imagePath: string, format: cstring = ".ttf", size: i32 = 20) -> rl.Font {
DATA := #load(imagePath)
font := rl.LoadFontFromMemory(format, raw_data(DATA), i32(len(DATA)), size, nil, 0)
return font
}