couple fix
authorhgn <hgodden00@gmail.com>
Mon, 31 Oct 2022 03:12:31 +0000 (03:12 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 31 Oct 2022 03:12:31 +0000 (03:12 +0000)
src/vg/vg.h
src/vg/vg_console.h
src/vg/vg_input.h
src/vg/vg_lines.h
src/vg/vg_mem.h
src/vg/vg_steam_friends.h
src/vg/vg_ui.h

index f3456f3199887c8e76c4f0222cefe55732978292..71f4b2a3d853c8c6605559c5a39a18d0486eae2b 100644 (file)
@@ -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 
index 62e311895e9e2bf6513bf950f8a6e11956cd3843..b0758c1f4a64c5429d92ca65a1f645c77d6bbb2f 100644 (file)
@@ -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();
index ac2cce6e2cb4c7dcd8bbf85e829a43c6e67c450c..f7df7511b860b16c4c21ccea526ea2d94eacc0e9 100644 (file)
@@ -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 ++ )
index c0da5b308dd3d313da4b6bb4eeb8912bbb873d35..672a59e84d663b76fa407310d7ca0bc57e27c2e8 100644 (file)
@@ -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 );
 
index 2309707437d97d02a649a102f0c13610f26994c7..8406b3342002f7bbbe9bf3ef2289333a9f86746e 100644 (file)
@@ -77,6 +77,11 @@ struct vg_linear_allocator
    /*                            */
    /*                            */
    /*                            */
+
+#ifdef _WIN32
+   /* 32 bit pointers! */
+   u8 padding[ 8 ];
+#endif
 };
 #pragma pack(pop)
 
index 64ea6b49f6cfeb63832b069a333f6fb59449531d..587e7fc84271fe48cf0b039aeaa2287de5a11a02 100644 (file)
@@ -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)
 
index 6c970aff29698fbabbfeed343a8395c11081aecc..0c4b4159bc5636419e86f430fe185aac93410adb 100644 (file)
@@ -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();