aboutsummaryrefslogtreecommitdiff
path: root/graphics.h
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-04-16 02:48:01 +0000
committerrodri <rgl@antares-labs.eu>2024-04-16 02:48:01 +0000
commitb41192ebe4f5f0720cf7e4dc5ca1f6fc0131daf1 (patch)
treebbd3aaa1a6c6c1e11cda1294c48a9832b1e40361 /graphics.h
parenta101d22599c9052ab242d68e12522732e710cc9e (diff)
downloadlibgraphics-b41192ebe4f5f0720cf7e4dc5ca1f6fc0131daf1.tar.gz
libgraphics-b41192ebe4f5f0720cf7e4dc5ca1f6fc0131daf1.tar.bz2
libgraphics-b41192ebe4f5f0720cf7e4dc5ca1f6fc0131daf1.zip
replace the Triangle with a general purpose Primitive.
this is only an structural replacement and doesn't add support for the other primitive types.
Diffstat (limited to 'graphics.h')
-rw-r--r--graphics.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/graphics.h b/graphics.h
index 1fc23c1..5abfa0c 100644
--- a/graphics.h
+++ b/graphics.h
@@ -2,10 +2,16 @@
typedef enum {
ORTHOGRAPHIC,
- PERSPECTIVE
+ PERSPECTIVE,
} Projection;
enum {
+ PPoint,
+ PLine,
+ PTriangle,
+};
+
+enum {
LIGHT_POINT,
LIGHT_DIRECTIONAL,
LIGHT_SPOT,
@@ -21,6 +27,7 @@ typedef struct Vertexattr Vertexattr;
typedef struct Vertex Vertex;
typedef struct LightSource LightSource;
typedef struct Material Material;
+typedef struct Primitive Primitive;
typedef struct Model Model;
typedef struct Entity Entity;
typedef struct Scene Scene;
@@ -86,8 +93,6 @@ struct Vertex
ulong nattrs;
};
-typedef Vertex Triangle[3];
-
struct LightSource
{
Point3 p;
@@ -103,16 +108,22 @@ struct Material
double shininess;
};
+struct Primitive
+{
+ int type;
+ Vertex v[3];
+};
+
struct Model
{
- OBJ *obj;
+ Primitive *mesh;
Memimage *tex; /* texture map */
Memimage *nor; /* normals map */
Material *materials;
ulong nmaterials;
- /* cache of renderable elems */
- OBJElem **elems;
+ OBJ *obj;
+ OBJElem **elems; /* cache of renderable elems */
ulong nelems;
};
@@ -190,7 +201,7 @@ struct Renderjob
Channel *donec;
struct {
- Rendertime R, E, Tn, Rn;
+ Rendertime R, E, Tn, Rn; /* renderer, entityproc, tilers, rasterizers */
} times;
Renderjob *next;
@@ -199,7 +210,7 @@ struct Renderjob
struct Framebuf
{
Memimage *cb; /* color buffer */
- double *zbuf; /* z/depth buffer */
+ double *zb; /* z/depth buffer */
Rectangle r;
};