Runtime fixes

This commit is contained in:
Edward R. Gonzalez 2024-03-02 20:22:28 -05:00
parent b4feb9e506
commit bd6e79d005
5 changed files with 13 additions and 11 deletions

View File

@ -75,7 +75,7 @@ startup :: proc( live_mem : virtual.Arena, snapshot_mem : []u8, host_logger : ^
rl.SetConfigFlags( {
rl.ConfigFlag.WINDOW_RESIZABLE,
rl.ConfigFlag.WINDOW_TOPMOST,
// rl.ConfigFlag.WINDOW_TOPMOST,
})
// Rough setup of window with rl stuff
@ -108,7 +108,7 @@ startup :: proc( live_mem : virtual.Arena, snapshot_mem : []u8, host_logger : ^
// path_squidgy_slimes := strings.concatenate( { Path_Assets, "Squidgy Slimes.ttf" } )
// font_squidgy_slimes = font_load( path_squidgy_slimes, 24.0, "Squidgy_Slime" )
path_firacode := strings.concatenate( { Path_Assets, "FiraCode-Regular.ttf" } )
path_firacode := strings.concatenate( { Path_Assets, "FiraCode-Regular.ttf" }, temp_allocator() )
font_firacode = font_load( path_firacode, 24.0, "FiraCode" )
// font_data, read_succeded : = os.read_entire_file( path_rec_mono_semicasual_reg )

View File

@ -25,10 +25,14 @@ array_underlying_slice :: proc(slice: []($ Type)) -> Array(Type) {
return array_ptr ^
}
array_to_slice :: proc( using self : Array($ Type) ) -> []Type {
array_to_slice_num :: proc( using self : Array($ Type) ) -> []Type {
return slice_ptr( data, int(num) )
}
array_to_slice :: proc( using self : Array($ Type) ) -> []Type {
return slice_ptr( data, int(capacity))
}
array_grow_formula :: proc( value : u64 ) -> u64 {
return 2 * value + 8
}
@ -41,7 +45,7 @@ array_init_reserve :: proc( $ Type : typeid, allocator : Allocator, capacity : u
{
raw_data, result_code := alloc( size_of(Array) + int(capacity) * size_of(Type), allocator = allocator )
result := cast(^Array(Type)) raw_data;
result.data = cast( [^]Type ) ptr_offset( result, 1 )
result.data = cast( [^]Type ) (cast( [^]Array(Type)) result)[ 1:]
result.allocator = allocator
result.capacity = capacity
return (result ^), result_code

View File

@ -45,14 +45,12 @@ zpl_hmap_init_reserve :: proc( $ Type : typeid, allocator : Allocator, num : u64
result : HMapZPL(Type)
hashes_result, entries_result : AllocatorError
hashes_size := cast(u64) (HMapZPL_HashToEntryRatio * f32(num))
result.hashes, hashes_result = array_init_reserve( i64, allocator, hashes_size )
result.hashes, hashes_result = array_init_reserve( i64, allocator, num )
if hashes_result != AllocatorError.None {
ensure( false, "Failed to allocate hashes array" )
return result, hashes_result
}
array_resize( & result.hashes, hashes_size )
array_resize( & result.hashes, num )
slice.fill( slice_ptr( result.hashes.data, cast(int) result.hashes.num), -1 )
result.entries, entries_result = array_init_reserve( HMapZPL_Entry(Type), allocator, num )

View File

@ -12,7 +12,7 @@ debug_draw_text :: proc( content : string, pos : Vec2, size : f32, color : rl.Co
return
}
runes, alloc_error := to_runes( content, context.temp_allocator )
verify( alloc_error != AllocatorError.None, "Failed to temp allocate runes" )
verify( alloc_error == AllocatorError.None, "Failed to temp allocate runes" )
font := font
if font.key == Font_Default.key {
@ -40,7 +40,7 @@ debug_draw_text_world :: proc( content : string, pos : Vec2, size : f32, color :
return
}
runes, alloc_error := to_runes( content, context.temp_allocator )
verify( alloc_error != AllocatorError.None, "Failed to temp allocate runes" )
verify( alloc_error == AllocatorError.None, "Failed to temp allocate runes" )
font := font
if font.key == Font_Default.key {

View File

@ -217,7 +217,7 @@ update :: proc( delta_time : f64 ) -> b32
ui_set_layout( first_layout )
// First Demo
when false
when true
{
first_flags : UI_BoxFlags = { .Mouse_Clickable, .Focusable, .Click_To_Focus }
first_box := ui_box_make( first_flags, "FIRST BOX BOIS" )