clean up overlay init code
[carveJwlIkooP6JGAAIwe30JlM.git] / model.c
diff --git a/model.c b/model.c
index 9b704cd0df2196b4ccc556237dbd25cf1b5fa2a3..19f45f2d0466c8d3c55e1aca8160595b6e242431 100644 (file)
--- a/model.c
+++ b/model.c
@@ -5,15 +5,18 @@
 #pragma once
 
 #include "vg/vg_io.h"
+
+#ifndef C0_STOPGAP
 #include "vg/vg_async.h"
 #include "vg/vg_tex.h"
+#endif
 #include "vg/vg_msg.h"
 #include "vg/vg_string.h"
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
 #include "model.h"
-#include "render.h"
+#include "shader_props.h"
 
 static void mdl_load_fatal_corrupt( mdl_context *mdl )
 {
@@ -81,7 +84,8 @@ static void mdl_load_array_file( mdl_context *mdl, mdl_array_ptr *ptr,
    if( arr->item_count )
    {
       u32 size = stride*arr->item_count;
-      ptr->data = vg_linear_alloc( lin_alloc, vg_align8(size) );
+      ptr->data = lin_alloc? vg_linear_alloc( lin_alloc, vg_align8(size) ):
+                             malloc( size );
       mdl_load_array_file_buffer( mdl, arr, ptr->data, stride );
    }
    else
@@ -283,6 +287,9 @@ int mdl_load_materials( mdl_context *mdl, void *lin_alloc )
    mdl_array_ptr data;
    _mdl_load_array( mdl, &data, "shader_data", vg_mem.scratch, 1 );
 
+   if( !lin_alloc )
+      return 1;
+
    for( u32 i=0; i<mdl_arrcount(&mdl->materials); i ++ )
    {
       mdl_material *mat = mdl_arritm( &mdl->materials, i );
@@ -409,6 +416,7 @@ int mdl_pstreq( mdl_context *mdl, u32 pstr, const char *str, u32 djb2 )
  * ----------------------------------------------------------------------------
  */
 
+#ifndef C0_STOPGAP
 static void mesh_upload( glmesh *mesh,
                             mdl_vert *verts, u32 vert_count,
                             u32 *indices, u32 indice_count )
@@ -494,6 +502,7 @@ void mdl_draw_submesh( mdl_submesh *sm )
 {
    mesh_drawn( sm->indice_start, sm->indice_count );
 }
+#endif
 
 mdl_mesh *mdl_find_mesh( mdl_context *mdl, const char *name )
 {
@@ -518,6 +527,7 @@ mdl_submesh *mdl_find_submesh( mdl_context *mdl, const char *mesh_name )
    return mdl_arritm( &mdl->submeshs, mesh->submesh_start );
 }
 
+#ifndef C0_STOPGAP
 struct payload_glmesh_load
 {
    mdl_vert *verts;
@@ -629,3 +639,4 @@ void mdl_async_full_load_std( mdl_context *mdl )
                                VG_TEX2D_CLAMP|VG_TEX2D_NEAREST, &tex->glname );
    }
 }
+#endif