gg,stbi: implement gg.create_image_from_memory/2

This commit is contained in:
Delyan Angelov 2020-08-04 13:18:08 +03:00
parent 216b6bf285
commit f9d241ae27
2 changed files with 21 additions and 14 deletions

View file

@ -272,6 +272,23 @@ pub fn create_image(file string) Image {
return img
}
pub fn create_image_from_memory(buf byteptr, bufsize int) Image {
stb_img := stbi.load_from_memory(buf, bufsize)
mut img := Image{
width: stb_img.width
height: stb_img.height
nr_channels: stb_img.nr_channels
ok: stb_img.ok
data: stb_img.data
ext: stb_img.ext
}
return img
}
pub fn create_image_from_byte_array(b []byte) Image {
return create_image_from_memory(b.data, b.len)
}
pub fn (mut img Image) init_sokol_image() &Image {
mut img_desc := C.sg_image_desc{
width: img.width
@ -291,13 +308,6 @@ pub fn (mut img Image) init_sokol_image() &Image {
return img
}
pub fn create_image_from_memory(buf byteptr) u32 {
// texture := gl.gen_texture()
// img := stbi.load_from_memory(buf)
// img.free()
return 0 // texture
}
pub fn (gg &Context) begin() {
if gg.render_text && gg.font_inited {
gg.ft.flush()