- return (float)value;
-}
-
-VG_STATIC void sfd_encode( u32 row, const char *str )
-{
- int end=0;
- u32 row_h = world_global.sfd.h -1 -row;
-
- for( int i=0; i<world_global.sfd.w; i++ ){
- u32 idx = (world_global.sfd.w*row_h + i) * 2;
-
- if( end ){
- world_global.sfd.buffer[idx] = 0.0f;
- }
- else{
- if( !str[i] )
- end = 1;
-
- world_global.sfd.buffer[idx] = sfd_encode_glyph( str[i] );
- }
- }
-}
-
-VG_STATIC void sfd_update(void)
-{
- for( int i=0; i<world_global.sfd.w*world_global.sfd.h; i++ ){
- float *target = &world_global.sfd.buffer[i*2+0],
- *cur = &world_global.sfd.buffer[i*2+1];
-
- float const rate = vg.time_delta * 15.2313131414f;
- float d1 = *target-*cur;
-
- if( fabsf(d1) > rate ){
- *cur += rate;
- if( *cur > 60.0f )
- *cur -= 60.0f;
- }
- else
- *cur = *target;
- }
-}
-
-VG_STATIC void bind_terrain_noise(void);
-VG_STATIC void sfd_render( world_instance *world, camera *cam, m4x3f transform )
-{
- mesh_bind( &world_global.sfd.mesh_display );
- shader_scene_scoretext_use();
- shader_scene_scoretext_uTexMain(1);
-
- world_link_lighting_ub( world, _shader_scene_scoretext.id );
- world_bind_position_texture( world, _shader_scene_scoretext.id,
- _uniform_scene_scoretext_g_world_depth, 2 );
- world_bind_light_array( world, _shader_scene_scoretext.id,
- _uniform_scene_scoretext_uLightsArray, 3 );
- world_bind_light_index( world, _shader_scene_scoretext.id,
- _uniform_scene_scoretext_uLightsIndex, 4 );
-
- bind_terrain_noise();
-
- glActiveTexture( GL_TEXTURE1 );
- glBindTexture( GL_TEXTURE_2D, tex_scoretex );
-
- m4x4f pvm_prev;
- m4x3_expand( transform, pvm_prev );
- m4x4_mul( cam->mtx_prev.pv, pvm_prev, pvm_prev );
-
- shader_scene_scoretext_uPv( cam->mtx.pv );
- shader_scene_scoretext_uPvmPrev( pvm_prev );
- shader_scene_scoretext_uMdl( transform );
- shader_scene_scoretext_uCamera( cam->transform[3] );
-
- for( int y=0;y<world_global.sfd.h; y++ ){
- for( int x=0; x<world_global.sfd.w; x++ ){
- float value = world_global.sfd.buffer[(y*world_global.sfd.w+x)*2+1];
- shader_scene_scoretext_uInfo( (v3f){ x,y, value } );
- mesh_draw( &world_global.sfd.mesh_display );
- }
- }
-
- shader_scene_vertex_blend_use();
- shader_scene_vertex_blend_uTexGarbage(0);
- shader_scene_vertex_blend_uTexGradients(1);
- world_link_lighting_ub( world, _shader_scene_vertex_blend.id );
- world_bind_position_texture( world, _shader_scene_vertex_blend.id,
- _uniform_scene_vertex_blend_g_world_depth, 2 );
- world_bind_light_array( world, _shader_scene_vertex_blend.id,
- _uniform_scene_vertex_blend_uLightsArray, 3 );
- world_bind_light_index( world, _shader_scene_vertex_blend.id,
- _uniform_scene_vertex_blend_uLightsIndex, 4 );
- bind_terrain_noise();
- glActiveTexture( GL_TEXTURE1 );
- glBindTexture( GL_TEXTURE_2D, tex_scoretex );
-
- shader_scene_vertex_blend_uPv( cam->mtx.pv );
- shader_scene_vertex_blend_uPvmPrev( pvm_prev );
- shader_scene_vertex_blend_uMdl( transform );
- shader_scene_vertex_blend_uCamera( cam->transform[3] );
-
- mesh_bind( &world_global.sfd.mesh_base );
- mdl_draw_submesh( &world_global.sfd.sm_base );
-}
-
-VG_STATIC int world_sfd_test( int argc, const char *argv[] )
-{
- if( argc == 2 ){
- int row = vg_min( vg_max(atoi(argv[0]),0), world_global.sfd.h);
- sfd_encode( row, argv[1] );
- }
-
- return 0;
-}
-
-VG_STATIC void world_sfd_init(void)
-{
- vg_info( "world_sfd_init\n" );
- shader_scene_scoretext_register();
- vg_console_reg_cmd( "sfd", world_sfd_test, NULL );
-
- vg_linear_clear( vg_mem.scratch );
-
- mdl_context mscoreboard;
- mdl_open( &mscoreboard, "models/rs_scoretext.mdl", vg_mem.scratch );
- mdl_load_metadata_block( &mscoreboard, vg_mem.scratch );
- mdl_async_load_glmesh( &mscoreboard, &world_global.sfd.mesh_base );
-
- mdl_load_mesh_block( &mscoreboard, vg_mem.scratch );
-
- scene_context *scene = &world_global.sfd.scene;
- vg_async_item *call = scene_alloc_async( scene,
- &world_global.sfd.mesh_display,
- 3000, 8000 );
-
-
- mdl_mesh *m_backer = mdl_find_mesh( &mscoreboard, "backer" ),
- *m_card = mdl_find_mesh( &mscoreboard, "score_card" );
-
- mdl_submesh
- *sm_backer = mdl_arritm( &mscoreboard.submeshs, m_backer->submesh_start ),
- *sm_card = mdl_arritm( &mscoreboard.submeshs, m_card->submesh_start );
- world_global.sfd.sm_base = *sm_backer;
-
- m4x3f identity;
- m4x3_identity( identity );
-
- for( int i=0;i<4;i++ ){
- u32 vert_start = scene->vertex_count;
- scene_add_mdl_submesh( scene, &mscoreboard, sm_card, identity );
-
- for( int j=0; j<sm_card->vertex_count; j++ ){
- scene_vert *vert = &scene->arrvertices[ vert_start+j ];
-
- float const k_glyph_uvw = 1.0f/64.0f;
- vert->uv[0] -= k_glyph_uvw * (float)(i-1);
- vert->norm[3] = i*42;
- }
- }
-
- vg_async_dispatch( call, async_scene_upload );
- vg_tex2d_load_qoi_async_file( "textures/scoretext.qoi",
- VG_TEX2D_CLAMP|VG_TEX2D_NEAREST,
- &tex_scoretex );
-
- mdl_close( &mscoreboard );
-
- int w = 27,
- h = 13;