d661fbf90501a2d1d7329df8bd418fc4b602bd02
[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", ADDON_REG_PREMIUM );
195
196 world_static.load_state = k_world_loader_load;
197
198 struct world_load_args args = {
199 .purpose = k_world_purpose_hub,
200 .reg = hub
201 };
202 skaterift_world_load_thread( &args );
203 }
204
205 static void skaterift_load_player_content(void)
206 {
207 particle_alloc( &particles_grind, 300 );
208 particle_alloc( &particles_env, 200 );
209
210 player_load_animation_reference( "models/ch_none.mdl" );
211 player_model_load( &localplayer.fallback_model, "models/ch_none.mdl" );
212 player__bind();
213 player_board_load( &localplayer.fallback_board, "models/board_none.mdl" );
214 }
215
216 void vg_load(void)
217 {
218 if( k_tools_mode ){
219 vg_async_call( async_call_ready, NULL, 0 );
220 return;
221 }
222
223 vg_audio.always_keep_compressed = 1;
224
225 vg_console_reg_cmd( "load_world", skaterift_load_world_command, NULL );
226 vg_console_reg_var( "immobile", &localplayer.immobile, k_var_dtype_i32, 0 );
227
228 vg_loader_step( render_init, NULL );
229 vg_loader_step( menu_init, NULL );
230 vg_loader_step( control_overlay_init, NULL );
231 vg_loader_step( world_init, NULL );
232 vg_loader_step( vehicle_init, NULL );
233 vg_loader_step( gui_init, NULL );
234
235 vg_loader_step( player_init, NULL );
236 vg_loader_step( player_ragdoll_init, NULL );
237 vg_loader_step( npc_init, NULL );
238
239 /* content stuff */
240 vg_loader_step( addon_system_init, NULL );
241 vg_loader_step( workshop_init, NULL );
242 vg_loader_step( skateshop_init, NULL );
243 vg_loader_step( ent_tornado_init, NULL );
244 vg_loader_step( skaterift_replay_init, NULL );
245 vg_loader_step( skaterift_load_player_content, NULL );
246
247 /* --------------------- */
248
249 vg_bake_shaders();
250 vg_loader_step( audio_init, NULL );
251
252 /* 'systems' are completely loaded now */
253
254 /* Completing addon registrations
255 * -------------------------------------
256 */
257
258 /* load home/permanent world manually */
259 vg_loader_step( skaterift_load_world_content, NULL );
260 vg_async_call( async_skaterift_player_start, NULL, 0 );
261 vg_async_stall();
262
263 vg_console_load_autos();
264 menu_link();
265
266 addon_mount_content_folder( k_addon_type_player,
267 "playermodels", ".mdl" );
268 addon_mount_content_folder( k_addon_type_board, "boards", ".mdl" );
269 addon_mount_content_folder( k_addon_type_world, "maps", ".mdl" );
270 addon_mount_workshop_items();
271 vg_async_call( async_addon_reg_update, NULL, 0 );
272 vg_async_stall();
273
274 /* and now */
275 skaterift_restore_state();
276 update_ach_models();
277
278 vg_loader_step( NULL, skaterift_autosave_synchronous );
279
280 //board_processview_thread(NULL);
281 vg_async_call( async_call_ready, NULL, 0 );
282 }
283
284 static void draw_origin_axis(void){
285 vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 1.0f, 0.0f, 0.0f }, 0xffff0000 );
286 vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 1.0f, 0.0f }, 0xff00ff00 );
287 vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 0.0f, 1.0f }, 0xff0000ff );
288 }
289 void skaterift_change_client_world_preupdate(void);
290
291 /*
292 * UPDATE LOOP
293 * ---------------------------------------------------------------------------*/
294
295 void vg_pre_update(void)
296 {
297 skaterift_preupdate_inputs();
298
299 if( k_tools_mode ) return;
300
301 steam_update();
302 skaterift_change_client_world_preupdate();
303
304 if( skaterift.op == k_async_op_clientloading ) return;
305
306 draw_origin_axis();
307 addon_system_pre_update();
308 skateshop_world_preview_preupdate();
309 network_update();
310
311 /* time rate */
312 f32 target = 1;
313 if( skaterift.activity & (k_skaterift_replay|k_skaterift_menu|
314 k_skaterift_world_map) )
315 {
316 target = 0;
317 }
318
319 vg_slewf( &skaterift.time_rate, target, vg.time_frame_delta * (1.0f/0.3f) );
320 vg.time_rate = vg_smoothstepf( skaterift.time_rate );
321
322 /* TODO: how can we compress this? */
323 ent_miniworld_preupdate();
324 world_entity_focus_preupdate();
325
326 if( skaterift.activity != k_skaterift_menu )
327 {
328 player__pre_update();
329 }
330
331 skaterift_replay_pre_update();
332 remote_sfx_pre_update();
333 skateshop_world_preupdate( world_current_instance() );
334
335 world_update( world_current_instance(), localplayer.rb.co );
336 audio_ambient_sprites_update( world_current_instance(), localplayer.rb.co );
337 world_map_pre_update();
338 }
339
340 void vg_fixed_update(void)
341 {
342 if( k_tools_mode ) return;
343 if( skaterift.op == k_async_op_clientloading ) return;
344
345 world_routes_fixedupdate( world_current_instance() );
346 player__update();
347 vehicle_update_fixed();
348 }
349
350 void vg_post_update(void)
351 {
352 if( k_tools_mode ) return;
353 if( skaterift.op == k_async_op_clientloading ) return;
354
355 player__post_update();
356
357 float dist;
358 int sample_index;
359 world_audio_sample_distances( localplayer.rb.co, &sample_index, &dist );
360
361 audio_lock();
362 vg_dsp.echo_distances[sample_index] = dist;
363
364 v3f ears = { 1.0f,0.0f,0.0f };
365 m3x3_mulv( skaterift.cam.transform, ears, ears );
366 v3_copy( ears, vg_audio.external_listener_ears );
367 v3_copy( skaterift.cam.transform[3], vg_audio.external_listener_pos );
368
369 if( localplayer.gate_waiting ){
370 m4x3_mulv( localplayer.gate_waiting->transport,
371 vg_audio.external_listener_pos,
372 vg_audio.external_listener_pos );
373 }
374
375 v3_copy( localplayer.rb.v, vg_audio.external_lister_velocity );
376 audio_unlock();
377
378 vehicle_update_post();
379 skaterift_autosave_update();
380 }
381
382 /*
383 * RENDERING
384 * ---------------------------------------------------------------------------*/
385
386 void vg_framebuffer_resize( int w, int h ){
387 render_fb_resize();
388 }
389
390 static void present_view_with_post_processing(void){
391 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
392 glViewport( 0,0, vg.window_x, vg.window_y );
393
394 glEnable(GL_BLEND);
395 glDisable(GL_DEPTH_TEST);
396 glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);
397 glBlendEquation(GL_FUNC_ADD);
398
399 v2f inverse;
400 render_fb_inverse_ratio( gpipeline.fb_main, inverse );
401
402 if( k_blur_effect ){
403 shader_blitblur_use();
404 shader_blitblur_uTexMain( 0 );
405 shader_blitblur_uTexMotion( 1 );
406 shader_blitblur_uBlurStrength( k_blur_strength /
407 (vg.time_frame_delta*60.0) );
408 shader_blitblur_uInverseRatio( inverse );
409
410 inverse[0] -= 0.0001f;
411 inverse[1] -= 0.0001f;
412 shader_blitblur_uClampUv( inverse );
413
414 static f64 effect_time = 133.0;
415 effect_time += vg.time_frame_delta;
416 shader_blitblur_uTime( effect_time );
417
418 f32 glitch_strength = 0.0f;
419 if( skaterift.activity == k_skaterift_replay ){
420 glitch_strength = 0.005f;
421 if( player_replay.replay_control == k_replay_control_play )
422 glitch_strength = 0.005f;
423 else
424 glitch_strength += 0.005f*player_replay.track_velocity;
425 }
426 shader_blitblur_uGlitchStrength( glitch_strength );
427
428 v2f override;
429 if( skaterift.activity == k_skaterift_menu )
430 v2_muls( (v2f){ 0.04f, 0.001f }, 1.0f-skaterift.time_rate, override );
431 else
432 v2_zero( override );
433 shader_blitblur_uOverrideDir( override );
434
435 render_fb_bind_texture( gpipeline.fb_main, 0, 0 );
436 render_fb_bind_texture( gpipeline.fb_main, 1, 1 );
437 }
438 else{
439 shader_blit_use();
440 shader_blit_uTexMain( 0 );
441 shader_blit_uInverseRatio( inverse );
442 render_fb_bind_texture( gpipeline.fb_main, 0, 0 );
443 }
444
445 render_fsquad();
446 }
447
448 static void render_player_transparent(void){
449 static vg_camera small_cam; /* DOES NOT NEED TO BE STATIC BUT MINGW
450 SAIS OTHERWISE */
451
452 m4x3_copy( skaterift.cam.transform, small_cam.transform );
453
454 small_cam.fov = skaterift.cam.fov;
455 small_cam.nearz = 0.05f;
456 small_cam.farz = 60.0f;
457
458 vg_camera_update_view( &small_cam );
459 vg_camera_update_projection( &small_cam );
460 vg_camera_finalize( &small_cam );
461
462 /* Draw player to window buffer and blend background ontop */
463 player__render( &small_cam );
464 }
465
466 static world_instance *get_view_world(void){
467 world_instance *view_world = world_current_instance();
468 if( localplayer.gate_waiting &&
469 (localplayer.gate_waiting->flags & k_ent_gate_nonlocal) ){
470 view_world = &world_static.instances[world_static.active_instance ^ 0x1];
471 }
472
473 return view_world;
474 }
475
476 static void render_scene(void){
477 /* Draw world */
478 glEnable( GL_DEPTH_TEST );
479
480 for( u32 i=0; i<vg_list_size(world_static.instances); i++ ){
481 if( world_static.instances[i].status == k_world_status_loaded ){
482 world_prerender( &world_static.instances[i] );
483 }
484 }
485
486 if( skaterift.activity == k_skaterift_world_map ){
487 world_instance *world = world_current_instance();
488 glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } );
489
490 v3f bg;
491 v3_muls( world->ub_lighting.g_daysky_colour,
492 world->ub_lighting.g_day_phase -
493 world->ub_lighting.g_sunset_phase*0.1f, bg );
494
495 v3_muladds( bg, world->ub_lighting.g_sunset_colour,
496 (1.0f-0.5f)*world->ub_lighting.g_sunset_phase, bg );
497
498 v3_muladds( bg, world->ub_lighting.g_nightsky_colour,
499 (1.0f-world->ub_lighting.g_day_phase), bg );
500
501 glClearColor( bg[0], bg[1], bg[2], 0.0f );
502 glClear( GL_COLOR_BUFFER_BIT );
503 glDrawBuffers( 2, (GLenum[]){ GL_COLOR_ATTACHMENT0,
504 GL_COLOR_ATTACHMENT1 } );
505
506 m4x3f identity;
507 m4x3_identity( identity );
508 render_world_override( world, world, identity, &skaterift.cam,
509 world_map.spawn,
510 (v4f){world->tar_min, world->tar_max, 1.0f, 0.0f});
511 render_world_routes( world, world, identity, &skaterift.cam, 0, 1 );
512 return;
513 }
514
515 world_instance *view_world = get_view_world();
516 render_world( view_world, &skaterift.cam, 0, 0, 1, 1 );
517
518 particle_system_update( &particles_grind, vg.time_delta );
519 //particle_system_debug( &particles_grind );
520 particle_system_prerender( &particles_grind );
521 particle_system_render( &particles_grind, &skaterift.cam );
522
523 ent_tornado_pre_update();
524 particle_system_update( &particles_env, vg.time_delta );
525 particle_system_prerender( &particles_env );
526 particle_system_render( &particles_env, &skaterift.cam );
527
528 player_glide_render_effects( &skaterift.cam );
529
530 /*
531 * render transition
532 */
533 if( global_miniworld.transition == 0 )
534 return;
535
536 world_instance *holdout_world = NULL;
537 f32 t = 0.0f;
538
539 if( global_miniworld.transition == 1 ){
540 holdout_world = &world_static.instances[ k_world_purpose_hub ];
541 t = global_miniworld.t;
542 }
543 else{
544 holdout_world = &world_static.instances[ k_world_purpose_client ];
545 t = 1.0f-global_miniworld.t;
546 }
547
548 if( holdout_world->status != k_world_status_loaded )
549 return;
550
551 t = vg_smoothstepf( t );
552
553 glEnable( GL_STENCIL_TEST );
554 glDisable( GL_DEPTH_TEST );
555 glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
556 glStencilFunc( GL_ALWAYS, 1, 0xFF );
557 glStencilMask( 0xFF );
558
559 shader_blit_transition_use();
560 shader_blit_transition_uInverseRatio( (v2f){1.0f,1.0f} );
561 shader_blit_transition_uT( -(sqrtf(2)+0.5f) * t );
562
563 render_fsquad();
564 render_world( holdout_world, &global_miniworld.cam, 1, 0, 1, 1 );
565 }
566
567 static void skaterift_composite_maincamera(void)
568 {
569 vg_camera_lerp( &localplayer.cam, &world_static.focus_cam,
570 vg_smoothstepf(world_static.focus_strength), &skaterift.cam );
571
572 if( skaterift.activity == k_skaterift_replay )
573 {
574 if( player_replay.use_freecam )
575 {
576 freecam_preupdate();
577 v3_copy( player_replay.replay_freecam.pos, skaterift.cam.pos );
578 v3_copy( player_replay.replay_freecam.angles, skaterift.cam.angles );
579 skaterift.cam.fov = player_replay.replay_freecam.fov;
580 }
581 else
582 {
583 skaterift_get_replay_cam( &skaterift.cam );
584 }
585 }
586
587 skaterift.cam.nearz = 0.1f;
588 skaterift.cam.farz = 2100.0f;
589
590 if( skaterift.activity == k_skaterift_world_map ){
591 vg_camera_copy( &world_map.cam, &skaterift.cam );
592 skaterift.cam.nearz = 4.0f;
593 skaterift.cam.farz = 3100.0f;
594 }
595
596 if( global_miniworld.transition ){
597 f32 dt = vg.time_frame_delta / 2.0f,
598 s = vg_signf( global_miniworld.transition );
599 global_miniworld.t += s * dt;
600
601 if( (global_miniworld.t > 1.0f) || (global_miniworld.t < 0.0f) ){
602 global_miniworld.t = vg_clampf( global_miniworld.t, 0.0f, 1.0f );
603 global_miniworld.transition = 0;
604 }
605 }
606
607 vg_camera_update_transform( &skaterift.cam );
608 vg_camera_update_view( &skaterift.cam );
609 vg_camera_update_projection( &skaterift.cam );
610 vg_camera_finalize( &skaterift.cam );
611 }
612
613 static void render_main_game(void){
614 if( skaterift.activity == k_skaterift_replay ){
615 player__animate_from_replay( &player_replay.local );
616 }
617 else{
618 player__animate();
619 skaterift_record_frame( &player_replay.local,
620 localplayer.deferred_frame_record );
621 localplayer.deferred_frame_record = 0;
622 }
623 animate_remote_players();
624 player__pre_render();
625
626 skaterift_composite_maincamera();
627
628 /* --------------------------------------------------------------------- */
629 if( skaterift.activity != k_skaterift_world_map ){
630 world_instance *world = world_current_instance();
631 render_world_cubemaps( world );
632
633 ent_gate *nlg = world->rendering_gate;
634 if( nlg && nlg->flags & k_ent_gate_nonlocal )
635 render_world_cubemaps( &world_static.instances[nlg->target] );
636 }
637
638 /* variable res target */
639 render_fb_bind( gpipeline.fb_main, 1 );
640 glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
641 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT );
642
643 render_scene();
644 glEnable( GL_DEPTH_TEST );
645
646 /* full res target */
647 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
648 glViewport( 0,0, vg.window_x, vg.window_y );
649
650 render_player_transparent(); /* needs to read the depth buffer before we fuck
651 it up with the oblique rendering inside the
652 portals */
653
654 /* continue with variable rate */
655 if( !global_miniworld.transition &&
656 (skaterift.activity != k_skaterift_world_map) ){
657 render_fb_bind( gpipeline.fb_main, 1 );
658 render_world_gates( get_view_world(), &skaterift.cam );
659 }
660
661 /* composite */
662 present_view_with_post_processing();
663 skaterift_replay_post_render();
664 control_overlay_render();
665 }
666
667 void vg_render(void)
668 {
669 if( k_tools_mode ){
670 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
671 glViewport( 0,0, vg.window_x, vg.window_y );
672 glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
673 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
674 return;
675 }
676
677 if( skaterift.op == k_async_op_clientloading ){
678 vg_loader_render();
679 return;
680 }
681
682 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
683
684 glViewport( 0,0, vg.window_x, vg.window_y );
685 glDisable( GL_DEPTH_TEST );
686 glDisable( GL_BLEND );
687
688 glClearColor( 1.0f, 0.0f, 0.0f, 0.0f );
689 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
690
691 render_main_game();
692 m4x4_copy( skaterift.cam.mtx.pv, vg.pv );
693
694 /* Other shite */
695 glDisable(GL_BLEND);
696 glDisable(GL_DEPTH_TEST);
697 vg_lines_drawall();
698 glViewport( 0,0, vg.window_x, vg.window_y );
699
700 gui_render_icons();
701 }
702
703 void vg_gui(void)
704 {
705 if( skaterift.op == k_async_op_clientloading ) return;
706
707 gui_draw();
708
709 if( k_tools_mode ){
710 ui_rect null;
711 ui_rect screen = { 0, 0, vg.window_x, vg.window_y };
712 ui_rect panel = { 0, 0, 1000, 700 };
713 ui_rect_center( screen, panel );
714 vg_ui.wants_mouse = 1;
715
716 ui_fill( panel, ui_colour( k_ui_bg+1 ) );
717 ui_outline( panel, 1, ui_colour( k_ui_bg+7 ), 0 );
718
719 ui_rect_pad( panel, (ui_px[2]){ 8, 8 } );
720
721 return;
722 }
723
724 if( k_light_editor )
725 imgui_world_light_edit( world_current_instance() );
726
727 vg_ui.tex_bg = gpipeline.fb_main->attachments[0].id;
728 render_fb_inverse_ratio( gpipeline.fb_main, vg_ui.bg_inverse_ratio );
729
730 menu_update();
731 if( skaterift.activity == k_skaterift_menu ){
732 glClear( GL_DEPTH_BUFFER_BIT );
733 menu_render();
734 }
735
736 player__im_gui();
737 world_instance *world = world_current_instance();
738
739 world_routes_imgui( world );
740 skaterift_replay_imgui();
741 workshop_form_gui();
742 render_view_framebuffer_ui();
743 remote_player_network_imgui( vg.pv );
744
745 if( skaterift.activity == k_skaterift_world_map ){
746 remote_players_imgui_world( world_current_instance(), vg.pv, 2000.0f, 0 );
747 remote_players_imgui_lobby();
748 }
749 else {
750 remote_players_chat_imgui(); /* TODO: conditional */
751 remote_players_imgui_world( world_current_instance(), vg.pv, 100.0f, 1 );
752 }
753 }
754
755 #include "addon.c"
756 #include "addon_types.c"
757 #include "audio.c"
758 #include "ent_challenge.c"
759 #include "ent_glider.c"
760 #include "entity.c"
761 #include "ent_miniworld.c"
762 #include "ent_objective.c"
763 #include "ent_region.c"
764 #include "ent_relay.c"
765 #include "ent_route.c"
766 #include "ent_skateshop.c"
767 #include "ent_tornado.c"
768 #include "ent_traffic.c"
769 #include "freecam.c"
770 #include "menu.c"
771 #include "network.c"
772 #include "particle.c"
773 #include "player_basic_info.c"
774 #include "player.c"
775 #include "player_common.c"
776 #include "player_dead.c"
777 #include "player_drive.c"
778 #include "player_effects.c"
779 #include "player_glide.c"
780 #include "player_ragdoll.c"
781 #include "player_remote.c"
782 #include "player_render.c"
783 #include "player_replay.c"
784 #include "player_skate.c"
785 #include "player_walk.c"
786 #include "render.c"
787 #include "save.c"
788 #include "scene.c"
789 #include "steam.c"
790 #include "trail.c"
791 #include "vehicle.c"
792 #include "workshop.c"
793 #include "world_audio.c"
794 #include "world.c"
795 #include "world_entity.c"
796 #include "world_gate.c"
797 #include "world_gen.c"
798 #include "world_load.c"
799 #include "world_map.c"
800 #include "world_physics.c"
801 #include "world_render.c"
802 #include "world_routes.c"
803 #include "world_routes_ui.c"
804 #include "world_sfd.c"
805 #include "world_volumes.c"
806 #include "world_water.c"
807 #include "ent_npc.c"
808 #include "model.c"
809 #include "control_overlay.c"