append graphics.kv
append glfw3.kv
-
ccmd
{
name exec
description "The path to the config"
}
}
-
config "bind ALT+GRAVE_ACCENT console"
+
config "bind BACKSPACE ui_backspace"
config "bind DELETE ui_delete"
config "bind ENTER ui_enter"
static inline f32 f32_max( f32 a, f32 b ){ return a > b? a: b; }
static inline i32 i32_min( i32 a, i32 b ){ return a < b? a: b; }
static inline i32 i32_max( i32 a, i32 b ){ return a > b? a: b; }
+static inline i16 i16_min( i16 a, i16 b ){ return a < b? a: b; }
+static inline i16 i16_max( i16 a, i16 b ){ return a > b? a: b; }
static inline f32 f32_clamp( f32 a, f32 min, f32 max ) { return f32_min( max, f32_max( a, min ) ); }
+static inline i16 i16_clamp( i16 a, i16 min, i16 max ){ return i16_min( max, i16_max( a, min ) ); }
+static inline i16 i32_clamp( i32 a, i32 min, i32 max ){ return i32_min( max, i32_max( a, min ) ); }
static inline f32 f32_sign( f32 a ) { return a < 0.0f? -1.0f: 1.0f; }
void _exit_init(void);
void stretchy_init( struct stretchy_allocator *stretchy, u32 element_size );
void *stretchy_append( struct stretchy_allocator *stretchy );
void *stretchy_get( struct stretchy_allocator *stretchy, u32 index );
-void *stretchy_delete( struct stretchy_allocator *stretchy, u32 index ); // TODO
+void stretchy_delete( struct stretchy_allocator *stretchy, u32 index );
u32 stretchy_count( struct stretchy_allocator *stretchy );
void stretchy_free( struct stretchy_allocator *stretchy );
void rect_pad( i16 rect[4], i16 padding[2] );
void rect_split( i16 rect[4], u32 vertical, i16 width, i16 gap, i16 out_left[4], i16 out_right[4] );
void rect_split_ratio( i16 rect[4], u32 vertical, f32 ratio, i16 gap, i16 out_left[4], i16 out_right[4] );
+bool ui_inside_rect( i16 rect[4], i16 co[2] );
/* Font
* ------------------------------------------------------------------------------------------------------------------ */
/* Immediate mode UI
* ------------------------------------------------------------------------------------------------------------------ */
void _ui_set_mouse( i16 x, i16 y );
+void _ui_get_mouse_co( i16 out_co[2] );
void _ui_input_text( const c8 *text );
#define UI_PADDING_PX 8
void _input_init(void)
{
glfwSetKeyCallback( _engine.window_handle, _input_key_callback );
+ glfwSetMouseButtonCallback( _engine.window_handle, _input_mouse_callback );
for( u32 i=0; i<ARRAY_COUNT( _input_aliases ); i ++ )
_input_aliases[i].alias_hash = buffer_djb2( _input_aliases[i].alias, 0 );
}
-#define SMALL_SEGMENTS 1
+#define SMALL_SEGMENTS 4
void stretchy_init( struct stretchy_allocator *stretchy, u32 element_size )
{
stretchy->count = 0;
i32 i, offset;
stretchy_core( stretchy, stretchy->count ++, &i, &offset );
if( offset == 0 )
+ {
+ $log( $ok, {"Allocated new stretchy segment: "}, $unsigned( i ), {", size: "}, $unsigned(1<<(i+SMALL_SEGMENTS)) );
stretchy->segments[ i ] = _heap_allocate( (1<<(i+SMALL_SEGMENTS)) * stretchy->element_size );
+ }
return stretchy->segments[ i ] + stretchy->element_size*offset;
}
stretchy->segments[i] = NULL;
}
}
+
+void stretchy_delete( struct stretchy_allocator *stretchy, u32 index )
+{
+ if( (stretchy->count > 1) && (index != stretchy->count-1) )
+ {
+ buffer_copy( stretchy_get( stretchy, stretchy->count-1 ), stretchy->element_size,
+ stretchy_get( stretchy, index ), stretchy->element_size );
+ }
+ stretchy->count --;
+
+ i32 i, offset;
+ stretchy_core( stretchy, stretchy->count, &i, &offset );
+ if( offset == 0 )
+ {
+ $log( $ok, {"Deleted stretchy segment: "}, $unsigned(i) );
+ _heap_free( stretchy->segments[i] );
+ stretchy->segments[i] = NULL;
+ }
+}
_graphics_target = target;
}
-static i16 i16_min( i16 a, i16 b ){ return a<b?a:b; }
-static i16 i16_max( i16 a, i16 b ){ return a>b?a:b; }
-static i16 i16_clamp( i16 a, i16 min, i16 max ){ return i16_min( max, i16_max( a, min ) ); }
void rect_clip( i16 child[4], i16 parent[4], i16 clipped[4] )
{
i16 px = parent[0], py = parent[1], pw = parent[2], ph = parent[3];
}
_ui;
+void _ui_get_mouse_co( i16 out_co[2] )
+{
+ out_co[0] = _ui.mouse_co[0];
+ out_co[1] = _ui.mouse_co[1];
+}
+
void _ui_set_encoding( enum ui_text_encoding encoding )
{
_ui.text_encoding = encoding;
}
-static bool ui_inside_rect( i16 rect[4], i16 co[2] )
+bool ui_inside_rect( i16 rect[4], i16 co[2] )
{
return (co[0] >= rect[0]) && (co[1] >= rect[1]) && (co[0] < rect[0]+rect[2]) && (co[1] < rect[1]+rect[3]);
}
bool shared = 0;
bool no_pdb = 0;
+u32 optimise = 0;
+
enum libc_version
{
k_libc_version_native = 0,
stream_open_buffer_read( &arg_stream, (void*)arg, buffer_last_index(arg,0,0)+1, 0 );
ASSERT_CRITICAL( string_parse_u64( &arg_stream, &processors ) == k_string_parse_ok );
}
+
+ if( _option_flag( 'O', "Run optimisers" ) )
+ optimise = 3;
target_file_path = _option();
ASSERT_CRITICAL( target_file_path );
if( use_tsan ) $v_string( &command_string, {" -fsanitize=thread -lasan \\\n"} );
if( use_asan ) $v_string( &command_string, {" -fsanitize=address -lasan \\\n"} );
+ $v_string( &command_string, { " -O" }, $unsigned( optimise ), {" \\\n"} );
$v_string( &command_string, {" -target "}, {string_get(&tripple_string)}, {" "} );
if( platform == k_platform_windows )