add motion vectors to all shaders
[carveJwlIkooP6JGAAIwe30JlM.git] / common.h
1 /*
2 * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 */
4
5 #ifndef COMMON_H
6 #define COMMON_H
7
8 #define VG_TIMESTEP_FIXED (1.0/60.0)
9 #define VG_3D
10 #define VG_GAME
11 #define VG_STATIC static
12 #define VG_FRAMEBUFFER_RESIZE 1
13 #include "vg/vg.h"
14 #include "submodules/anyascii/impl/c/anyascii.c"
15
16 #define RESET_MAX_TIME 45.0
17
18 enum menu_controller_type
19 {
20 k_menu_controller_type_keyboard,
21 k_menu_controller_type_xbox,
22 k_menu_controller_type_playstation,
23 k_menu_controller_type_steam,
24 k_menu_controller_type_steam_deck
25 };
26
27 VG_STATIC enum menu_controller_type menu_display_controller;
28
29 typedef struct ray_hit ray_hit;
30 struct ray_hit
31 {
32 float dist;
33 u32 *tri;
34 v3f pos, normal;
35 };
36
37 VG_STATIC int network_scores_updated = 0;
38
39 VG_STATIC u32 utf8_byte0_byte_count( u8 char0 )
40 {
41 for( u32 k=2; k<4; k++ )
42 {
43 if( !(char0 & (0x80 >> k)) )
44 return k;
45 }
46
47 return 0;
48 }
49
50 VG_STATIC void str_utf8_collapse( const char *str, char *buf, u32 length )
51 {
52 u8 *ustr = (u8 *)str;
53 u32 utf32_code = 0x00000000;
54 u32 i=0, j=0, utf32_byte_ct=0;
55
56 for(;i < length-1;)
57 {
58 if( ustr[i] == 0x00 )
59 break;
60
61 if( ustr[i] & 0x80 )
62 {
63 if( utf32_byte_ct )
64 {
65 utf32_byte_ct --;
66 utf32_code |= (ustr[i] & 0x3F) << (utf32_byte_ct*6);
67
68 if( !utf32_byte_ct )
69 {
70 const char *match;
71 size_t chars = anyascii( utf32_code, &match );
72
73 for( u32 k=0; k<VG_MIN(chars, length-1-j); k++ )
74 {
75 buf[ j++ ] = (u8)match[k];
76 }
77 }
78 }
79 else
80 {
81 utf32_byte_ct = utf8_byte0_byte_count( ustr[i] )-1;
82 utf32_code = ustr[i] & (0x3F >> utf32_byte_ct);
83 utf32_code <<= utf32_byte_ct*6;
84 }
85 }
86 else
87 {
88 utf32_byte_ct = 0x00;
89 buf[j ++] = str[i];
90 }
91
92 i++;
93 }
94
95 buf[j] = 0x00;
96 }
97
98 #endif /* COMMON_H */