latest
authorhgn <hgodden00@gmail.com>
Fri, 20 Jan 2023 03:15:04 +0000 (03:15 +0000)
committerhgn <hgodden00@gmail.com>
Fri, 20 Jan 2023 03:15:04 +0000 (03:15 +0000)
vg_audio.h
vg_console.h
vg_graph.h [new file with mode: 0644]
vg_profiler.h

index 07c4be09b2d61361c383ba695dfeff70bc674f76..edbe8a2681b4a169f741a183aca611b5208cac46 100644 (file)
@@ -639,7 +639,7 @@ VG_STATIC void audio_entity_get_samples( aatree_ptr id, u32 count, float *buf )
       if( source_mode == k_audio_source_mono )
       {
          i16 *src_buffer = ent->info.source->data,
-             *src = &src_buffer[cursor];
+             *src        = &src_buffer[cursor];
 
          audio_decode_uncompressed_mono( src, samples_this_run, dst );
       }
index dbf57f72be526b3c27240110baca5953164f839a..5a137e3f05222366239791a68866745d474a0fda 100644 (file)
 #include "vg/vg_ui.h"
 #include "vg/vg_log.h"
 
+#define VG_VAR_F32_PERSISTENT( NAME )  \
+   vg_var_push( (struct vg_var){       \
+      .name = #NAME,                   \
+      .data = &NAME,                   \
+      .data_type = k_var_dtype_f32,    \
+      .persistent = 1                  \
+   });
+
+#define VG_VAR_F32( NAME )             \
+   vg_var_push( (struct vg_var){       \
+      .name = #NAME,                   \
+      .data = &NAME,                   \
+      .data_type = k_var_dtype_f32,    \
+   });
+
+#define VG_VAR_I32_PERSISTENT( NAME )  \
+   vg_var_push( (struct vg_var){       \
+      .name = #NAME,                   \
+      .data = &NAME,                   \
+      .data_type = k_var_dtype_i32,    \
+      .persistent = 1                  \
+   });
+
+#define VG_VAR_I32( NAME )             \
+   vg_var_push( (struct vg_var){       \
+      .name = #NAME,                   \
+      .data = &NAME,                   \
+      .data_type = k_var_dtype_i32,    \
+   });
+
 typedef struct vg_var vg_var;
 typedef struct vg_cmd vg_cmd;
 
@@ -46,7 +76,7 @@ struct vg_console
 
                int persistent; /* Should this var be stored to cfg/auto.conf? */
        } 
-       vars[ 32 ];
+       vars[ 64 ];
        
        struct vg_cmd
        {
diff --git a/vg_graph.h b/vg_graph.h
new file mode 100644 (file)
index 0000000..fac1984
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef VG_GRAPH_H
+#define VG_GRAPH_H
+
+#define VG_GAME
+#include "vg/vg.h"
+
+enum { k_vg_graph_max_samples  = 1024 };
+enum { k_vg_graph_max_vertices = k_vg_graph_max_samples * 2 };
+enum { k_vg_graph_max_indices  = (k_vg_graph_max_samples-1) * 6 };
+
+struct vg_graph
+{
+   GLuint vao, vbo, ebo;
+};
+
+VG_STATIC void vg_graph_init( struct vg_graph *graph )
+{
+   vg_acquire_thread_sync();
+   {
+      glGenVertexArrays( 1, &graph->vao );
+      glGenBuffers( 1, &graph->vbo );
+      glGenBuffers( 1, &graph->ebo );
+      glBindVertexArray( graph->vao );
+
+      size_t stride = sizeof(v2f);
+
+      glBindBuffer( GL_ARRAY_BUFFER, graph->vbo );
+      glBufferData( GL_ARRAY_BUFFER, k_vg_graph_max_vertices*stride, 
+                                     NULL, GL_DYNAMIC_DRAW );
+
+      glBindVertexArray( graph->vao );
+      glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, graph->ebo );
+      glBufferData( GL_ELEMENT_ARRAY_BUFFER, 
+            k_vg_graph_max_indices*sizeof(u16), NULL,
+            GL_DYNAMIC_DRAW );
+
+      glVertexAttribPointer( 0, 2, GL_FLOAT, GL_FALSE, stride, (void *)0 );
+      glEnableVertexAttribArray( 0 );
+      VG_CHECK_GL_ERR();
+   }
+}
+
+VG_STATIC void vg_graph_add_sample( struct vg_graph *graph )
+{
+   
+}
+
+#endif /* VG_GRAPH_H */
index 944a5bb2a02155e571b9e0b1781bf31e3bce7a7d..c8db76dab3c7ad8bfcf3322eeec37e2e0659e3a3 100644 (file)
@@ -13,8 +13,8 @@ struct vg_profile
 {
    const char *name;
 
-   u64 samples[ VG_PROFILE_SAMPLE_COUNT ];
-   u32 buffer_count, buffer_current;
+   float samples[ VG_PROFILE_SAMPLE_COUNT ];
+   u32   buffer_count, buffer_current;
 
    enum profile_mode
    {
@@ -41,7 +41,7 @@ VG_STATIC void vg_profile_increment( struct vg_profile *profile )
    if( profile->buffer_current >= VG_PROFILE_SAMPLE_COUNT )
       profile->buffer_current = 0;
 
-   profile->samples[ profile->buffer_current ] = 0;
+   profile->samples[ profile->buffer_current ] = 0.0f;
 }
 
 VG_STATIC void vg_profile_end( struct vg_profile *profile )
@@ -51,7 +51,7 @@ VG_STATIC void vg_profile_end( struct vg_profile *profile )
 
    if( profile->mode == k_profile_mode_frame )
    {
-      profile->samples[ profile->buffer_current ] = delta;
+      profile->samples[ profile->buffer_current ] = (float)delta;
       vg_profile_increment( profile );
    }
    else
@@ -60,6 +60,12 @@ VG_STATIC void vg_profile_end( struct vg_profile *profile )
    }
 }
 
+VG_STATIC void vg_profile_graph_sample( struct vg_profile *profile, float s )
+{
+   profile->samples[ profile->buffer_current ] = s;
+   vg_profile_increment( profile );
+}
+
 VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count,
                               float budget, ui_rect panel, u32 colour_offset )
 {
@@ -90,7 +96,7 @@ VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count,
    u32 colours[] = { 0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000,
                      0xffff00ff, 0xffffff00 };
 
-   double rate_mul = 1000.0 / (double)SDL_GetPerformanceFrequency();
+   float rate_mul = 1000.0f / (float)SDL_GetPerformanceFrequency();
 
    for( int i=0; i<VG_PROFILE_SAMPLE_COUNT-1; i++ )
    {
@@ -103,7 +109,7 @@ VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count,
          if( ptrs[j] < 0 )
             ptrs[j] = VG_PROFILE_SAMPLE_COUNT-1;
 
-         float sample  = (double)profiles[j]->samples[ptrs[j]] * rate_mul,
+         float sample  = profiles[j]->samples[ptrs[j]] * rate_mul,
                px      = (total  / (budget)) * sw,
                wx      = (sample / (budget)) * sw;