X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_render.h;h=3590cf7480d7215131dc13ef5b073d27e30fce21;hb=d43d7f62ff83799b6d99221d881179814cb239a6;hp=65494a5be204ea8f6e25b6e7adfddadb3f32a4f7;hpb=c2d67378dd5c82de50b8fbbbe222ec6be2da4eee;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_render.h b/world_render.h index 65494a5..3590cf7 100644 --- a/world_render.h +++ b/world_render.h @@ -1,272 +1,74 @@ +/* + * Copyright (C) 2021-2023 Mt.ZERO Software, Harry Godden - All Rights Reserved + */ + #ifndef WORLD_RENDER_H #define WORLD_RENDER_H +#include "camera.h" #include "world.h" -vg_tex2d tex_terrain_colours = { .path = "textures/gradients.qoi", - .flags = VG_TEXTURE_CLAMP|VG_TEXTURE_NEAREST }; - -vg_tex2d tex_terrain_noise = { .path = "textures/garbage.qoi", - .flags = VG_TEXTURE_NEAREST }; - -vg_tex2d tex_alphatest = { .path = "textures/alphatest.qoi", - .flags = VG_TEXTURE_NEAREST }; - -vg_tex2d tex_graffiti = { .path = "textures/graffitibox.qoi", - .flags = VG_TEXTURE_NEAREST }; - -static int world_render_init(void) -{ - vg_info( "Loading default world textures\n" ); - - if( vg_acquire_thread_sync(1) ) - { - vg_tex2d_init( (vg_tex2d *[]){ &tex_terrain_colours, - &tex_terrain_noise, - &tex_alphatest, - &tex_graffiti }, 4 ); - - vg_release_thread_sync(1); - return 1; - } - - return 0; -} - -static void world_render_free(void*_) -{ - vg_tex2d_free( (vg_tex2d *[]){ &tex_terrain_colours, - &tex_terrain_noise, - &tex_alphatest, - &tex_graffiti }, 4 ); -} - - +#include "shaders/scene_standard.h" +#include "shaders/scene_standard_alphatest.h" +#include "shaders/scene_vertex_blend.h" +#include "shaders/scene_terrain.h" +#include "shaders/scene_depth.h" +#include "shaders/scene_position.h" +#include "shaders/model_sky.h" -static void render_world_depth( m4x4f projection, m4x3f camera ); +static const float k_world_light_cube_size = 8.0f; +struct world_render{ + GLuint tex_terrain_noise; + /* rendering */ + glmesh skydome; + double sky_time, sky_rate, sky_target_rate; -/* - * Rendering - */ - -static void bind_terrain_textures(void) -{ - vg_tex2d_bind( &tex_terrain_noise, 0 ); - vg_tex2d_bind( &tex_terrain_colours, 1 ); -} - -static void render_world_vb( m4x4f projection, v3f camera ) -{ - m4x3f identity_matrix; - m4x3_identity( identity_matrix ); - - shader_vblend_use(); - shader_vblend_uTexGarbage(0); - shader_vblend_uTexGradients(1); - shader_link_standard_ub( _shader_vblend.id, 2 ); - bind_terrain_textures(); - - shader_vblend_uPv( projection ); - shader_vblend_uMdl( identity_matrix ); - shader_vblend_uCamera( camera ); - - scene_bind( &world.geo ); - mdl_draw_submesh( &world.sm_geo_vb ); - - mesh_bind( &world.cars ); - -#if 0 - for( int i=0; igate.co[0], camera[3] ); - - if( dist < closest ) - { - closest = dist; - id = i; - } + water; + + v3f render_gate_pos; + struct timer_text{ + char text[8]; + m4x3f transform; + ent_gate *gate; + ent_route *route; } + timer_texts[4]; + u32 timer_text_count; - render_gate( &world.routes.gates[id].gate, playerco, camera ); - v3_lerp( world.render_gate_pos, - world.routes.gates[id].gate.co[0], - 1.0f, - world.render_gate_pos ); -} - -static void render_world( m4x4f projection, m4x3f camera ) -{ - render_sky( camera ); - render_world_routes( projection, camera[3] ); - render_world_vb( projection, camera[3] ); - render_world_alphatest( projection, camera[3] ); - render_terrain( projection, camera[3] ); - - int closest = 0; - float min_dist = INFINITY; + struct text_particle{ + rb_object obj; + m4x3f mlocal; + ent_glyph *glyph; + v4f colour; - for( int i=0; i