From 509ebce56cd8dcbb8aa159fd32b79f5b13b7a1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 11 May 2019 23:51:16 +0200 Subject: [PATCH] Parametrize texture coords --- s3l.h | 26 +++++++++++++------------- testSDL.c | 14 +++++++------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/s3l.h b/s3l.h index b42876e..1ef4f62 100644 --- a/s3l.h +++ b/s3l.h @@ -198,19 +198,19 @@ typedef int32_t S3L_Unit; /**< Units of measurement in 3D space. There is /** Predefined texture coordinates of a cube, corresponding to triangles (NOT vertices), to be used with S3L_CUBE_VERTICES and S3L_CUBE_TRIANGLES. */ -#define S3L_CUBE_TEXCOORDS\ - 1,1, 0,0, 1,0,\ - 1,1, 0,1, 0,0,\ - 1,0, 1,1, 0,1,\ - 1,0, 0,1, 0,0,\ - 0,0, 1,0, 1,1,\ - 1,1, 0,1, 0,0,\ - 0,1, 0,0, 1,0,\ - 0,1, 1,0, 1,1,\ - 1,1, 0,0, 1,0,\ - 1,1, 0,1, 0,0,\ - 0,1, 1,0, 1,1,\ - 0,1, 0,0, 1,0 +#define S3L_CUBE_TEXCOORDS(m)\ + m,m, 0,0, m,0,\ + m,m, 0,m, 0,0,\ + m,0, m,m, 0,m,\ + m,0, 0,m, 0,0,\ + 0,0, m,0, m,m,\ + m,m, 0,m, 0,0,\ + 0,m, 0,0, m,0,\ + 0,m, m,0, m,m,\ + m,m, 0,0, m,0,\ + m,m, 0,m, 0,0,\ + 0,m, m,0, m,m,\ + 0,m, 0,0, m,0 #define S3L_SIN_TABLE_LENGTH 128 static const S3L_Unit S3L_sinTable[S3L_SIN_TABLE_LENGTH] = diff --git a/testSDL.c b/testSDL.c index 60a830b..f2272a7 100644 --- a/testSDL.c +++ b/testSDL.c @@ -32,7 +32,7 @@ const int16_t test_coords[] = const S3L_Unit ver[] = { S3L_CUBE_VERTICES }; const S3L_Index tri[] = { S3L_CUBE_TRIANGLES }; -const S3L_Unit tex_coords[] = { S3L_CUBE_TEXCOORDS }; +const S3L_Unit tex_coords[] = { S3L_CUBE_TEXCOORDS(16) }; int8_t keys[256]; @@ -103,15 +103,15 @@ void drawPixel(S3L_PixelInfo *p) coords = tex_coords + p->triangleID * 6; u = S3L_interpolateBarycentric( - coords[0] * 16, - coords[2] * 16, - coords[4] * 16, + coords[0], + coords[2], + coords[4], p->barycentric0, p->barycentric1, p->barycentric2); v = S3L_interpolateBarycentric( - coords[1] * 16, - coords[3] * 16, - coords[5] * 16, + coords[1], + coords[3], + coords[5], p->barycentric0, p->barycentric1, p->barycentric2); uint8_t col = texturePixel(u,v);