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);