From 796fc8e76d689e00a8b2bffecf5779a4ee2cc4bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 8 Jun 2019 19:59:06 +0200 Subject: [PATCH] Fix equality --- programs/modelViewer.c | 2 +- programs/testSDL.c | 10 ++++++++-- small3dlib.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/programs/modelViewer.c b/programs/modelViewer.c index b27de8a..f9b2d8b 100644 --- a/programs/modelViewer.c +++ b/programs/modelViewer.c @@ -13,7 +13,7 @@ #define S3L_FLAT 0 #define S3L_STRICT_NEAR_CULLING 1 -#define S3L_PERSPECTIVE_CORRECTION 0 +#define S3L_PERSPECTIVE_CORRECTION 1 #define S3L_SORT 0 #define S3L_STENCIL_BUFFER 0 #define S3L_Z_BUFFER 1 diff --git a/programs/testSDL.c b/programs/testSDL.c index 785b380..bad4045 100644 --- a/programs/testSDL.c +++ b/programs/testSDL.c @@ -85,7 +85,7 @@ uint32_t frame = 0; void clearScreen() { - memset(pixels,0,S3L_RESOLUTION_X * S3L_RESOLUTION_Y * sizeof(uint32_t)); + memset(pixels,255,S3L_RESOLUTION_X * S3L_RESOLUTION_Y * sizeof(uint32_t)); } static inline void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue) @@ -133,6 +133,12 @@ void houseTex(int32_t u, int32_t v, uint8_t *r, uint8_t *g, uint8_t *b) void drawPixel(S3L_PixelInfo *p) { + +//setPixel(p->x,p->y,p->triangleIndex,p->triangleIndex,p->triangleIndex); +setPixel(p->x,p->y,0,0,0); + +return; + if (p->x < 0 || p ->x >= S3L_RESOLUTION_X || p->y < 0 || p->y >= S3L_RESOLUTION_Y) { offScreenPixels++; @@ -338,7 +344,7 @@ scene.camera.transform.rotation.x = -35; scene.camera.transform.rotation.y = 128; scene.camera.transform.rotation.z = 0; -S3L_setTransform3D(3196,1814,5958,-18,300,0,512,512,512,&(scene.camera.transform)); +S3L_setTransform3D(-2039,173,6096,-2,-296,0,512,512,512,&(scene.camera.transform)); scene.modelCount = 2; scene.models = models; diff --git a/small3dlib.h b/small3dlib.h index e90ae70..b658f84 100644 --- a/small3dlib.h +++ b/small3dlib.h @@ -2124,7 +2124,7 @@ static inline int8_t S3L_triangleIsVisible( (p1.y - p0.y) * (p2.x - p1.x) - (p1.x - p0.x) * (p2.y - p1.y); if ((backfaceCulling == 1 && winding < 0) || - (backfaceCulling == 2 && winding >= 0)) + (backfaceCulling == 2 && winding > 0)) return 0; }