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