rasterizer

C++ software renderer

refactor: rm redundanct aliases, add size_t -> usize alias

Arjun Choudhary contact@arjunchoudhary.com

commit: ac47048 parent: 622e4ca

5 files changed, 8 insertions(+), 19 deletions(-)
MODsrc/clip.cpp+1-1
MODsrc/clip.h+1-0
MODsrc/globals.h+1-0
MODsrc/renderer.h+1-14
MODsrc/util_string.h+4-4
MOD · src/clip.cpp +1 -1
--- a/src/clip.cpp
+++ b/src/clip.cpp
@@ -65,7 +65,7 @@ vector<ClipVertex> clip_against_plane(
     bool       prev_inside = (prev_dist >= 0.0f);
 
     // loop over each vertex to compare
-    for (size_t i = 0; i < polygon_in.size(); ++i) {
+    for (usize i = 0; i < polygon_in.size(); ++i) {
         const ClipVertex &curr_vert   = polygon_in[i];
         float             curr_dist   = plane_dist(curr_vert.pos);
         bool              curr_inside = (curr_dist >= 0.0f);
MOD · src/clip.h +1 -0
--- a/src/clip.h
+++ b/src/clip.h
@@ -1,5 +1,6 @@
 #include <vector>
 
+#include "globals.h"
 #include "util_math.h"
 
 using std::vector;
MOD · src/globals.h +1 -0
--- a/src/globals.h
+++ b/src/globals.h
@@ -12,6 +12,7 @@ typedef uint32_t u32;
 typedef uint64_t u64;
 typedef float    f32;
 typedef double   f64;
+typedef size_t   usize;
 
 #define static_global   static
 #define static_local    static
MOD · src/renderer.h +1 -14
--- a/src/renderer.h
+++ b/src/renderer.h
@@ -3,20 +3,7 @@
 #include <SDL.h>
 #include <stdint.h>
 
-typedef int8_t   i8;
-typedef int16_t  i16;
-typedef int32_t  i32;
-typedef int64_t  i64;
-typedef uint8_t  u8;
-typedef uint16_t u16;
-typedef uint32_t u32;
-typedef uint64_t u64;
-typedef float    f32;
-typedef double   f64;
-
-#define static_global   static
-#define static_local    static
-#define static_internal static
+#include "globals.h"
 
 // could manually blit instead of using SDL_Renderer, but there's no point?
 // GPU gets used to composite the window anyway.
MOD · src/util_string.h +4 -4
--- a/src/util_string.h
+++ b/src/util_string.h
@@ -22,8 +22,8 @@ inline string string_from_cstr(char *cstr) {
 }
 
 inline void string_trim(string *s) {
-    size_t start = 0;
-    size_t end   = s->size;
+    usize start = 0;
+    usize end   = s->size;
     while (start < end &&
            (s->str[start] == ' ' || s->str[start] == '\t' ||
             s->str[start] == '\r' || s->str[start] == '\n')) {
@@ -39,7 +39,7 @@ inline void string_trim(string *s) {
 }
 
 inline bool string_starts_with(const string &s, const char *prefix) {
-    size_t len = strlen(prefix);
+    usize len = strlen(prefix);
     if (s.size < len) {
         return false;
     }
@@ -50,7 +50,7 @@ inline bool string_equals(string a, string b) {
     if (a.size != b.size) {
         return false;
     }
-    for (uint32_t i = 0; i < a.size; ++i) {
+    for (u32 i = 0; i < a.size; ++i) {
         if (a.str[i] != b.str[i]) {
             return false;
         }