diff options
Diffstat (limited to 'src/resources.odin')
| -rw-r--r-- | src/resources.odin | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/resources.odin b/src/resources.odin index 1bd567e..22fed57 100644 --- a/src/resources.odin +++ b/src/resources.odin @@ -1,8 +1,10 @@ package demonchime +import "core:image" +import "core:image/qoi" import "core:log" -import rl "vendor:raylib" +import "fw" Tiled_Property :: union { string, @@ -12,7 +14,7 @@ Tiled_Property :: union { } Image_Resource :: struct { - texture: rl.Texture2D, + texture: fw.Texture, anim: Animation_Id, data: []u8, } @@ -73,21 +75,15 @@ Room_Position_Resource :: struct { height: i32, } -get_image :: proc(id: Image_Id) -> rl.Texture2D { +get_image :: proc(id: Image_Id) -> fw.Texture { img_res := &images[id] - if !rl.IsTextureValid(img_res.texture) { - rl_img := rl.LoadImageFromMemory( - ".qoi", - raw_data(img_res.data), - i32(len(img_res.data)), - ) - if !rl.IsImageValid(rl_img) { - log.warnf("Could not load asset %v", id) - } + if img_res.texture.handle == 0 { + img, qoi_err := qoi.load_from_bytes(img_res.data) + defer image.destroy(img) - img_res.texture = rl.LoadTextureFromImage(rl_img) - rl.UnloadImage(rl_img) + img_res.texture = fw.create_texture_from_image(img) + log.debug(img_res.texture.size) } return img_res.texture |
