+/*
+ * Copyright (C) Mount0 Software, Harry Godden - All Rights Reserved
+ */
+
#include "common.h"
/* Resources */
#include "road.h"
#include "scene.h"
#include "ik.h"
+#include "audio.h"
#include "terrain.h"
#include "character.h"
#include "ragdoll.h"
gate_register();
}
+static void init_other(void)
+{
+ render_init();
+ gate_init();
+ terrain_init();
+ character_init();
+ audio_init();
+}
+
vg_tex2d *texture_list[] =
{
&tex_norwey,
vg_init( argc, argv, "Voyager Game Engine" );
}
-#if 0
-rigidbody mr_box = {
- .bbx = {{ -1.0f, -0.25f, -0.25f }, { 1.0f, 0.25f, 0.25f }}
-};
-
-rigidbody mrs_box = {
- .bbx = {{ -0.5f, -0.25f, -0.25f }, { 0.5f, 0.25f, 0.25f }}
-};
-
-teleport_gate gate_a = {
- .co = { 0.0f, -3.0f, -15.0f },
- .q = { 0.0f, 0.0f, 0.0f, 1.0f }
-},
-gate_b = {
- .co = { -8.0f, -3.0f, -17.0f },
- .q = { 0.0f, 0.0f, 0.0f, 1.0f }
-};
-#endif
-
static int playermodel( int argc, char const *argv[] )
{
if( argc < 1 ) return 0;
.persistent = 1
});
+ vg_convar_push( (struct vg_convar){
+ .name = "grid",
+ .data = &walk_grid_iterations,
+ .data_type = k_convar_dtype_i32,
+ .opt_i32 = { .min=0, .max=1, .clamp=0 },
+ .persistent = 1
+ });
+
vg_convar_push( (struct vg_convar){
.name = "walk_speed",
.data = &k_walkspeed,
});
vg_tex2d_init( texture_list, vg_list_size( texture_list ) );
-
- render_init();
- gate_init();
- terrain_init();
- character_init();
+
+ init_other();
character_load( &player.mdl, "ch_default" );
character_init_ragdoll( &player.mdl );
player_transform_update();
}
+void vg_free(void)
+{
+ vg_tex2d_free( texture_list, vg_list_size(texture_list) );
+}
+
void vg_update(void)
{
player_update();
glDisable( GL_DEPTH_TEST );
glClearColor( 0.11f, 0.35f, 0.37f, 1.0f );
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
float speed = freecam? 0.0f: v3_length( player.v );
v3f shake = { vg_randf()-0.5f, vg_randf()-0.5f, vg_randf()-0.5f };
v3_muls( shake, speed*0.01f, shake );
- if( player.is_dead )
- {
-#if 0
- v3f delta;
- v3_sub( player.mdl.ragdoll[k_chpart_head].co, player.follow, delta );
- v3_normalize(delta);
-
- v3f follow_pos;
- v3_muladds( player.mdl.ragdoll[k_chpart_head].co, delta,
- -1.5f, follow_pos );
- v3_lerp( player.follow, follow_pos, 0.1f, player.follow );
- v3_negate( player.follow, final );
-
-
- float yaw = atan2f( delta[0], -delta[2] );
- float pitch = asinf( delta[1] );
- m4x3_rotate_x( world_matrix, -pitch );
- m4x3_rotate_y( world_matrix, yaw );
-#endif
- }
- else
- {
- }
-
m4x4f world_4x4;
m4x3_expand( player.camera_inverse, world_4x4 );
- gpipeline.fov = freecam? 60.0f: 100.0f; /* 120 */
+ gpipeline.fov = freecam? 60.0f: 135.0f; /* 120 */
m4x4_projection( vg_pv, gpipeline.fov,
(float)vg_window_x / (float)vg_window_y,
- 0.025f, 1000.0f );
+ 0.1f, 2100.0f );
m4x4_mul( vg_pv, world_4x4, vg_pv );
render_water_texture( player.camera );
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- render_water_surface( vg_pv );
+ render_water_surface( vg_pv, player.camera );
-#if 0
vg_tex2d_bind( &tex_water, 1 );
- render_gate( &gate_a, cam_transform );
-#endif
+
+ for( int i=0; i<world.gate_count; i++ )
+ {
+ render_gate( &world.gates[i], player.camera );
+ }
/* Copy the RGB of what we have into the background buffer */
draw_player();
- /* Draw back in the background */
+ /* Draw back in the background
+ *
+ * TODO: need to disable alpha write in the terrain shader so this works
+ * again.
+ */
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);
/* Other shite */
glDisable( GL_DEPTH_TEST );
vg_lines_drawall( (float *)vg_pv );
-
- /* Debugger camera */
-#if 0
- glViewport( 0,0, 800, 800 );
- glClearColor( 0.1f, 0.0f, 0.2f, 1.0f );
- glClear( GL_DEPTH_BUFFER_BIT );
-
- m4x3_identity( world_matrix );
-
- v3f debugcam;
- v3_negate( player.co, debugcam );
- debugcam[2] -= 2.0f;
- debugcam[1] -= 0.7f;
-
- m4x3_translate( world_matrix, debugcam );
- m4x3_expand( world_matrix, world_4x4 );
-
- m4x4_projection( vg_pv,
- 100.0f,
- (float)128.0f / (float)128.0f,
- 0.1f, 1000.0f );
- m4x4_mul( vg_pv, world_4x4, vg_pv );
-
- if(sv_debugcam)
- {
- glEnable( GL_DEPTH_TEST );
- draw_player();
- }
-#endif
-
- glDisable( GL_DEPTH_TEST );
- vg_lines_drawall( (float *)vg_pv );
-
glViewport( 0,0, vg_window_x, vg_window_y );
}
"Gamepad not ready", 1, k_text_align_left );
}
}
-
-void vg_free(void){}