mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Better using; foreign system libraries; optional semicolons
This commit is contained in:
+13
-13
@@ -7,24 +7,24 @@ type Bitmap: struct {
|
||||
make_bitmap :: proc(filename: string) -> Bitmap {
|
||||
stbi_load :: proc(filename: ^u8, x, y, comp: ^i32, req_comp: i32) -> ^u8 #foreign
|
||||
|
||||
c_buf: [1024]u8;
|
||||
bytes := filename as []byte;
|
||||
str_len := copy(c_buf[:], bytes);
|
||||
c_buf: [1024]u8
|
||||
bytes := filename as []byte
|
||||
str_len := copy(c_buf[:], bytes)
|
||||
|
||||
b: Bitmap;
|
||||
pixels := stbi_load(^c_buf[0], ^b.width, ^b.height, ^b.comp, 4);
|
||||
len := (b.width*b.height*b.comp) as int;
|
||||
b.data = pixels[:len];
|
||||
b: Bitmap
|
||||
pixels := stbi_load(^c_buf[0], ^b.width, ^b.height, ^b.comp, 4)
|
||||
len := (b.width*b.height*b.comp) as int
|
||||
b.data = slice_ptr(pixels, len)
|
||||
|
||||
return b;
|
||||
return b
|
||||
}
|
||||
|
||||
destroy_bitmap :: proc(b: ^Bitmap) {
|
||||
stbi_image_free :: proc(retval_from_stbi_load: rawptr) #foreign
|
||||
|
||||
stbi_image_free(^b.data[0]);
|
||||
b.data = b.data[:0];
|
||||
b.width = 0;
|
||||
b.height = 0;
|
||||
b.comp = 0;
|
||||
stbi_image_free(^b.data[0])
|
||||
b.data = b.data[:0]
|
||||
b.width = 0
|
||||
b.height = 0
|
||||
b.comp = 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user