update overlay to have ps controls too
[carveJwlIkooP6JGAAIwe30JlM.git] / skaterift.c
1 /*
2 * =============================================================================
3 *
4 * Copyright . . . -----, ,----- ,---. .---.
5 * 2021-2024 |\ /| | / | | | | /|
6 * | \ / | +-- / +----- +---' | / |
7 * | \ / | | / | | \ | / |
8 * | \/ | | / | | \ | / |
9 * ' ' '--' [] '----- '----- ' ' '---' SOFTWARE
10 *
11 * =============================================================================
12 */
13
14 #define SR_ALLOW_REWIND_HUB
15
16 #ifdef _WIN32
17 #include <winsock2.h>
18 #endif
19
20 /*
21 * system headers
22 * --------------------- */
23
24 #include "skaterift.h"
25 #include "steam.h"
26 #include "render.h"
27 #include "vg/vg_opt.h"
28 #include "vg/vg_loader.h"
29 #include "vg/vg_io.h"
30
31 #include "world.h"
32
33 #include "font.h"
34 #include "player.h"
35
36 #include "network.h"
37 #include "menu.h"
38 #include "vehicle.h"
39 #include "save.h"
40 #include "player_remote.h"
41 #include "particle.h"
42 #include "trail.h"
43 #include "freecam.h"
44 #include "ent_tornado.h"
45 #include "ent_miniworld.h"
46 #include "ent_skateshop.h"
47 #include "ent_npc.h"
48 #include "world_map.h"
49 #include "gui.h"
50 #include "workshop.h"
51 #include "audio.h"
52 #include "player_render.h"
53 #include "control_overlay.h"
54
55 struct skaterift_globals skaterift =
56 {
57 .op = k_async_op_clientloading, .time_rate = 1.0f, .demo_mode = 1,
58 .hub_world = "maps/dev_hub",
59 };
60
61 static int k_tools_mode = 0;
62
63 int main( int argc, char *argv[] )
64 {
65 network_set_host( "skaterift.com", NULL );
66 vg_mem.use_libc_malloc = 0;
67 vg_set_mem_quota( 160*1024*1024 );
68 vg_enter( argc, argv, "Voyager Game Engine" );
69 return 0;
70 }
71
72 void vg_launch_opt(void)
73 {
74 const char *arg;
75 if( vg_long_opt( "noauth" ) ){
76 network_client.auth_mode = eServerModeNoAuthentication;
77 }
78
79 if( (arg = vg_long_opt_arg( "server" )) )
80 {
81 network_set_host( arg, NULL );
82 }
83
84 if( vg_long_opt( "tools" ) ){
85 k_tools_mode = 1;
86 }
87
88 if( vg_long_opt( "demo" ) ){
89 skaterift.demo_mode = 1;
90 }
91
92 if( (arg = vg_long_opt_arg( "world" )) ){
93 skaterift.hub_world = arg;
94 }
95 }
96
97 void vg_preload(void)
98 {
99 vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" );
100 vg_info(" 2021-2023 |\\ /| | / | | | | /| \n" );
101 vg_info(" | \\ / | +-- / +----- +---' | / | \n" );
102 vg_info(" | \\ / | | / | | \\ | / | \n" );
103 vg_info(" | \\/ | | / | | \\ | / | \n" );
104 vg_info(" ' ' '--' [] '----- '----- ' ' '---' "
105 "SOFTWARE\n" );
106
107 /* please forgive me! */
108 u32 sz; char *drm;
109 if( (drm = vg_file_read_text( vg_mem.scratch, "DRM", &sz )) )
110 if( !strcmp(drm, "blibby!") )
111 skaterift.demo_mode = 0;
112
113 vg_loader_step( remote_players_init, NULL );
114
115 if( k_tools_mode )
116 return;
117
118 steam_init();
119 vg_loader_step( NULL, steam_end );
120 vg_loader_step( network_init, network_end );
121 }
122
123 static void async_skaterift_player_start( void *payload, u32 size ){
124 world_switch_instance(0);
125 }
126
127 static void async_call_ready( void *payload, u32 size )
128 {
129 skaterift.op = k_async_op_none;
130
131 if( network_client.auto_connect )
132 network_client.user_intent = k_server_intent_online;
133
134 menu_at_begin();
135 }
136
137 static void skaterift_restore_state(void)
138 {
139 savedata_file sav;
140 skaterift_read_main_savedata( &sav );
141
142 vg_msg kvsav;
143 vg_msg_init( &kvsav, sav.buf, sizeof(sav.buf) );
144
145 u32 ach;
146 vg_msg_getkvintg( &kvsav, "ach", k_vg_msg_u32, &ach, NULL );
147 skaterift.achievements |= ach;
148
149 u32 board_reg_id = time(NULL) % addon_count( k_addon_type_board, 0 ),
150 player_reg_id = (time(NULL)+44) % addon_count( k_addon_type_player, 0 );
151
152 vg_msg_cursor orig = kvsav.cur;
153 if( vg_msg_seekframe( &kvsav, "player" ) ){
154 addon_alias q;
155
156 /* board */
157 skaterift_read_addon_alias( &kvsav, "board", k_addon_type_board, &q );
158 u32 reg_id = addon_match( &q );
159 if( reg_id != 0xffffffff )
160 board_reg_id = reg_id;
161
162 /* playermodel */
163 skaterift_read_addon_alias( &kvsav, "playermodel",
164 k_addon_type_player, &q );
165 reg_id = addon_match( &q );
166 if( reg_id != 0xffffffff )
167 player_reg_id = reg_id;
168 }
169
170 localplayer.board_view_slot =
171 addon_cache_create_viewer( k_addon_type_board, board_reg_id );
172 localplayer.playermodel_view_slot =
173 addon_cache_create_viewer( k_addon_type_player, player_reg_id );
174
175 kvsav.cur = orig;
176 }
177
178 static addon_reg *skaterift_mount_world_unloadable( const char *path, u32 ext ){
179 addon_reg *reg = addon_mount_local_addon( path, k_addon_type_world, ".mdl" );
180 if( !reg ) vg_fatal_error( "world not found\n" );
181 reg->flags |= (ADDON_REG_HIDDEN | ext);
182 return reg;
183 }
184
185 static void skaterift_load_world_content(void){
186 /* hub world */
187 addon_reg *hub = skaterift_mount_world_unloadable( skaterift.hub_world, 0 );
188 skaterift_mount_world_unloadable( "maps/mp_spawn",
189 ADDON_REG_CITY|ADDON_REG_PREMIUM );
190 skaterift_mount_world_unloadable( "maps/mp_mtzero",
191 ADDON_REG_MTZERO|ADDON_REG_PREMIUM );
192 skaterift_mount_world_unloadable( "maps/dev_tutorial", 0 );
193 skaterift_mount_world_unloadable( "maps/dev_flatworld", 0 );
194 skaterift_mount_world_unloadable( "maps/mp_line1",
195 ADDON_REG_MTZERO|ADDON_REG_PREMIUM );
196
197 world_static.load_state = k_world_loader_load;
198
199 struct world_load_args args = {
200 .purpose = k_world_purpose_hub,
201 .reg = hub
202 };
203 skaterift_world_load_thread( &args );
204 }
205
206 static void skaterift_load_player_content(void)
207 {
208 particle_alloc( &particles_grind, 300 );
209 particle_alloc( &particles_env, 200 );
210
211 player_load_animation_reference( "models/ch_none.mdl" );
212 player_model_load( &localplayer.fallback_model, "models/ch_none.mdl" );
213 player__bind();
214 player_board_load( &localplayer.fallback_board, "models/board_none.mdl" );
215 }
216
217 void vg_load(void)
218 {
219 if( k_tools_mode ){
220 vg_async_call( async_call_ready, NULL, 0 );
221 return;
222 }
223
224 vg_audio.always_keep_compressed = 1;
225
226 vg_console_reg_cmd( "load_world", skaterift_load_world_command, NULL );
227 vg_console_reg_var( "immobile", &localplayer.immobile, k_var_dtype_i32, 0 );
228
229 vg_loader_step( render_init, NULL );
230 vg_loader_step( menu_init, NULL );
231 vg_loader_step( control_overlay_init, NULL );
232 vg_loader_step( world_init, NULL );
233 vg_loader_step( vehicle_init, NULL );
234 vg_loader_step( gui_init, NULL );
235
236 vg_loader_step( player_init, NULL );
237 vg_loader_step( player_ragdoll_init, NULL );
238 vg_loader_step( npc_init, NULL );
239
240 /* content stuff */
241 vg_loader_step( addon_system_init, NULL );
242 vg_loader_step( workshop_init, NULL );
243 vg_loader_step( skateshop_init, NULL );
244 vg_loader_step( ent_tornado_init, NULL );
245 vg_loader_step( skaterift_replay_init, NULL );
246 vg_loader_step( skaterift_load_player_content, NULL );
247
248 /* --------------------- */
249
250 vg_bake_shaders();
251 vg_loader_step( audio_init, NULL );
252
253 /* 'systems' are completely loaded now */
254
255 /* Completing addon registrations
256 * -------------------------------------
257 */
258
259 /* load home/permanent world manually */
260 vg_loader_step( skaterift_load_world_content, NULL );
261 vg_async_call( async_skaterift_player_start, NULL, 0 );
262 vg_async_stall();
263
264 vg_console_load_autos();
265 menu_link();
266
267 addon_mount_content_folder( k_addon_type_player,
268 "playermodels", ".mdl" );
269 addon_mount_content_folder( k_addon_type_board, "boards", ".mdl" );
270 addon_mount_content_folder( k_addon_type_world, "maps", ".mdl" );
271 addon_mount_workshop_items();
272 vg_async_call( async_addon_reg_update, NULL, 0 );
273 vg_async_stall();
274
275 /* and now */
276 skaterift_restore_state();
277 update_ach_models();
278
279 vg_loader_step( NULL, skaterift_autosave_synchronous );
280
281 //board_processview_thread(NULL);
282 vg_async_call( async_call_ready, NULL, 0 );
283 }
284
285 static void draw_origin_axis(void){
286 vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 1.0f, 0.0f, 0.0f }, 0xffff0000 );
287 vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 1.0f, 0.0f }, 0xff00ff00 );
288 vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 0.0f, 1.0f }, 0xff0000ff );
289 }
290 void skaterift_change_client_world_preupdate(void);
291
292 /*
293 * UPDATE LOOP
294 * ---------------------------------------------------------------------------*/
295
296 void vg_pre_update(void)
297 {
298 skaterift_preupdate_inputs();
299
300 if( k_tools_mode ) return;
301
302 steam_update();
303 skaterift_change_client_world_preupdate();
304
305 if( skaterift.op == k_async_op_clientloading ) return;
306
307 draw_origin_axis();
308 addon_system_pre_update();
309 skateshop_world_preview_preupdate();
310 network_update();
311
312 /* time rate */
313 f32 target = 1;
314 if( skaterift.activity & (k_skaterift_replay|k_skaterift_menu|
315 k_skaterift_world_map) )
316 {
317 target = 0;
318 }
319
320 vg_slewf( &skaterift.time_rate, target, vg.time_frame_delta * (1.0f/0.3f) );
321 vg.time_rate = vg_smoothstepf( skaterift.time_rate );
322
323 /* TODO: how can we compress this? */
324 ent_miniworld_preupdate();
325 world_entity_focus_preupdate();
326
327 if( skaterift.activity != k_skaterift_menu )
328 {
329 player__pre_update();
330 }
331
332 skaterift_replay_pre_update();
333 remote_sfx_pre_update();
334 skateshop_world_preupdate( world_current_instance() );
335
336 world_update( world_current_instance(), localplayer.rb.co );
337 audio_ambient_sprites_update( world_current_instance(), localplayer.rb.co );
338 world_map_pre_update();
339 }
340
341 void vg_fixed_update(void)
342 {
343 if( k_tools_mode ) return;
344 if( skaterift.op == k_async_op_clientloading ) return;
345
346 world_routes_fixedupdate( world_current_instance() );
347 player__update();
348 vehicle_update_fixed();
349 }
350
351 void vg_post_update(void)
352 {
353 if( k_tools_mode ) return;
354 if( skaterift.op == k_async_op_clientloading ) return;
355
356 player__post_update();
357
358 float dist;
359 int sample_index;
360 world_audio_sample_distances( localplayer.rb.co, &sample_index, &dist );
361
362 audio_lock();
363 vg_dsp.echo_distances[sample_index] = dist;
364
365 v3f ears = { 1.0f,0.0f,0.0f };
366 m3x3_mulv( skaterift.cam.transform, ears, ears );
367 v3_copy( ears, vg_audio.external_listener_ears );
368 v3_copy( skaterift.cam.transform[3], vg_audio.external_listener_pos );
369
370 if( localplayer.gate_waiting ){
371 m4x3_mulv( localplayer.gate_waiting->transport,
372 vg_audio.external_listener_pos,
373 vg_audio.external_listener_pos );
374 }
375
376 v3_copy( localplayer.rb.v, vg_audio.external_lister_velocity );
377 audio_unlock();
378
379 vehicle_update_post();
380 skaterift_autosave_update();
381 }
382
383 /*
384 * RENDERING
385 * ---------------------------------------------------------------------------*/
386
387 void vg_framebuffer_resize( int w, int h ){
388 render_fb_resize();
389 }
390
391 static void present_view_with_post_processing(void){
392 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
393 glViewport( 0,0, vg.window_x, vg.window_y );
394
395 glEnable(GL_BLEND);
396 glDisable(GL_DEPTH_TEST);
397 glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);
398 glBlendEquation(GL_FUNC_ADD);
399
400 v2f inverse;
401 render_fb_inverse_ratio( gpipeline.fb_main, inverse );
402
403 if( k_blur_effect ){
404 shader_blitblur_use();
405 shader_blitblur_uTexMain( 0 );
406 shader_blitblur_uTexMotion( 1 );
407 shader_blitblur_uBlurStrength( k_blur_strength /
408 (vg.time_frame_delta*60.0) );
409 shader_blitblur_uInverseRatio( inverse );
410
411 inverse[0] -= 0.0001f;
412 inverse[1] -= 0.0001f;
413 shader_blitblur_uClampUv( inverse );
414
415 static f64 effect_time = 133.0;
416 effect_time += vg.time_frame_delta;
417 shader_blitblur_uTime( effect_time );
418
419 f32 glitch_strength = 0.0f;
420 if( skaterift.activity == k_skaterift_replay ){
421 glitch_strength = 0.005f;
422 if( player_replay.replay_control == k_replay_control_play )
423 glitch_strength = 0.005f;
424 else
425 glitch_strength += 0.005f*player_replay.track_velocity;
426 }
427 shader_blitblur_uGlitchStrength( glitch_strength );
428
429 v2f override;
430 if( skaterift.activity == k_skaterift_menu )
431 v2_muls( (v2f){ 0.04f, 0.001f }, 1.0f-skaterift.time_rate, override );
432 else
433 v2_zero( override );
434 shader_blitblur_uOverrideDir( override );
435
436 render_fb_bind_texture( gpipeline.fb_main, 0, 0 );
437 render_fb_bind_texture( gpipeline.fb_main, 1, 1 );
438 }
439 else{
440 shader_blit_use();
441 shader_blit_uTexMain( 0 );
442 shader_blit_uInverseRatio( inverse );
443 render_fb_bind_texture( gpipeline.fb_main, 0, 0 );
444 }
445
446 render_fsquad();
447 }
448
449 static void render_player_transparent(void){
450 static vg_camera small_cam; /* DOES NOT NEED TO BE STATIC BUT MINGW
451 SAIS OTHERWISE */
452
453 m4x3_copy( skaterift.cam.transform, small_cam.transform );
454
455 small_cam.fov = skaterift.cam.fov;
456 small_cam.nearz = 0.05f;
457 small_cam.farz = 60.0f;
458
459 vg_camera_update_view( &small_cam );
460 vg_camera_update_projection( &small_cam );
461 vg_camera_finalize( &small_cam );
462
463 /* Draw player to window buffer and blend background ontop */
464 player__render( &small_cam );
465 }
466
467 static world_instance *get_view_world(void){
468 world_instance *view_world = world_current_instance();
469 if( localplayer.gate_waiting &&
470 (localplayer.gate_waiting->flags & k_ent_gate_nonlocal) ){
471 view_world = &world_static.instances[world_static.active_instance ^ 0x1];
472 }
473
474 return view_world;
475 }
476
477 static void render_scene(void){
478 /* Draw world */
479 glEnable( GL_DEPTH_TEST );
480
481 for( u32 i=0; i<vg_list_size(world_static.instances); i++ ){
482 if( world_static.instances[i].status == k_world_status_loaded ){
483 world_prerender( &world_static.instances[i] );
484 }
485 }
486
487 if( skaterift.activity == k_skaterift_world_map ){
488 world_instance *world = world_current_instance();
489 glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } );
490
491 v3f bg;
492 v3_muls( world->ub_lighting.g_daysky_colour,
493 world->ub_lighting.g_day_phase -
494 world->ub_lighting.g_sunset_phase*0.1f, bg );
495
496 v3_muladds( bg, world->ub_lighting.g_sunset_colour,
497 (1.0f-0.5f)*world->ub_lighting.g_sunset_phase, bg );
498
499 v3_muladds( bg, world->ub_lighting.g_nightsky_colour,
500 (1.0f-world->ub_lighting.g_day_phase), bg );
501
502 glClearColor( bg[0], bg[1], bg[2], 0.0f );
503 glClear( GL_COLOR_BUFFER_BIT );
504 glDrawBuffers( 2, (GLenum[]){ GL_COLOR_ATTACHMENT0,
505 GL_COLOR_ATTACHMENT1 } );
506
507 m4x3f identity;
508 m4x3_identity( identity );
509 render_world_override( world, world, identity, &skaterift.cam,
510 world_map.spawn,
511 (v4f){world->tar_min, world->tar_max, 1.0f, 0.0f});
512 render_world_routes( world, world, identity, &skaterift.cam, 0, 1 );
513 return;
514 }
515
516 world_instance *view_world = get_view_world();
517 render_world( view_world, &skaterift.cam, 0, 0, 1, 1 );
518
519 particle_system_update( &particles_grind, vg.time_delta );
520 //particle_system_debug( &particles_grind );
521 particle_system_prerender( &particles_grind );
522 particle_system_render( &particles_grind, &skaterift.cam );
523
524 ent_tornado_pre_update();
525 particle_system_update( &particles_env, vg.time_delta );
526 particle_system_prerender( &particles_env );
527 particle_system_render( &particles_env, &skaterift.cam );
528
529 player_glide_render_effects( &skaterift.cam );
530
531 /*
532 * render transition
533 */
534 if( global_miniworld.transition == 0 )
535 return;
536
537 world_instance *holdout_world = NULL;
538 f32 t = 0.0f;
539
540 if( global_miniworld.transition == 1 ){
541 holdout_world = &world_static.instances[ k_world_purpose_hub ];
542 t = global_miniworld.t;
543 }
544 else{
545 holdout_world = &world_static.instances[ k_world_purpose_client ];
546 t = 1.0f-global_miniworld.t;
547 }
548
549 if( holdout_world->status != k_world_status_loaded )
550 return;
551
552 t = vg_smoothstepf( t );
553
554 glEnable( GL_STENCIL_TEST );
555 glDisable( GL_DEPTH_TEST );
556 glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
557 glStencilFunc( GL_ALWAYS, 1, 0xFF );
558 glStencilMask( 0xFF );
559
560 shader_blit_transition_use();
561 shader_blit_transition_uInverseRatio( (v2f){1.0f,1.0f} );
562 shader_blit_transition_uT( -(sqrtf(2)+0.5f) * t );
563
564 render_fsquad();
565 render_world( holdout_world, &global_miniworld.cam, 1, 0, 1, 1 );
566 }
567
568 static void skaterift_composite_maincamera(void)
569 {
570 vg_camera_lerp( &localplayer.cam, &world_static.focus_cam,
571 vg_smoothstepf(world_static.focus_strength), &skaterift.cam );
572
573 if( skaterift.activity == k_skaterift_replay )
574 {
575 if( player_replay.use_freecam )
576 {
577 freecam_preupdate();
578 v3_copy( player_replay.replay_freecam.pos, skaterift.cam.pos );
579 v3_copy( player_replay.replay_freecam.angles, skaterift.cam.angles );
580 skaterift.cam.fov = player_replay.replay_freecam.fov;
581 }
582 else
583 {
584 skaterift_get_replay_cam( &skaterift.cam );
585 }
586 }
587
588 skaterift.cam.nearz = 0.1f;
589 skaterift.cam.farz = 2100.0f;
590
591 if( skaterift.activity == k_skaterift_world_map ){
592 vg_camera_copy( &world_map.cam, &skaterift.cam );
593 skaterift.cam.nearz = 4.0f;
594 skaterift.cam.farz = 3100.0f;
595 }
596
597 if( global_miniworld.transition ){
598 f32 dt = vg.time_frame_delta / 2.0f,
599 s = vg_signf( global_miniworld.transition );
600 global_miniworld.t += s * dt;
601
602 if( (global_miniworld.t > 1.0f) || (global_miniworld.t < 0.0f) ){
603 global_miniworld.t = vg_clampf( global_miniworld.t, 0.0f, 1.0f );
604 global_miniworld.transition = 0;
605 }
606 }
607
608 vg_camera_update_transform( &skaterift.cam );
609 vg_camera_update_view( &skaterift.cam );
610 vg_camera_update_projection( &skaterift.cam );
611 vg_camera_finalize( &skaterift.cam );
612 }
613
614 static void render_main_game(void){
615 if( skaterift.activity == k_skaterift_replay ){
616 player__animate_from_replay( &player_replay.local );
617 }
618 else{
619 player__animate();
620 skaterift_record_frame( &player_replay.local,
621 localplayer.deferred_frame_record );
622 localplayer.deferred_frame_record = 0;
623 }
624 animate_remote_players();
625 player__pre_render();
626
627 skaterift_composite_maincamera();
628
629 /* --------------------------------------------------------------------- */
630 if( skaterift.activity != k_skaterift_world_map ){
631 world_instance *world = world_current_instance();
632 render_world_cubemaps( world );
633
634 ent_gate *nlg = world->rendering_gate;
635 if( nlg && nlg->flags & k_ent_gate_nonlocal )
636 render_world_cubemaps( &world_static.instances[nlg->target] );
637 }
638
639 /* variable res target */
640 render_fb_bind( gpipeline.fb_main, 1 );
641 glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
642 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT );
643
644 render_scene();
645 glEnable( GL_DEPTH_TEST );
646
647 /* full res target */
648 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
649 glViewport( 0,0, vg.window_x, vg.window_y );
650
651 render_player_transparent(); /* needs to read the depth buffer before we fuck
652 it up with the oblique rendering inside the
653 portals */
654
655 /* continue with variable rate */
656 if( !global_miniworld.transition &&
657 (skaterift.activity != k_skaterift_world_map) ){
658 render_fb_bind( gpipeline.fb_main, 1 );
659 render_world_gates( get_view_world(), &skaterift.cam );
660 }
661
662 /* composite */
663 present_view_with_post_processing();
664 skaterift_replay_post_render();
665 control_overlay_render();
666 }
667
668 void vg_render(void)
669 {
670 if( k_tools_mode ){
671 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
672 glViewport( 0,0, vg.window_x, vg.window_y );
673 glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
674 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
675 return;
676 }
677
678 if( skaterift.op == k_async_op_clientloading ){
679 vg_loader_render();
680 return;
681 }
682
683 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
684
685 glViewport( 0,0, vg.window_x, vg.window_y );
686 glDisable( GL_DEPTH_TEST );
687 glDisable( GL_BLEND );
688
689 glClearColor( 1.0f, 0.0f, 0.0f, 0.0f );
690 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
691
692 render_main_game();
693 m4x4_copy( skaterift.cam.mtx.pv, vg.pv );
694
695 /* Other shite */
696 glDisable(GL_BLEND);
697 glDisable(GL_DEPTH_TEST);
698 vg_lines_drawall();
699 glViewport( 0,0, vg.window_x, vg.window_y );
700 gui_draw();
701 }
702
703 void vg_gui(void)
704 {
705 if( skaterift.op == k_async_op_clientloading ) return;
706
707 if( k_tools_mode ){
708 ui_rect null;
709 ui_rect screen = { 0, 0, vg.window_x, vg.window_y };
710 ui_rect panel = { 0, 0, 1000, 700 };
711 ui_rect_center( screen, panel );
712 vg_ui.wants_mouse = 1;
713
714 ui_fill( panel, ui_colour( k_ui_bg+1 ) );
715 ui_outline( panel, 1, ui_colour( k_ui_bg+7 ), 0 );
716
717 ui_rect_pad( panel, (ui_px[2]){ 8, 8 } );
718
719 return;
720 }
721
722 if( k_light_editor )
723 imgui_world_light_edit( world_current_instance() );
724
725 vg_ui.tex_bg = gpipeline.fb_main->attachments[0].id;
726 render_fb_inverse_ratio( gpipeline.fb_main, vg_ui.bg_inverse_ratio );
727
728 menu_update();
729 if( skaterift.activity == k_skaterift_menu ){
730 glClear( GL_DEPTH_BUFFER_BIT );
731 menu_render();
732 }
733
734 player__im_gui();
735 world_instance *world = world_current_instance();
736
737 world_routes_imgui( world );
738 skaterift_replay_imgui();
739 workshop_form_gui();
740 render_view_framebuffer_ui();
741 remote_player_network_imgui( vg.pv );
742
743 if( skaterift.activity == k_skaterift_world_map ){
744 remote_players_imgui_world( world_current_instance(), vg.pv, 2000.0f, 0 );
745 remote_players_imgui_lobby();
746 }
747 else {
748 remote_players_chat_imgui(); /* TODO: conditional */
749 remote_players_imgui_world( world_current_instance(), vg.pv, 100.0f, 1 );
750 }
751 }
752
753 #include "addon.c"
754 #include "addon_types.c"
755 #include "audio.c"
756 #include "ent_challenge.c"
757 #include "ent_glider.c"
758 #include "entity.c"
759 #include "ent_miniworld.c"
760 #include "ent_objective.c"
761 #include "ent_region.c"
762 #include "ent_relay.c"
763 #include "ent_route.c"
764 #include "ent_skateshop.c"
765 #include "ent_tornado.c"
766 #include "ent_traffic.c"
767 #include "freecam.c"
768 #include "menu.c"
769 #include "network.c"
770 #include "particle.c"
771 #include "player_basic_info.c"
772 #include "player.c"
773 #include "player_common.c"
774 #include "player_dead.c"
775 #include "player_drive.c"
776 #include "player_effects.c"
777 #include "player_glide.c"
778 #include "player_ragdoll.c"
779 #include "player_remote.c"
780 #include "player_render.c"
781 #include "player_replay.c"
782 #include "player_skate.c"
783 #include "player_walk.c"
784 #include "render.c"
785 #include "save.c"
786 #include "scene.c"
787 #include "steam.c"
788 #include "trail.c"
789 #include "vehicle.c"
790 #include "workshop.c"
791 #include "world_audio.c"
792 #include "world.c"
793 #include "world_entity.c"
794 #include "world_gate.c"
795 #include "world_gen.c"
796 #include "world_load.c"
797 #include "world_map.c"
798 #include "world_physics.c"
799 #include "world_render.c"
800 #include "world_routes.c"
801 #include "world_routes_ui.c"
802 #include "world_sfd.c"
803 #include "world_volumes.c"
804 #include "world_water.c"
805 #include "ent_npc.c"
806 #include "model.c"
807 #include "control_overlay.c"