From: hgn Date: Mon, 31 Oct 2022 03:12:31 +0000 (+0000) Subject: couple fix X-Git-Url: https://harrygodden.com/git/?p=vg.git;a=commitdiff_plain;h=20d7c01aba5f37fbddcbcf01748debde592e76e8 couple fix --- diff --git a/src/vg/vg.h b/src/vg/vg.h index f3456f3..71f4b2a 100644 --- a/src/vg/vg.h +++ b/src/vg/vg.h @@ -549,9 +549,11 @@ VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name ) vg.accumulator += vg.time_delta; vg.fixed_iterations = 0; + vg_lines.allow_input = 1; while( vg.accumulator >= (VG_TIMESTEP_FIXED-0.00125) ) { vg_update_fixed( loaded ); + vg_lines.allow_input = 0; vg.accumulator -= VG_TIMESTEP_FIXED; vg.accumulator = VG_MAX( 0.0, vg.accumulator ); @@ -562,6 +564,7 @@ VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name ) break; } } + vg_lines.allow_input = 1; /* * Rendering diff --git a/src/vg/vg_console.h b/src/vg/vg_console.h index 62e3118..b0758c1 100644 --- a/src/vg/vg_console.h +++ b/src/vg/vg_console.h @@ -125,12 +125,13 @@ VG_STATIC void vg_console_draw( void ) vg_mutex_lock( &log_print_mutex ); int ptr = vg_log.buffer_line_current; - int const fh = 14; - int console_lines = VG_MIN( 16, vg_log.buffer_line_count ); + int const fh = 14, + log_lines = 32; + int console_lines = VG_MIN( log_lines, vg_log.buffer_line_count ); vg_uictx.cursor[0] = 0; vg_uictx.cursor[1] = 0; - vg_uictx.cursor[3] = 16*fh; + vg_uictx.cursor[3] = log_lines*fh; ui_fill_x(); ui_new_node(); diff --git a/src/vg/vg_input.h b/src/vg/vg_input.h index ac2cce6..f7df751 100644 --- a/src/vg/vg_input.h +++ b/src/vg/vg_input.h @@ -163,7 +163,11 @@ int get_button_cross_device( int const id ) void vg_update_inputs(void) { if( !glfwGetGamepadState( GLFW_JOYSTICK_1, &vg.gamepad) ) + { vg.gamepad_ready = 0; + vg.gamepad.axes[ GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER ] = -1.0f; + vg.gamepad.axes[ GLFW_GAMEPAD_AXIS_LEFT_TRIGGER ] = -1.0f; + } /* Update button inputs */ for( int i = 0; i < vg_list_size( vg_button_binds ); i ++ ) diff --git a/src/vg/vg_lines.h b/src/vg/vg_lines.h index c0da5b3..672a59e 100644 --- a/src/vg/vg_lines.h +++ b/src/vg/vg_lines.h @@ -48,7 +48,8 @@ static struct vg_shader _shader_lines = struct { - u32 draw; + u32 draw, + allow_input; struct vg_lines_vert { @@ -117,6 +118,7 @@ VG_STATIC void vg_lines_init(void) } vg_release_thread_sync(); + vg_lines.allow_input = 1; } VG_STATIC void vg_lines_drawall( float* projection ) @@ -146,6 +148,9 @@ VG_STATIC void vg_lines_drawall( float* projection ) VG_STATIC void vg_line2( line_co from, line_co to, u32 fc, u32 tc ) { + if( !vg_lines.allow_input ) + return; + u32 size = 2 * sizeof(struct vg_lines_vert); struct vg_lines_vert *v = vg_linear_alloc( vg_lines.vertex_buffer, size ); diff --git a/src/vg/vg_mem.h b/src/vg/vg_mem.h index 2309707..8406b33 100644 --- a/src/vg/vg_mem.h +++ b/src/vg/vg_mem.h @@ -77,6 +77,11 @@ struct vg_linear_allocator /* */ /* */ /* */ + +#ifdef _WIN32 + /* 32 bit pointers! */ + u8 padding[ 8 ]; +#endif }; #pragma pack(pop) diff --git a/src/vg/vg_steam_friends.h b/src/vg/vg_steam_friends.h index 64ea6b4..587e7fc 100644 --- a/src/vg/vg_steam_friends.h +++ b/src/vg/vg_steam_friends.h @@ -4,12 +4,19 @@ #include "vg_steam.h" #if defined( VALVE_CALLBACK_PACK_SMALL ) + ; #pragma pack( push, 4 ) #elif defined( VALVE_CALLBACK_PACK_LARGE ) #pragma pack( push, 8 ) #endif /* ... */ +typedef struct GameOverlayActivated_t GameOverlayActivated_t; +struct GameOverlayActivated_t +{ + u8 m_bActive; // true if it's just been activated, false otherwise +}; +enum { k_iGameOverlayActivated = k_iSteamFriendsCallbacks + 31 }; #pragma pack(pop) diff --git a/src/vg/vg_ui.h b/src/vg/vg_ui.h index 6c970af..0c4b415 100644 --- a/src/vg/vg_ui.h +++ b/src/vg/vg_ui.h @@ -130,7 +130,7 @@ struct struct ui_vert *vertex_buffer; u16 *indice_buffer; - u32 num_verts, num_indices; + u32 max_verts, max_indices, cur_vert, cur_indice; ui_rect clipping; ui_rect cursor; @@ -176,8 +176,9 @@ VG_STATIC void ui_init_context(void) * Vertex buffer * ---------------------------------------- */ - u32 index_buffer_size = 20000, - vertex_buffer_size = (index_buffer_size+(index_buffer_size/2)); + + vg_uictx.max_indices = 20000; + vg_uictx.max_verts = 30000; /* Generate the buffer we are gonna be drawing to */ glGenVertexArrays( 1, &vg_uictx.vao ); @@ -188,13 +189,13 @@ VG_STATIC void ui_init_context(void) glBindBuffer( GL_ARRAY_BUFFER, vg_uictx.vbo ); glBufferData( GL_ARRAY_BUFFER, - vertex_buffer_size * sizeof( struct ui_vert ), + vg_uictx.max_verts * sizeof( struct ui_vert ), NULL, GL_DYNAMIC_DRAW ); glBindVertexArray( vg_uictx.vao ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, vg_uictx.ebo ); glBufferData( GL_ELEMENT_ARRAY_BUFFER, - index_buffer_size * sizeof( u16 ), NULL, GL_DYNAMIC_DRAW ); + vg_uictx.max_indices * sizeof( u16 ), NULL, GL_DYNAMIC_DRAW ); VG_CHECK_GL_ERR(); @@ -224,8 +225,8 @@ VG_STATIC void ui_init_context(void) VG_CHECK_GL_ERR(); /* Alloc RAM default context */ - u32 vert_size = vertex_buffer_size*sizeof(struct ui_vert), - inds_size = index_buffer_size *sizeof(u16); + u32 vert_size = vg_uictx.max_verts*sizeof(struct ui_vert), + inds_size = vg_uictx.max_indices*sizeof(u16); vg_uictx.vertex_buffer = vg_linear_alloc( vg_mem.rtmemory, vert_size ); vg_uictx.indice_buffer = vg_linear_alloc( vg_mem.rtmemory, inds_size ); @@ -271,7 +272,7 @@ static struct ui_vert *ui_fill_rect_uv( ui_rect rect, u32 colour, ui_px uv[4] ); VG_STATIC void ui_draw( m3x3f view_override ) { - u32 num_indices_normal = vg_uictx.num_indices; + u32 num_indices_normal = vg_uictx.cur_indice; /* Append images to back of buffer */ for( int i = 0; i < vg_uictx.image_count; i ++ ) @@ -284,12 +285,12 @@ VG_STATIC void ui_draw( m3x3f view_override ) glBindBuffer( GL_ARRAY_BUFFER, vg_uictx.vbo ); glBufferSubData( GL_ARRAY_BUFFER, 0, - vg_uictx.num_verts * sizeof( struct ui_vert ), + vg_uictx.cur_vert * sizeof( struct ui_vert ), vg_uictx.vertex_buffer ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, vg_uictx.ebo ); glBufferSubData( GL_ELEMENT_ARRAY_BUFFER, 0, - vg_uictx.num_indices * sizeof( u16 ), + vg_uictx.cur_indice * sizeof( u16 ), vg_uictx.indice_buffer ); glEnable(GL_BLEND); @@ -490,8 +491,13 @@ VG_STATIC void ui_release_clip(void) static struct ui_vert *ui_fill_rect_uv( ui_rect rect, u32 colour, ui_px uv[4] ) { - struct ui_vert *vertices = &vg_uictx.vertex_buffer[ vg_uictx.num_verts ]; - u16 *indices = &vg_uictx.indice_buffer[ vg_uictx.num_indices ]; + /* this if far from ideal but stops us from crashing */ + if( (vg_uictx.cur_vert + 6 > vg_uictx.max_verts) || + (vg_uictx.cur_indice + 4 > vg_uictx.max_indices)) + return vg_uictx.vertex_buffer; + + struct ui_vert *vertices = &vg_uictx.vertex_buffer[ vg_uictx.cur_vert ]; + u16 *indices = &vg_uictx.indice_buffer[ vg_uictx.cur_indice ]; vertices[0].co[0] = rect[0]; vertices[0].co[1] = rect[1]; @@ -513,7 +519,7 @@ static struct ui_vert *ui_fill_rect_uv( ui_rect rect, u32 colour, ui_px uv[4] ) vertices[3].uv[0] = uv[0]; vertices[3].uv[1] = uv[3]; vertices[3].colour = colour; - u16 ind_start = vg_uictx.num_verts; + u16 ind_start = vg_uictx.cur_vert; ui_rect_copy( vg_uictx.clipping, vertices[0].clip ); ui_rect_copy( vg_uictx.clipping, vertices[1].clip ); @@ -528,8 +534,8 @@ static struct ui_vert *ui_fill_rect_uv( ui_rect rect, u32 colour, ui_px uv[4] ) indices[4] = ind_start+3; indices[5] = ind_start+2; - vg_uictx.num_indices += 6; - vg_uictx.num_verts += 4; + vg_uictx.cur_indice += 6; + vg_uictx.cur_vert += 4; return vertices; } @@ -664,8 +670,8 @@ VG_STATIC void ui_begin( ui_px res_x, ui_px res_y ) vg_uictx.stack_count = 1; - vg_uictx.num_verts = 0; - vg_uictx.num_indices = 0; + vg_uictx.cur_vert = 0; + vg_uictx.cur_indice = 0; ui_release_clip();