commit 65516795a0721f6aa255ce4afdbb061a43c79ae7 parent b5eaa9d20663fe8c14608e2f4a172946dd645f26 Author: Michael Savage <mikejsavage@gmail.com> Date: Thu Aug 20 21:18:53 +0200 i32 -> s32 Diffstat:
bsp.cc | | | 6 | +++--- |
bsp.h | | | 56 | ++++++++++++++++++++++++++++---------------------------- |
bsp_renderer.cc | | | 12 | ++++++------ |
intrinsics.h | | | 8 | ++++---- |
main.cc | | | 5 | +++-- |
diff --git a/bsp.cc b/bsp.cc @@ -155,7 +155,7 @@ void BSP::trace_seg_brush( const BSP_Brush & brush, BSP_Intersection & bis ) con } } -void BSP::trace_seg_leaf( const i32 leaf_idx, BSP_Intersection & bis ) const { +void BSP::trace_seg_leaf( const s32 leaf_idx, BSP_Intersection & bis ) const { const BSP_Leaf & leaf = leaves[ leaf_idx ]; for( u32 i = 0; i < leaf.num_brushes; i++ ) { @@ -168,7 +168,7 @@ void BSP::trace_seg_leaf( const i32 leaf_idx, BSP_Intersection & bis ) const { } } -void BSP::trace_seg_tree( const i32 node_idx, const glm::vec3 & start, const glm::vec3 & end, const float t1, const float t2, BSP_Intersection & bis ) const { +void BSP::trace_seg_tree( const s32 node_idx, const glm::vec3 & start, const glm::vec3 & end, const float t1, const float t2, BSP_Intersection & bis ) const { if( node_idx < 0 ) { trace_seg_leaf( -( node_idx + 1 ), bis ); return; @@ -227,7 +227,7 @@ bool BSP::trace_seg( const glm::vec3 & start, const glm::vec3 & end, Intersectio } BSP_Leaf & BSP::position_to_leaf( const glm::vec3 & pos ) const { - i32 node_idx = 0; + s32 node_idx = 0; do { const BSP_Node & node = nodes[ node_idx ]; diff --git a/bsp.h b/bsp.h @@ -40,8 +40,8 @@ struct BSP_Header { struct BSP_Texture { char name[ 64 ]; - i32 surface_flags; - i32 content_flags; + s32 surface_flags; + s32 content_flags; }; struct BSP_Plane { @@ -52,19 +52,19 @@ struct BSP_Plane { struct BSP_Node { u32 plane; - i32 pos_child; - i32 neg_child; + s32 pos_child; + s32 neg_child; - i32 mins[ 3 ]; - i32 maxs[ 3 ]; + s32 mins[ 3 ]; + s32 maxs[ 3 ]; }; struct BSP_Leaf { - i32 cluster; - i32 area; + s32 cluster; + s32 area; - i32 mins[ 3 ]; - i32 maxs[ 3 ]; + s32 mins[ 3 ]; + s32 maxs[ 3 ]; u32 init_face; u32 num_faces; @@ -82,12 +82,12 @@ struct BSP_Brush { u32 init_side; u32 num_sides; - i32 texture; + s32 texture; }; struct BSP_BrushSide { u32 plane; - i32 texture; + s32 texture; }; struct BSP_Vertex { @@ -97,30 +97,30 @@ struct BSP_Vertex { u8 rgba[ 4 ]; }; -typedef i32 BSP_MeshVert; +typedef s32 BSP_MeshVert; // LUMP_FOG struct BSP_Face { - i32 texture; - i32 effect; - i32 type; - - i32 init_vert; - i32 num_verts; - i32 init_mesh_vert; - i32 num_mesh_verts; - - i32 lightmap; - i32 lmpos[ 2 ]; - i32 lmsize[ 2 ]; + s32 texture; + s32 effect; + s32 type; + + s32 init_vert; + s32 num_verts; + s32 init_mesh_vert; + s32 num_mesh_verts; + + s32 lightmap; + s32 lmpos[ 2 ]; + s32 lmsize[ 2 ]; glm::vec3 lmorigin; glm::vec3 a; glm::vec3 b; glm::vec3 normal; - i32 c; i32 d; + s32 c; s32 d; }; // LUMP_LIGHTING @@ -192,8 +192,8 @@ public: // TODO void load_vis(); void trace_seg_brush( const BSP_Brush & brush, BSP_Intersection & bis ) const; - void trace_seg_leaf( const i32 leaf_idx, BSP_Intersection & bis ) const; - void trace_seg_tree( const i32 node_idx, const glm::vec3 & start, const glm::vec3 & end, const float t1, const float t2, BSP_Intersection & bis ) const; + void trace_seg_leaf( const s32 leaf_idx, BSP_Intersection & bis ) const; + void trace_seg_tree( const s32 node_idx, const glm::vec3 & start, const glm::vec3 & end, const float t1, const float t2, BSP_Intersection & bis ) const; BSP_Leaf & position_to_leaf( const glm::vec3 & pos ) const; diff --git a/bsp_renderer.cc b/bsp_renderer.cc @@ -96,9 +96,9 @@ void bspr_init( BSPRenderer * const bspr, MemoryArena * const arena, const BSP * const glm::vec3 colour = bspr_face_colour( bsp, face ); const BSP_Vertex * const vertices = &bsp->vertices[ face.init_vert ]; - const i32 * const indices = &bsp->mesh_verts[ face.init_mesh_vert ]; + const s32 * const indices = &bsp->mesh_verts[ face.init_mesh_vert ]; - for( i32 v = 0; v < face.num_verts; v++ ) { + for( s32 v = 0; v < face.num_verts; v++ ) { const glm::vec3 & pos = vertices[ v ].pos; pos_scratch[ pos_scratch_used++ ] = pos; @@ -107,7 +107,7 @@ void bspr_init( BSPRenderer * const bspr, MemoryArena * const arena, const BSP * assert( pos_scratch_used < 2048 && colour_scratch_used < 2048 ); } - for( i32 m = 0; m < face.num_mesh_verts; m++ ) { + for( s32 m = 0; m < face.num_mesh_verts; m++ ) { ebo_scratch[ ebo_scratch_used++ ] = indices[ m ] + offset; assert( ebo_scratch_used < 2048 ); @@ -152,7 +152,7 @@ static void bspr_render_leaf( const BSPRenderer * const bspr, const u32 leaf, co static const glm::mat4 P( glm::perspective( glm::radians( 120.0f ), 640.0f / 480.0f, 0.1f, 10000.0f ) ); void bspr_render( const BSPRenderer * const bspr, const glm::vec3 & pos, const GLuint at_position, const GLuint at_colour ) { - const i32 cluster = bspr->bsp->position_to_leaf( pos ).cluster; + const s32 cluster = bspr->bsp->position_to_leaf( pos ).cluster; if( cluster == -1 ) { for( u32 i = 0; i < bspr->bsp->num_leaves; i++ ) { @@ -165,8 +165,8 @@ void bspr_render( const BSPRenderer * const bspr, const glm::vec3 & pos, const G for( u32 i = 0; i < bspr->bsp->num_leaves; i++ ) { const BSP_Leaf & leaf = bspr->bsp->leaves[ i ]; - const i32 other_cluster = leaf.cluster; - const i32 pvs_idx = cluster * bspr->bsp->vis->cluster_size + other_cluster / 8; + const s32 other_cluster = leaf.cluster; + const s32 pvs_idx = cluster * bspr->bsp->vis->cluster_size + other_cluster / 8; if( bspr->bsp->vis->pvs[ pvs_idx ] & ( 1 << other_cluster % 8 ) ) { bspr_render_leaf( bspr, i, at_position, at_colour ); diff --git a/intrinsics.h b/intrinsics.h @@ -4,10 +4,10 @@ #include <stdio.h> #include <stdint.h> -typedef int8_t i8; -typedef int16_t i16; -typedef int32_t i32; -typedef int64_t i64; +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; typedef uint8_t u8; typedef uint16_t u16; diff --git a/main.cc b/main.cc @@ -11,6 +11,7 @@ #include "game.h" #include "intrinsics.h" #include "gl.h" +#include "keys.h" struct Game { void * lib; @@ -69,7 +70,7 @@ bool should_reload_game( const char * const path, const time_t lib_write_time ) } int main( int argc, char ** argv ) { - const char * const game_library_path = argc == 2 ? argv[ 1 ] : "./hm.so"; + const char * const game_library_path = argc == 2 ? argv[ 1 ] : "./bsp.so"; Game game = load_game( game_library_path ); GameMemory mem = { }; @@ -94,7 +95,7 @@ int main( int argc, char ** argv ) { break; } - if( ( i32 ) current_frame_time != ( i32 ) last_frame_time ) { + if( ( s32 ) current_frame_time != ( s32 ) last_frame_time ) { if( should_reload_game( game_library_path, game.lib_write_time ) ) { unload_game( &game ); game = load_game( game_library_path );