From 85cadda3b3d5f67e758e05b40fc5f2266ff45258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 11 May 2019 19:52:40 +0200 Subject: [PATCH] Fix triangle flicker --- s3l.h | 4 +--- testSDL.c | 10 ++++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/s3l.h b/s3l.h index 3ebe16a..067164e 100644 --- a/s3l.h +++ b/s3l.h @@ -876,7 +876,7 @@ void _S3L_drawFilledTriangle( int16_t bDx = x##b - x##t;\ int16_t aDy = S3L_nonZero(y##a - y##t);\ int16_t bDy = S3L_nonZero(y##b - y##t);\ - if ((aDx << 4) / aDy < (bDx << 4) / bDy)\ + if ((aDx << 5) / aDy < (bDx << 5) / bDy)\ {\ lPointSx = x##a; lPointSy = y##a;\ rPointSx = x##b; rPointSy = y##b;\ @@ -1175,10 +1175,8 @@ void S3L_drawTriangle(S3L_Vec4 point0, S3L_Vec4 point1, S3L_Vec4 point2, const S3L_DrawConfig *config, const S3L_Camera *camera, S3L_Index triangleID) { - if (config->backfaceCulling != S3L_BACKFACE_CULLING_NONE) { - int32_t winding = // determines CW or CCW ( (point1.y - point0.y) * (point2.x - point1.x) - diff --git a/testSDL.c b/testSDL.c index f842bd1..1d620d0 100644 --- a/testSDL.c +++ b/testSDL.c @@ -129,11 +129,13 @@ void draw() clearScreen(); - modelTransform.rotation.z = frame * 0.1; - modelTransform.rotation.x = frame * 0.3; + uint32_t f = frame; - modelTransform.translation.x = sin(frame >> 7) * 700; - modelTransform.translation.y = sin(frame >> 8) * 600; + modelTransform.rotation.z = f * 0.1; + modelTransform.rotation.x = f * 0.3; + + modelTransform.translation.x = sin(f >> 7) * 700; + modelTransform.translation.y = sin(f >> 8) * 600; S3L_drawModelIndexed(ver,tri,12,modelTransform,&camera,&conf);