This commit is contained in:
gingerBill
2020-09-04 11:18:58 +01:00
4 changed files with 10 additions and 8 deletions

View File

@@ -119,8 +119,10 @@ vector4_linear_to_srgb :: proc(col: Vector4) -> Vector4 {
}
vector4_hsl_to_rgb :: proc(h, s, l: Float, a: Float = 1) -> Vector4 {
hue_to_rgb :: proc(p, q, t0: Float) -> Float {
t := math.mod(t0, 1.0);
hue_to_rgb :: proc(p, q, t: Float) -> Float {
t := t;
if t < 0 do t += 1;
if t > 1 do t -= 1;
switch {
case t < 1.0/6.0: return p + (q - p) * 6.0 * t;
case t < 1.0/2.0: return q;

View File

@@ -70,7 +70,7 @@ file_size_from_path :: proc(path: string) -> i64 {
return length;
}
read_entire_file :: proc(name: string) -> (data: []byte, success: bool) {
read_entire_file :: proc(name: string, allocator := context.allocator) -> (data: []byte, success: bool) {
fd, err := open(name, O_RDONLY, 0);
if err != 0 {
return nil, false;
@@ -86,7 +86,7 @@ read_entire_file :: proc(name: string) -> (data: []byte, success: bool) {
return nil, true;
}
data = make([]byte, int(length));
data = make([]byte, int(length), allocator);
if data == nil {
return nil, false;
}

View File

@@ -271,7 +271,7 @@ get_page_size :: proc() -> int {
// The current directory is stored as a global variable in the process.
@private cwd_gate := false;
get_current_directory :: proc() -> string {
get_current_directory :: proc(allocator := context.allocator) -> string {
for intrinsics.atomic_xchg(&cwd_gate, true) {}
sz_utf16 := win32.GetCurrentDirectoryW(0, nil);
@@ -282,7 +282,7 @@ get_current_directory :: proc() -> string {
intrinsics.atomic_store(&cwd_gate, false);
return win32.utf16_to_utf8(dir_buf_wstr);
return win32.utf16_to_utf8(dir_buf_wstr, allocator);
}
set_current_directory :: proc(path: string) -> (err: Errno) {

View File

@@ -48,8 +48,8 @@ base :: proc(path: string, new := false, allocator := context.allocator) -> stri
name :: proc(path: string, new := false, allocator := context.allocator) -> string {
if path == "" do return "";
dot := len(path);
end := dot - 1;
end := len(path) - 1;
dot := end;
for i := end; i >= 0; i -= 1 {
switch path[i] {