From 714038d0bce05c734d4e45289ec2bf1174463e4a Mon Sep 17 00:00:00 2001 From: rodri Date: Fri, 5 Jul 2024 18:16:49 +0000 Subject: create a new texture interface. --- graphics.h | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'graphics.h') diff --git a/graphics.h b/graphics.h index 335b4b0..70eeb71 100644 --- a/graphics.h +++ b/graphics.h @@ -17,12 +17,18 @@ enum { LIGHT_SPOT, }; +enum { + RAWTexture, + sRGBTexture, +}; + enum { VAPoint, VANumber, }; typedef struct Color Color; +typedef struct Texture Texture; typedef struct Cubemap Cubemap; typedef struct Vertexattr Vertexattr; typedef struct Vertex Vertex; @@ -49,10 +55,16 @@ struct Color double r, g, b, a; }; +struct Texture +{ + Memimage *image; + int type; +}; + struct Cubemap { char *name; - Memimage *faces[6]; + Texture *faces[6]; }; /* @@ -119,8 +131,8 @@ struct Material Color diffuse; Color specular; double shininess; - Memimage *diffusemap; - Memimage *normalmap; + Texture *diffusemap; + Texture *normalmap; }; struct Primitive @@ -135,7 +147,7 @@ struct Model { Primitive *prims; ulong nprims; - Memimage *tex; /* texture map (TODO get rid of it, use materials) */ + Texture *tex; /* texture map (TODO get rid of it, use materials) */ Material *materials; ulong nmaterials; }; @@ -325,12 +337,14 @@ 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)); +Texture *alloctexture(int, Memimage*); +void freetexture(Texture*); +Color neartexsampler(Texture*, Point2); +Color bilitexsampler(Texture*, Point2); +Color texture(Texture*, Point2, Color(*)(Texture*, Point2)); Cubemap *readcubemap(char*[6]); void freecubemap(Cubemap*); -Color cubemaptexture(Cubemap*, Point3, Color(*)(Memimage*, Point2)); +Color cubemaptexture(Cubemap*, Point3, Color(*)(Texture*, Point2)); /* util */ double fmin(double, double); -- cgit v1.2.3