fix: shader recompile, fix: ui string length count vt codes, change: vg_camera now... vg3
authorhgn <hgodden00@gmail.com>
Mon, 17 Feb 2025 20:04:20 +0000 (20:04 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 17 Feb 2025 20:04:20 +0000 (20:04 +0000)
vg_camera.c
vg_camera.h
vg_engine.c
vg_loader.c
vg_shader.c
vg_ui/imgui.c
vg_ui/imgui.h

index 3828645eb0ced1b4b925438a9d05543ca69a7a14..cb44a56794c2e9614c500df5e726354b90649ee5 100644 (file)
@@ -64,12 +64,10 @@ void vg_camera_update_view( vg_camera *cam )
 /*
  * 3) [fov,nearz,farz] -> projection matrix
  */
-void vg_camera_update_projection( vg_camera *cam )
+void vg_camera_update_projection( vg_camera *cam, f32 vw, f32 vh )
 {
    m4x4_copy( cam->mtx.p,  cam->mtx_prev.p );
-   m4x4_projection( cam->mtx.p, cam->fov,
-                    (float)vg.window_x / (float)vg.window_y, 
-                    cam->nearz, cam->farz );
+   m4x4_projection( cam->mtx.p, cam->fov, (float)vw / (float)vh, cam->nearz, cam->farz );
 }
 
 /*
index 45d34440730791214b6065b24ecbd95f06345a53..a0846b0fcc1ec4e4edb8783ba8bd30dea63d119b 100644 (file)
@@ -43,7 +43,7 @@ void vg_camera_update_view( vg_camera *cam );
 /*
  * 3) [fov,nearz,farz] -> projection matrix
  */
-void vg_camera_update_projection( vg_camera *cam );
+void vg_camera_update_projection( vg_camera *cam, f32 vw, f32 vh );
 
 /*
  * 4) [projection matrix, view matrix] -> previous pv, new pv 
index b7fd4c61868a9f430a3d160cffd4e527e2bd0fa9..6f0d519cb598d25deb82329a223590191920d6cb 100644 (file)
@@ -239,8 +239,7 @@ static void _vg_process_events(void)
 
             if( !w || !h )
             {
-               vg_warn( "Got a invalid framebuffer size: "
-                        "%dx%d... ignoring\n", w, h );
+               vg_warn( "Got a invalid framebuffer size: %dx%d... ignoring\n", w, h );
             }
             else
             {
@@ -249,8 +248,9 @@ static void _vg_process_events(void)
                _vg_magi_area_change( delta );
                vg.window_x = w;
                vg.window_y = h;
-
+               
                vg_framebuffer_update_sizes();
+               vg_framebuffer_resize( vg.window_x, vg.window_y );
             }
          }
          else if( event.window.event == SDL_WINDOWEVENT_CLOSE )
index b49ea122925c0c9b1eda99171b90278fe29052d4..9908689d2a1fc8a5f676a44737a4787e34e5ae05 100644 (file)
@@ -141,7 +141,7 @@ void vg_loader_render_ring( f32 opacity )
    opacity *= opacity;
 
    glUseProgram( _shader_loader.id );
-       glUniform1f( glGetUniformLocation( _shader_loader.id, "uTime" ), vg.time );
+       glUniform1f( glGetUniformLocation( _shader_loader.id, "uTime" ), vg.time_real );
    f32 ratio = (f32)vg.window_x / (f32)vg.window_y;
    glUniform1f( glGetUniformLocation( _shader_loader.id, "uRatio"), ratio );
    glUniform1f( glGetUniformLocation( _shader_loader.id, "uOpacity"), opacity );
index bafab346b09c10c2246ad5bfb498355842a70777..344120794af70c2e2c47847f3688ef159ba225fc 100644 (file)
@@ -218,6 +218,10 @@ int vg_shaders_live_recompile( int argc, const char *argv[] )
       vg_recompile_shader( shader );
    }
 
+#ifdef VG_CUSTOM_SHADERS
+   vg_auto_shader_link();
+#endif
+
    return 0;
 }
 
index 1a4ea5bd15f1692a410e8e82812a4059d20340f8..dbcbe5e3e3c9a1c53ef29ae6e252ee4d4daee0bf 100644 (file)
@@ -335,7 +335,21 @@ ui_px ui_text_line_width( ui_context *ctx, const char *str )
    const char *_c = str;
    u8 c;
 
-   while( (c = *(_c ++)) ){
+   while( (c = *(_c ++)) )
+   { 
+      /* skip vt colour codes */
+      if( c == '\x1B' )
+      {
+         while( (c = *(_c ++)) )
+         {
+            if( c == 'm' ) 
+               break;
+         } 
+         
+         if( c == 0 ) break;
+         else continue;
+      }
+
       if( c >= 32 ) length ++;
       else if( c == '\n' ) break;
    }
index 8672cf4369d2640fc55e23c25e51c2d220dca720..8b85392495654bdab3481d8d94bcb3a9cd0d800e 100644 (file)
@@ -316,10 +316,8 @@ enum ui_button_state ui_colourbutton_text(
       ui_rect rect, const char *string, ui_px scale,
       enum ui_scheme_colour colour );
 
-enum ui_button_state ui_button_text( ui_context *ctx, ui_rect rect, 
-                                     const char *string, ui_px scale );
-enum ui_button_state ui_button( ui_context *ctx,
-                                ui_rect inout_panel, const char *string );
+enum ui_button_state ui_button_text( ui_context *ctx, ui_rect rect, const char *string, ui_px scale );
+enum ui_button_state ui_button( ui_context *ctx, ui_rect inout_panel, const char *string );
 void ui_postrender( ui_context *ctx, f32 delta_time );
 enum ui_button_state ui_checkbox_base( ui_context *ctx, 
                                        ui_rect box, i32 *data );