Add inverse z-buffering
This commit is contained in:
8 files changed
+126
-53
No files matched your search
+2
-1
@@ -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
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user