Add inverse z-buffering

This commit is contained in:
austin committed 2020-07-01 17:42:48 -07:00
1 parent 63e8bd1b93
commit 8ede3f1952
8 files changed
+126 -53

No files matched your search

+2 -1
View File
@@ -26,7 +26,8 @@ enum Engine_Input
// STRUCTURES
struct Engine_Buffer
{
uint32_t *pixels;
uint32_t *buffer;
float *zbuffer;
int width;
int height;
};
+5 -4
View File
@@ -77,10 +77,11 @@ struct Mesh
// PUBLIC FUNCTIONS
void FillTriangle(
uint32_t *buffer, int width, uint32_t color,
float x0, float y0,
float x1, float y1,
float x2, float y2);
uint32_t *buffer, int width,
float *zbuffer, uint32_t color,
float x0, float y0, float z0,
float x1, float y1, float z1,
float x2, float y2, float z2);
#define GEOMETRY_H
+7
View File
@@ -74,6 +74,13 @@ inline Point operator*(Point v, Matrix m)
return result;
}
inline Point &operator*=(Point &v, Matrix m)
{
v = v * m;
return v;
}
#define MATRIX_H
#endif
+8
View File
@@ -36,6 +36,14 @@ inline Point operator/(Point v, float f)
return result;
}
// v /= f
inline Point &operator/=(Point &v, float f)
{
v = v / f;
return v;
}
// v1 - v2
inline Vector operator-(Point v1, Point v2)
{