interfaces fixes; freetype.text_width(); gl and stbi fixes

This commit is contained in:
Alexander Medvednikov 2020-01-09 12:00:39 +01:00
parent 938f27e391
commit b6c0b22742
14 changed files with 150 additions and 14 deletions

View file

@ -22,6 +22,7 @@ mut:
}
fn C.stbi_load() voidptr
fn C.stbi_load_from_memory() voidptr
fn C.stbi_image_free()
fn C.stbi_set_flip_vertically_on_load()
@ -41,6 +42,22 @@ pub fn load(path string) Image {
return res
}
//pub fn load_from_memory(buf []byte) Image {
pub fn load_from_memory(buf byteptr) Image {
mut res := Image {
ok: true
data: 0
}
flag := C.STBI_rgb_alpha
res.data = C.stbi_load_from_memory(buf, 3812, &res.width, &res.height, &res.nr_channels, flag)
if isnil(res.data) {
println('stbi image failed to load from memory')
exit(1)
}
return res
}
pub fn (img Image) free() {
C.stbi_image_free(img.data)
}