2 #define VG_AUDIO_FORCE_COMPRESSED
4 #define VG_LOG_SOURCE_INFO
5 #define VG_TIMESTEP_FIXED (1.0/60.0)
11 #define SDL_MAIN_HANDLED
14 #include "vg/vg_camera.h"
16 int main( int argc
, char *argv
[] ){
17 vg_mem
.use_libc_malloc
= 0;
18 vg_set_mem_quota( 80*1024*1024 );
19 vg_enter( argc
, argv
, "Voyager Game Engine" );
23 static void vg_launch_opt(void){
27 static void vg_preload(void){
28 vg_audio
.dsp_enabled
= 0;
31 static void vg_load(void){
35 static void vg_pre_update(void){
38 static void vg_fixed_update(void){
41 static void vg_post_update(void){
44 static void vg_framebuffer_resize( int w
, int h
){
47 static void draw_origin_axis(void){
48 vg_line( (v3f
){ 0.0f
, 0.0f
, 0.0f
}, (v3f
){ 1.0f
, 0.0f
, 0.0f
}, 0xffff0000 );
49 vg_line( (v3f
){ 0.0f
, 0.0f
, 0.0f
}, (v3f
){ 0.0f
, 1.0f
, 0.0f
}, 0xff00ff00 );
50 vg_line( (v3f
){ 0.0f
, 0.0f
, 0.0f
}, (v3f
){ 0.0f
, 0.0f
, 1.0f
}, 0xff0000ff );
53 static void vg_render(void){
54 glBindFramebuffer( GL_FRAMEBUFFER
, 0 );
55 glViewport( 0,0, vg
.window_x
, vg
.window_y
);
56 glEnable( GL_DEPTH_TEST
);
57 glDisable( GL_BLEND
);
59 glClearColor( 0.05f
, 0.05f
, 0.05f
, 1.0f
);
60 glClear( GL_COLOR_BUFFER_BIT
|GL_DEPTH_BUFFER_BIT
);
62 f32 x
= -((f32
)vg
.mouse_pos
[0] / (f32
)vg
.window_x
) * VG_TAUf
,
63 y
= (((f32
)vg
.mouse_pos
[1] / (f32
)vg
.window_y
) - 0.5f
)*VG_PIf
;
65 f32 t
= vg
.time
* 0.1f
* VG_TAUf
;
68 .angles
= { -x
, y
, 0 },
72 .pos
= { sinf(x
)*10.0f
*cosf(y
),
74 cosf(x
)*10.0f
*cosf(y
) },
77 vg_camera_update_transform( &cam
);
78 vg_camera_update_view( &cam
);
79 vg_camera_update_projection( &cam
);
80 vg_camera_finalize( &cam
);
81 m4x4_copy( cam
.mtx
.pv
, vg
.pv
);
87 vg_rb_view_capsule( mdl
, (sinf(t
*0.2f
)*0.5f
+0.55f
)*2.0f
,
88 (sinf(t
*0.33f
)*0.5f
+0.55f
)*1.0f
,
90 vg_rb_view_box( mdl
, (boxf
){{-4.999,-2.001,-4.999},{4.999,-0.999,4.999}},
91 (v4f
){0.8f
,0.8f
,0.8f
,1} );
93 mdl
[3][0] = sinf(t
)*2.0f
;
94 mdl
[3][2] = cosf(t
)*2.0f
;
95 vg_rb_view_sphere( mdl
, 1, (v4f
){0,1,0,1} );
100 glDisable(GL_DEPTH_TEST
);
103 static void vg_gui(void){
104 vg_ui
.wants_mouse
= 1;