update helpers/location to 'frosted' ui
[carveJwlIkooP6JGAAIwe30JlM.git] / font.h
diff --git a/font.h b/font.h
index a5449f906a6860225a1d31aa93ceff4859ed568f..34441ca3071f1913169dba9603d3f60d40b4c3f9 100644 (file)
--- a/font.h
+++ b/font.h
@@ -1,13 +1,12 @@
-#ifndef FONT_H
-#define FONT_H
-
+#pragma once
 #include "model.h"
 #include "entity.h"
-#include "camera.h"
+#include "vg/vg_camera.h"
 #include "shaders/model_font.h"
 #include "shaders/scene_font.h"
 #include "world_render.h"
 #include "depth_compare.h"
+#include <string.h>
 
 enum efont_SRglyph{
    k_SRglyph_end           = 0x00, /* control characters */
@@ -58,11 +57,14 @@ enum efont_SRglyph{
    k_SRglyph_kbm_return    = 0xa2,
    k_SRglyph_kbm_escape    = 0xa3,
    k_SRglyph_kbm_mousemove = 0xa4,
+
+#if 0
    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
+#endif
 };
 
 typedef struct font3d font3d;
@@ -97,7 +99,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 );
@@ -105,11 +107,6 @@ static void font3d_load( font3d *font, const char *mdl_path, void *alloc ){
    mdl_close( &font->mdl );
 }
 
-static void font3d_init(void){
-   shader_model_font_register();
-   shader_scene_font_register();
-}
-
 static u32 font3d_find_variant( font3d *font, const char *name ){
    for( u32 i=0; i<mdl_arrcount( &font->font_variants ); i ++ ){
       ent_font_variant *variant = mdl_arritm( &font->font_variants, i );
@@ -140,18 +137,19 @@ static gui_font3d;
  */
 static void font3d_bind( font3d *font, enum font_shader shader, 
                          int depth_compare, world_instance *world,
-                         camera *cam ){
+                         vg_camera *cam ){
    gui_font3d.shader = shader;
    gui_font3d.font = font;
    glActiveTexture( GL_TEXTURE1 );
    glBindTexture( GL_TEXTURE_2D, font->texture );
 
-   if( shader == k_font_shader_default ){
+   if( shader == k_font_shader_default )
+   {
       shader_model_font_use();
       shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} );
       shader_model_font_uTexMain( 1 );
+      shader_model_font_uDepthMode( depth_compare );
 
-      shader_model_font_uDepthCompare( depth_compare );
       if( depth_compare ){
          depth_compare_bind( 
             shader_model_font_uTexSceneDepth,
@@ -161,8 +159,8 @@ static void font3d_bind( font3d *font, enum font_shader shader,
 
       shader_model_font_uPv( cam->mtx.pv );
    }
-   else if( shader == k_font_shader_world ){
-      assert( world );
+   else if( shader == k_font_shader_world )
+   {
       shader_scene_font_use();
       shader_scene_font_uTexGarbage(0);
       shader_scene_font_uTexMain(1);
@@ -189,7 +187,7 @@ static ent_glyph *font3d_glyph( font3d *font, u32 variant_id, u32 utf32 ){
 }
 
 static void font3d_set_transform( const char *text,
-                                  camera *cam, m4x3f transform ){
+                                  vg_camera *cam, m4x3f transform ){
    v4_copy( (v4f){0.0f,0.0f,0.0f,1.0f}, gui_font3d.offset );
 
    m4x4f prev_mtx;
@@ -297,7 +295,7 @@ static void font3d_draw( const char *text ){
 }
 
 static f32 font3d_simple_draw( u32 variant_id, const char *text, 
-                               camera *cam, m4x3f transform ){
+                               vg_camera *cam, m4x3f transform ){
    if( !text ) return 0.0f;
 
    gui_font3d.variant_id = variant_id;
@@ -323,5 +321,3 @@ static f32 font3d_string_width( u32 variant_id, const char *text ){
 
    return width;
 }
-
-#endif /* FONT_H */