threading fixes for skateshop
[carveJwlIkooP6JGAAIwe30JlM.git] / skaterift_imgui_dev.c
1 /*
2 * =============================================================================
3 *
4 * Copyright . . . -----, ,----- ,---. .---.
5 * 2021-2023 |\ /| | / | | | | /|
6 * | \ / | +-- / +----- +---' | / |
7 * | \ / | | / | | \ | / |
8 * | \/ | | / | | \ | / |
9 * ' ' '--' [] '----- '----- ' ' '---' SOFTWARE
10 *
11 * =============================================================================
12 */
13
14 #define SR_NETWORKED
15 #define VG_DEVWINDOW
16 #include "common.h"
17 #include "conf.h"
18 #include "steam.h"
19 #include "render.h"
20 #include "audio.h"
21 #include "world.h"
22 #include "font.h"
23 #include "player.h"
24 #include "entity.c"
25 #include "workshop.c"
26
27 static int skaterift_loaded = 0;
28
29 int main( int argc, char *argv[] )
30 {
31 vg_mem.use_libc_malloc = 0;
32 vg_set_mem_quota( 160*1024*1024 );
33 vg_enter( argc, argv, "Voyager Game Engine" );
34 return 0;
35 }
36
37 VG_STATIC void vg_launch_opt(void)
38 {
39 }
40
41 VG_STATIC void vg_preload(void)
42 {
43 vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" );
44 vg_info(" 2021-2023 |\\ /| | / | | | | /| \n" );
45 vg_info(" | \\ / | +-- / +----- +---' | / | \n" );
46 vg_info(" | \\ / | | / | | \\ | / | \n" );
47 vg_info(" | \\/ | | / | | \\ | / | \n" );
48 vg_info(" ' ' '--' [] '----- '----- ' ' '---' "
49 "SOFTWARE\n" );
50
51 steam_init();
52 vg_loader_step( NULL, steam_end );
53 }
54
55 VG_STATIC void skaterift_load_post( void *data, u32 len )
56 {
57 skaterift_loaded = 1;
58 }
59
60 VG_STATIC void vg_load(void)
61 {
62 vg_bake_shaders();
63 vg_async_call( skaterift_load_post, NULL, 0 );
64 }
65
66 VG_STATIC void vg_update(void)
67 {
68 steam_update();
69 }
70
71 VG_STATIC void vg_update_fixed(void)
72 {
73 }
74
75 VG_STATIC void vg_update_post(void)
76 {
77 }
78
79 VG_STATIC void vg_framebuffer_resize( int w, int h )
80 {
81 render_fb_resize();
82 }
83
84 VG_STATIC void vg_render(void)
85 {
86 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
87
88 glViewport( 0,0, vg.window_x, vg.window_y );
89 glDisable( GL_DEPTH_TEST );
90
91 glClearColor( 0.0f, 0.2f, 0.7f, 0.0f );
92 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
93
94 /* Other shite */
95 glDisable( GL_BLEND );
96 glDisable( GL_DEPTH_TEST );
97 vg_lines_drawall();
98 }
99
100 VG_STATIC void vg_gui(void)
101 {
102 if( !skaterift_loaded ) return;
103
104 ui_rect null;
105 ui_rect screen = { 0, 0, vg.window_x, vg.window_y };
106 ui_rect window = { 0, 0, 1000, 700 };
107 ui_rect_center( screen, window );
108 vg_ui.wants_mouse = 1;
109
110 ui_fill( window, ui_colour( k_ui_bg+1 ) );
111 ui_outline( window, 1, ui_colour( k_ui_bg+7 ) );
112
113 ui_rect title, panel;
114 ui_split_px( window, k_ui_axis_h, 28, 0, title, panel );
115 ui_fill( title, ui_colour( k_ui_bg+7 ) );
116 ui_text( title, "Workshop tool", 1, k_ui_align_middle_center,
117 ui_colourcont(k_ui_bg+7) );
118
119 ui_rect quit_button;
120 ui_split_px( title, k_ui_axis_v, title[2]-title[3], 2, title, quit_button );
121
122 if( workshop_form.operation == k_workshop_form_op_none ){
123 if( ui_button_text( quit_button, "X", 1 ) ){
124 workshop_quit_form();
125 return;
126 }
127 }
128
129 ui_dev_colourview();
130 }