mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-11-23 20:59:58 +01:00
Fix bug
This commit is contained in:
parent
91e078b920
commit
fbab60d893
2 changed files with 28 additions and 4 deletions
12
small3dlib.h
12
small3dlib.h
|
@ -1485,14 +1485,20 @@ void S3L_drawTriangle(
|
|||
}
|
||||
|
||||
#if S3L_PERSPECTIVE_CORRECTION == 1
|
||||
S3L_ScreenCoord i = lXClipped - lX; /* helper var to save one
|
||||
substraction in the inner loop */
|
||||
S3L_ScreenCoord i = lXClipped - lX - 1; /* helper var to save one
|
||||
substraction in the inner
|
||||
loop */
|
||||
#endif
|
||||
|
||||
// draw the row -- inner loop:
|
||||
|
||||
for (S3L_ScreenCoord x = lXClipped; x < rXClipped; ++x)
|
||||
{
|
||||
#if S3L_PERSPECTIVE_CORRECTION == 1
|
||||
++i; /* Has to be done here, because the following tests can skip the
|
||||
the rest of the loop. */
|
||||
#endif
|
||||
|
||||
#if S3L_STENCIL_BUFFER
|
||||
if (!S3L_stencilTest(x,p.y))
|
||||
continue;
|
||||
|
@ -1531,8 +1537,6 @@ void S3L_drawTriangle(
|
|||
(lOverZ - S3L_interpolateFrom0(lOverZ,i,rowLength))
|
||||
* p.depth
|
||||
) / S3L_FRACTIONS_PER_UNIT;
|
||||
|
||||
i++;
|
||||
#else
|
||||
*barycentric0 = S3L_getFastLerpValue(b0FLS);
|
||||
*barycentric1 = S3L_getFastLerpValue(b1FLS);
|
||||
|
|
20
testSDL.c
20
testSDL.c
|
@ -11,6 +11,7 @@
|
|||
|
||||
#define S3L_PERSPECTIVE_CORRECTION 1
|
||||
#define S3L_Z_BUFFER 1
|
||||
#define S3L_SORT 0
|
||||
|
||||
#define S3L_PIXEL_FUNCTION drawPixel
|
||||
|
||||
|
@ -32,6 +33,7 @@ S3L_Scene scene;
|
|||
int8_t keys[256];
|
||||
|
||||
const uint8_t testTexture[] =
|
||||
/*
|
||||
{
|
||||
2,2,2,0,0,0,2,2,2,2,0,0,0,2,2,2,
|
||||
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
|
||||
|
@ -50,6 +52,24 @@ const uint8_t testTexture[] =
|
|||
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
|
||||
2,2,2,0,0,0,2,2,2,2,0,0,0,2,2,2
|
||||
};
|
||||
*/
|
||||
{
|
||||
0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,
|
||||
1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,
|
||||
2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,
|
||||
0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,
|
||||
1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,
|
||||
2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,
|
||||
0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,
|
||||
1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,
|
||||
2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,
|
||||
0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,
|
||||
1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,
|
||||
2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,
|
||||
0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,
|
||||
1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,
|
||||
2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2
|
||||
};
|
||||
|
||||
uint32_t pixels[S3L_RESOLUTION_X * S3L_RESOLUTION_Y];
|
||||
|
||||
|
|
Loading…
Reference in a new issue