stbi: add proper declarations for C.stbi_load etc.

pull/8468/head
Delyan Angelov 2021-01-31 10:23:43 +02:00
parent 0081e77969
commit e066e83041
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 14 additions and 10 deletions

View File

@ -4,7 +4,6 @@
module stbi
#flag -I @VROOT/thirdparty/stb_image
#include "stb_image.h"
#flag @VROOT/thirdparty/stb_image/stbi.o
@ -19,10 +18,15 @@ pub mut:
ext string
}
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()
fn C.stbi_load(filename charptr, x &int, y &int, channels_in_file &int, desired_channels int) byteptr
fn C.stbi_load_from_file(f voidptr, x &int, y &int, channels_in_file &int, desired_channels int) byteptr
fn C.stbi_load_from_memory(buffer byteptr, len int, x &int, y &int, channels_in_file &int, desired_channels int) byteptr
fn C.stbi_image_free(retval_from_stbi_load byteptr)
fn C.stbi_set_flip_vertically_on_load(should_flip int)
fn init() {
set_flip_vertically_on_load(false)
@ -49,14 +53,14 @@ pub fn load_from_memory(buf byteptr, bufsize int) ?Image {
data: 0
}
flag := C.STBI_rgb_alpha
res.data = C.stbi_load_from_memory(buf, bufsize, &res.width, &res.height, &res.nr_channels, flag)
res.data = C.stbi_load_from_memory(buf, bufsize, &res.width, &res.height, &res.nr_channels,
flag)
if isnil(res.data) {
return error('stbi image failed to load from memory')
}
return res
}
pub fn (img &Image) free() {
C.stbi_image_free(img.data)
}