update imgui api changes
[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
17 #define SKATERIFT_APPID 2103940
18
19 #define VG_TIMESTEP_FIXED (1.0/60.0)
20 #define VG_3D
21 #define VG_GAME
22 #define VG_MSG_V1_SUPPORT
23 #define VG_LOG_SOURCE_INFO
24 #include "vg/vg.h"
25
26 static int skaterift_loaded = 0;
27 static char g_an_buffer[ 4096 ];
28
29 int main( int argc, char *argv[] ){
30 vg_mem.use_libc_malloc = 0;
31 vg_set_mem_quota( 160*1024*1024 );
32 vg_enter( argc, argv, "Voyager Game Engine" );
33 return 0;
34 }
35
36 VG_STATIC void vg_launch_opt(void){
37 }
38
39 VG_STATIC void vg_preload(void){
40 vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" );
41 vg_info(" 2021-2023 |\\ /| | / | | | | /| \n" );
42 vg_info(" | \\ / | +-- / +----- +---' | / | \n" );
43 vg_info(" | \\ / | | / | | \\ | / | \n" );
44 vg_info(" | \\/ | | / | | \\ | / | \n" );
45 vg_info(" ' ' '--' [] '----- '----- ' ' '---' "
46 "SOFTWARE\n" );
47 }
48
49 VG_STATIC void skaterift_load_post( void *data, u32 len ){
50 skaterift_loaded = 1;
51 }
52
53 VG_STATIC void vg_load(void){
54 vg_bake_shaders();
55 vg_async_call( skaterift_load_post, NULL, 0 );
56 }
57
58 VG_STATIC void vg_pre_update(void){
59 }
60
61 VG_STATIC void vg_fixed_update(void){
62 }
63
64 VG_STATIC void vg_post_update(void){
65 }
66
67 VG_STATIC void vg_framebuffer_resize( int w, int h ){
68 //render_fb_resize();
69 }
70
71 VG_STATIC void vg_render(void){
72 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
73
74 glViewport( 0,0, vg.window_x, vg.window_y );
75 glDisable( GL_DEPTH_TEST );
76
77 glClearColor( 0.0f, 0.2f, 0.7f, 0.0f );
78 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
79
80 /* Other shite */
81 glDisable( GL_BLEND );
82 glDisable( GL_DEPTH_TEST );
83 vg_lines_drawall();
84 }
85
86 static struct ui_enum_opt dropdown_options[] = {
87 { 0, "Zero" },
88 { 3, "Three" },
89 { -1, "Minus One" }
90 };
91 static i32 dropdown_value = 8;
92
93 VG_STATIC void vg_gui(void){
94 if( !skaterift_loaded ) return;
95
96 static ui_rect window;
97 static int once = 1;
98 if( once ){
99 ui_rect screen = { 0, 0, vg.window_x, vg.window_y };
100 rect_copy( (ui_rect){ 0, 0, 1000, 700 }, window );
101 ui_rect_center( screen, window );
102 once = 0;
103 }
104
105 vg_ui.wants_mouse = 1;
106
107 ui_rect panel;
108 if( vgi_window( window, "Test window", k_vgi_window_standard, panel ) ){
109 ui_rect tmp;
110 ui_split( panel, k_ui_axis_h, k_vgi_widget_height*k_vgi_scale,
111 0, tmp, panel );
112 ui_enum( tmp, "Select enum:", dropdown_options, 3, &dropdown_value );
113 }
114 else{
115 /* window close */
116 }
117
118 #if 0
119 ui_fill( window, ui_colour( k_ui_bg+1 ) );
120 ui_outline( window, 1, ui_colour( k_ui_bg+7 ) );
121
122 ui_rect title, panel;
123 ui_split( window, k_ui_axis_h, 28, 0, title, panel );
124 ui_fill( title, ui_colour( k_ui_bg+7 ) );
125 ui_text( title, "Workshop tool", 1, k_ui_align_middle_center,
126 ui_colourcont(k_ui_bg+7) );
127
128 ui_rect quit_button;
129 ui_split( title, k_ui_axis_v, title[2]-title[3], 2, title, quit_button );
130 if( ui_button_text( quit_button, "x", 1 ) == 1 ){
131 ui_start_modal( g_an_buffer, UI_MODAL_GOOD );
132 }
133
134 ui_rect tbox;
135 ui_split( panel, k_ui_axis_h, 28, 0, tbox, panel );
136 ui_textbox( tbox, g_an_buffer, 4096, 0, NULL );
137
138 ui_dev_colourview();
139 #endif
140 }