fix rendering issue in workshop board preview
[carveJwlIkooP6JGAAIwe30JlM.git] / font.h
diff --git a/font.h b/font.h
index c49bc6639f396a5fb27d9a55f2b78b06f2d98add..0647b771a1457ce793466b66370c7a1b4911b77b 100644 (file)
--- a/font.h
+++ b/font.h
@@ -7,6 +7,7 @@
 #include "shaders/model_font.h"
 #include "shaders/scene_font.h"
 #include "world_render.h"
+#include "depth_compare.h"
 
 enum efont_SRglyph{
    k_SRglyph_end           = 0x00, /* control characters */
@@ -56,7 +57,12 @@ enum efont_SRglyph{
    k_SRglyph_kbm_space     = 0xa1,
    k_SRglyph_kbm_return    = 0xa2,
    k_SRglyph_kbm_escape    = 0xa3,
-   k_SRglyph_kbm_mousemove = 0xa4
+   k_SRglyph_kbm_mousemove = 0xa4,
+   k_SRglyph_vg_ret        = 0xa5,
+   k_SRglyph_vg_link       = 0xa6,
+   k_SRglyph_vg_square     = 0xa7,
+   k_SRglyph_vg_triangle   = 0xa8,
+   k_SRglyph_vg_circle     = 0xa9
 };
 
 typedef struct font3d font3d;
@@ -76,11 +82,11 @@ static void font3d_load( font3d *font, const char *mdl_path, void *alloc ){
 
    vg_linear_clear( vg_mem.scratch );
    mdl_array_ptr fonts;
-   mdl_load_array( &font->mdl, &fonts, "ent_font", vg_mem.scratch );
+   MDL_LOAD_ARRAY( &font->mdl, &fonts, ent_font, vg_mem.scratch );
    font->info = *((ent_font *)mdl_arritm(&fonts,0));
 
-   mdl_load_array( &font->mdl, &font->font_variants, "ent_font_variant", alloc);
-   mdl_load_array( &font->mdl, &font->glyphs, "ent_glyph", alloc );
+   MDL_LOAD_ARRAY( &font->mdl, &font->font_variants, ent_font_variant, alloc);
+   MDL_LOAD_ARRAY( &font->mdl, &font->glyphs, ent_glyph, alloc );
 
    vg_linear_clear( vg_mem.scratch );
 
@@ -91,7 +97,7 @@ static void font3d_load( font3d *font, const char *mdl_path, void *alloc ){
    void *data = vg_linear_alloc( vg_mem.scratch, tex0->file.pack_size );
    mdl_fread_pack_file( &font->mdl, &tex0->file, data );
 
-   mdl_async_load_glmesh( &font->mdl, &font->mesh );
+   mdl_async_load_glmesh( &font->mdl, &font->mesh, NULL );
    vg_tex2d_load_qoi_async( data, tex0->file.pack_size, 
                             VG_TEX2D_LINEAR|VG_TEX2D_CLAMP,
                             &font->texture );
@@ -147,17 +153,10 @@ static void font3d_bind( font3d *font, enum font_shader shader,
 
       shader_model_font_uDepthCompare( depth_compare );
       if( depth_compare ){
-         /* TODO: Compress with code in player_render.c */
-         shader_model_font_uTexSceneDepth( 2 );
-         render_fb_bind_texture( gpipeline.fb_main, 2, 2 );
-         v3f inverse;
-         render_fb_inverse_ratio( gpipeline.fb_main, inverse );
-         inverse[2] = skaterift.cam.farz-skaterift.cam.nearz;
-
-         shader_model_font_uInverseRatioDepth( inverse );
-         render_fb_inverse_ratio( NULL, inverse );
-         inverse[2] = cam->farz-cam->nearz;
-         shader_model_font_uInverseRatioMain( inverse );
+         depth_compare_bind( 
+            shader_model_font_uTexSceneDepth,
+            shader_model_font_uInverseRatioDepth,
+            shader_model_font_uInverseRatioMain, cam );
       }
 
       shader_model_font_uPv( cam->mtx.pv );
@@ -171,14 +170,7 @@ static void font3d_bind( font3d *font, enum font_shader shader,
       shader_scene_font_uPv( skaterift.cam.mtx.pv );
       shader_scene_font_uTime( vg.time );
 
-      /* TODO: Code dupe... */
-      world_link_lighting_ub( world, _shader_scene_font.id );
-      world_bind_position_texture( world, _shader_scene_font.id, 
-                                   _uniform_scene_font_g_world_depth, 2 );
-      world_bind_light_array( world, _shader_scene_font.id,
-                                   _uniform_scene_font_uLightsArray, 3 );
-      world_bind_light_index( world, _shader_scene_font.id,
-                                   _uniform_scene_font_uLightsIndex, 4 );
+      WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, scene_font );
 
       bind_terrain_noise();
       shader_scene_font_uCamera( skaterift.cam.transform[3] );