diff options
author | rodri <rgl@antares-labs.eu> | 2024-03-06 12:41:00 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-03-06 12:41:00 +0000 |
commit | 96eb8b3c74e8d95579dbd8a3727b7c25f4d49ba2 (patch) | |
tree | 2601f2d5c017a3aad25cfc55f2ef26f1e4c0431e /graphics.h | |
parent | 6b71bf694a9fa2e694f3e70a2067e0021b2c2f07 (diff) | |
download | libgraphics-96eb8b3c74e8d95579dbd8a3727b7c25f4d49ba2.tar.gz libgraphics-96eb8b3c74e8d95579dbd8a3727b7c25f4d49ba2.tar.bz2 libgraphics-96eb8b3c74e8d95579dbd8a3727b7c25f4d49ba2.zip |
add a texture sampler with nearest and bilinear routines.
pass the material reference along with the vertices.
also implemented back-face culling, but it's disabled
for now.
Diffstat (limited to 'graphics.h')
-rw-r--r-- | graphics.h | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -38,6 +38,28 @@ struct Color double r, g, b, a; }; +/* + * a more general approach worth investigating. + * it could be made to handle types other than double. + * + * examples: + * double intens; + * addvattr(v, "intensity", 1, &intens); + * + * Point3 p; + * addvattr(v, "normal", 3, &p); + * + * Matrix3 m; + * addvattr(v, "proj", 4*4, m); + */ +//struct Vertexattr +//{ +// char *id; +// int type; +// ulong len; +// double val[]; +//}; + struct Vertexattr { char *id; @@ -54,6 +76,7 @@ struct Vertex Point3 n; /* surface normal */ Color c; /* shading color */ Point2 uv; /* texture coordinate */ + OBJMaterial *mtl; /* TODO it'd be neat to use a dynamic hash table instead */ Vertexattr *attrs; /* attributes (aka varyings) */ ulong nattrs; @@ -223,6 +246,11 @@ void delscene(Scene*); void addvattr(Vertex*, char*, int, void*); Vertexattr *getvattr(Vertex*, char*); +/* texture */ +Color neartexsampler(Memimage*, Point2); +Color bilitexsampler(Memimage*, Point2); +Color texture(Memimage*, Point2, Color(*)(Memimage*, Point2)); + /* util */ double fmin(double, double); double fmax(double, double); |