aboutsummaryrefslogtreecommitdiff
path: root/graphics.h
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-05-03 13:32:48 +0000
committerrodri <rgl@antares-labs.eu>2024-05-03 13:32:48 +0000
commitb429311ed087ee7cf7fc7771a8e1834ea074f8da (patch)
treeef05d69723ebcdf89a2d8a25b069075b2b51fc63 /graphics.h
parentcf3e0cb65c03955ef18624a50b9e33c3f6e8c6e5 (diff)
downloadlibgraphics-b429311ed087ee7cf7fc7771a8e1834ea074f8da.tar.gz
libgraphics-b429311ed087ee7cf7fc7771a8e1834ea074f8da.tar.bz2
libgraphics-b429311ed087ee7cf7fc7771a8e1834ea074f8da.zip
add a general primitive with support for points, lines and triangles.
also got rid of the dependency on OBJ for the entire renderer, instead letting the user load a Model from any given OBJ. this modularity will allow for other formats to be used in the same way, relying on a single, internal representation for the entire pipeline.
Diffstat (limited to 'graphics.h')
-rw-r--r--graphics.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/graphics.h b/graphics.h
index 5abfa0c..7d4006c 100644
--- a/graphics.h
+++ b/graphics.h
@@ -86,7 +86,7 @@ struct Vertex
Point3 n; /* surface normal */
Color c; /* shading color */
Point2 uv; /* texture coordinate */
- OBJMaterial *mtl;
+ Material *mtl;
/* TODO it'd be neat to use a dynamic hash table instead */
Vertexattr *attrs; /* attributes (aka varyings) */
@@ -106,25 +106,24 @@ struct Material
Color diffuse;
Color specular;
double shininess;
+ Memimage *diffusemap;
};
struct Primitive
{
int type;
Vertex v[3];
+ Material *mtl;
};
struct Model
{
- Primitive *mesh;
+ Primitive *prims;
+ ulong nprims;
Memimage *tex; /* texture map */
Memimage *nor; /* normals map */
Material *materials;
ulong nmaterials;
-
- OBJ *obj;
- OBJElem **elems; /* cache of renderable elems */
- ulong nelems;
};
struct Entity
@@ -167,7 +166,7 @@ struct SUparams
Memimage *frag;
Renderjob *job;
Entity *entity;
- OBJElem **eb, **ee;
+ Primitive *eb, *ee;
uvlong uni_time;
@@ -283,7 +282,7 @@ void perspective(Matrix3, double, double, double, double);
void orthographic(Matrix3, double, double, double, double, double, double);
/* scene */
-int refreshmodel(Model*);
+int loadobjmodel(Model*, OBJ*);
Model *newmodel(void);
void delmodel(Model*);
Entity *newentity(Model*);