mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-12-23 01:26:19 +01:00
Parametrize texture coords
This commit is contained in:
parent
420bbc3aa6
commit
509ebce56c
2 changed files with 20 additions and 20 deletions
26
s3l.h
26
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] =
|
||||
|
|
14
testSDL.c
14
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);
|
||||
|
|
Loading…
Reference in a new issue