Better using; foreign system libraries; optional semicolons

This commit is contained in:
Ginger Bill
2016-08-30 18:39:29 +01:00
parent 0eaf7bd830
commit a06f70d5d9
17 changed files with 1136 additions and 1629 deletions
+13 -13
View File
@@ -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
}