imgui stuff
[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
26 static int skaterift_loaded = 0;
27 static GLuint tex_error;
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_tex2d_replace_with_error( &tex_error );
63 vg_bake_shaders();
64 vg_async_call( skaterift_load_post, NULL, 0 );
65 }
66
67 VG_STATIC void vg_update(void)
68 {
69 steam_update();
70 }
71
72 VG_STATIC void vg_update_fixed(void)
73 {
74 }
75
76 VG_STATIC void vg_update_post(void)
77 {
78 }
79
80 VG_STATIC void vg_framebuffer_resize( int w, int h )
81 {
82 render_fb_resize();
83 }
84
85 VG_STATIC void vg_render(void)
86 {
87 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
88
89 glViewport( 0,0, vg.window_x, vg.window_y );
90 glDisable( GL_DEPTH_TEST );
91
92 glClearColor( 0.0f, 0.2f, 0.7f, 0.0f );
93 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
94
95 /* Other shite */
96 glDisable(GL_BLEND);
97 glDisable(GL_DEPTH_TEST);
98 vg_lines_drawall();
99 }
100
101 VG_STATIC void vg_ui(void)
102 {
103 if( !skaterift_loaded ) return;
104
105 ui_rect screen = { 0, 0, vg.window_x, vg.window_y };
106
107 v4f btn_basic = { 0.8f,0.8f,0.8f,1.0f };
108
109 ui_rect window = { 0, 0, 1200, 800 };
110 ui_rect_center( screen, window );
111 {
112 ui_fill( window, 0xff111111 );
113 ui_outline( window, 1, 0xffffffff );
114
115 ui_rect title, panel;
116 ui_split_px( window, k_ui_axis_h, 28, 0, title, panel );
117 ui_fill( title, 0xff333333 );
118 ui_text( title, "Workshop tool", 2, k_ui_align_center );
119
120 ui_rect sidebar, content;
121 ui_split_ratio( panel, k_ui_axis_v, 0.25f, 1, sidebar, content );
122
123 /* entries panel */
124 ui_fill( sidebar, 0xff222222 );
125
126 ui_split_px( sidebar, k_ui_axis_h, 28, 0, title, sidebar );
127 ui_text( title, "Your submissions", 1, k_ui_align_middle_center );
128
129
130 ui_rect up_button;
131 ui_split_px( sidebar, k_ui_axis_h, 48, 0, up_button, sidebar );
132
133 if( ui_button_text( up_button, "^", 2, btn_basic ) ){
134 vg_info( "page up\n" );
135 }
136
137 /* content page */
138 ui_rect_pad( content, 8 );
139
140 ui_rect image_plane;
141 ui_split_px( content, k_ui_axis_h, 300, 0, image_plane, content );
142 ui_fill( image_plane, 0xff000000 );
143
144 ui_rect img_box;
145 ui_fit_item( image_plane, (ui_px[2]){ 3, 2 }, img_box );
146 ui_image( img_box, tex_error );
147
148 ui_text( content, "rest of the stuff", 1, k_ui_align_left );
149 }
150
151 #if 0
152 ui_box box = { 200, 100, 600, 400 };{
153 ui_fill( box, 0xff0000aa );
154 ui_outline( box, 1, 0xffffffff );
155
156 ui_split split = ui_split_ratio( box, k_ui_axis_v, 0.25f, 8 );{
157 if( ui_mouseover_rect( split.l.rect ) ) ui_fill( split.l, 0xff00aa00 );
158 else ui_fill( split.l, 0xffaa0000 );
159
160 ui_text( split.l.rect, "Hello world!\n"
161 "adwjdiwadjwidwjidiadjw\n"
162 "eeeee", 1, k_ui_align_center );
163 }{
164 ui_fill( split.r, 0xff002000 );
165 split = ui_split_ratio( split.r, k_ui_axis_h, 0.5f, 1 );
166
167 ui_box img_box = ui_fit_item( split.t, (ui_px[2]){ 30,20 } );
168 ui_image( img_box.rect, tex_error );
169
170 ui_fill( split.b, 0xff00ff00 );
171 }
172 }
173 #endif
174 }