edit build script to not be c0 thing
authorhgn <hgodden00@gmail.com>
Sun, 8 Sep 2024 15:25:50 +0000 (16:25 +0100)
committerhgn <hgodden00@gmail.com>
Sun, 8 Sep 2024 15:25:50 +0000 (16:25 +0100)
.gitignore
build.c
build_control_overlay.c [new file with mode: 0644]
c0_stopgap.c [deleted file]
control_overlay.h
model.c

index db0406a6910105213da81c53d139a5561729a7dc..ac4266bfd493a22f3f28cb3ff685d0a22ba99f20 100755 (executable)
@@ -5,7 +5,7 @@
 *.old
 *.bin
 *.swp
-*.c0
+*.generated
 *.gc
 
 # soft links
diff --git a/build.c b/build.c
index 8a82f4985ba51566170f07265fe73a459d7279e3..f772fd2868483691a77db33321520fd9230f6317 100644 (file)
--- a/build.c
+++ b/build.c
@@ -7,11 +7,9 @@
 #include "vg/vg_msg.h"
 #include "addon_types.h"
 
-#define C0_STOPGAP
 #include "vg/vg_m.h"
 #include "model.h"
 #include "model.c"
-#include "c0_stopgap.c"
 
 /* 
  * Addon metadata utilities 
@@ -150,6 +148,8 @@ void build_game_content( struct vg_project *proj )
    vg_syscall( "mkdir -p bin/%s/tools", proj->uid.buffer );
    vg_syscall( "cp bin/skaterift_blender.zip bin/%s/tools/", proj->uid.buffer );
 }
+   
+#include "build_control_overlay.c"
 
 void build_game_bin( struct vg_project *proj, struct vg_compiler_env *env )
 {
@@ -161,8 +161,8 @@ void build_game_bin( struct vg_project *proj, struct vg_compiler_env *env )
       build_game_metadata();
       vg_low( "\n\n" );
    }
-   
-#include "control_overlay.h"
+
+   build_control_overlay();
 
    struct vg_compiler_conf conf = {0};
 
diff --git a/build_control_overlay.c b/build_control_overlay.c
new file mode 100644 (file)
index 0000000..1b67b37
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Script to load the overlay model and generate an enum referencing each 
+ * submesh by its name.
+ */
+void build_control_overlay(void)
+{
+   FILE *hdr = fopen( "control_overlay.h.generated", "w" );
+   mdl_context ctx;
+   mdl_open( &ctx, "content_skaterift/models/rs_overlay.mdl", NULL );
+   mdl_load_metadata_block( &ctx, NULL );
+   mdl_close( &ctx );
+
+   for( u32 i=0; i<mdl_arrcount( &ctx.meshs ); i ++ )
+   {
+      mdl_mesh *mesh = mdl_arritm( &ctx.meshs, i );
+      fprintf( hdr, "   %s = %u,\n", 
+                  mdl_pstr( &ctx, mesh->pstr_name ), mesh->submesh_start );
+   }
+
+   fclose( hdr );
+}
diff --git a/c0_stopgap.c b/c0_stopgap.c
deleted file mode 100644 (file)
index b33378c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <stdio.h>
-#include <stdarg.h>
-FILE *c0_file = NULL;
-static void c0_start( const char *fn )
-{
-   c0_file = fopen( fn, "w" );
-}
-
-static void c0_end(void)
-{
-   fclose( c0_file );
-   c0_file = NULL;
-}
-
-static void c0_echof( const char *fmt, ... )
-{
-   va_list args;
-   va_start( args, fmt );
-   vfprintf( c0_file, fmt, args );
-   va_end( args );
-}
index 5cf358c3fedcf3fe9b0e3953a8b7455e71a66637..089136de7026cbfaeaa9aedb939b4f6a101fd273 100644 (file)
@@ -1,26 +1,8 @@
 #pragma once
 
-#ifdef C0_STOPGAP /* -> control_overlay.h.c0 */
-
-c0_start( "control_overlay.h.c0" );
-mdl_context ctx;
-mdl_open( &ctx, "content_skaterift/models/rs_overlay.mdl", NULL );
-mdl_load_metadata_block( &ctx, NULL );
-mdl_close( &ctx );
-
-for( u32 i=0; i<mdl_arrcount( &ctx.meshs ); i ++ )
-{
-   mdl_mesh *mesh = mdl_arritm( &ctx.meshs, i );
-   c0_echof( "   %s = %u,\n", 
-               mdl_pstr( &ctx, mesh->pstr_name ), mesh->submesh_start );
-}
-c0_end();
-
-#else
-
 enum control_overlay_mesh
 {
-   #include "control_overlay.h.c0"
+   #include "control_overlay.h.generated"
 };
 
 struct control_overlay
@@ -33,5 +15,3 @@ extern control_overlay;
 
 void control_overlay_render(void);
 void control_overlay_init(void);
-
-#endif
diff --git a/model.c b/model.c
index a623e7b4e201a865915774b957b5f27784415b83..f3f7ab2aa5a25bc63cb6932a5a1b4b45cc1f6749 100644 (file)
--- a/model.c
+++ b/model.c
@@ -6,10 +6,11 @@
 
 #include "vg/vg_io.h"
 
-#ifndef C0_STOPGAP
+#ifdef VG_3D
 #include "vg/vg_async.h"
 #include "vg/vg_tex.h"
 #endif
+
 #include "vg/vg_msg.h"
 #include "vg/vg_string.h"
 #include <string.h>
@@ -421,7 +422,7 @@ int mdl_pstreq( mdl_context *mdl, u32 pstr, const char *str, u32 djb2 )
  * ----------------------------------------------------------------------------
  */
 
-#ifndef C0_STOPGAP
+#ifdef VG_3D
 static void mesh_upload( glmesh *mesh,
                             mdl_vert *verts, u32 vert_count,
                             u32 *indices, u32 indice_count )
@@ -530,7 +531,7 @@ mdl_submesh *mdl_find_submesh( mdl_context *mdl, const char *mesh_name )
    return mdl_arritm( &mdl->submeshs, mesh->submesh_start );
 }
 
-#ifndef C0_STOPGAP
+#ifdef VG_3D
 struct payload_glmesh_load
 {
    mdl_vert *verts;