From 406aa46cad83725c4560737aa6f2d4a40277a108 Mon Sep 17 00:00:00 2001 From: rodri Date: Sun, 1 Sep 2024 12:20:21 +0000 Subject: unify shaders into a single interface. --- graphics.h | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'graphics.h') diff --git a/graphics.h b/graphics.h index 106f467..a361491 100644 --- a/graphics.h +++ b/graphics.h @@ -53,9 +53,7 @@ typedef struct Primitive Primitive; typedef struct Model Model; typedef struct Entity Entity; typedef struct Scene Scene; -typedef struct VSparams VSparams; -typedef struct FSoutput FSoutput; -typedef struct FSparams FSparams; +typedef struct Shaderparams Shaderparams; typedef struct SUparams SUparams; typedef struct Shadertab Shadertab; typedef struct Renderer Renderer; @@ -198,21 +196,17 @@ struct Scene Entity *(*getent)(Scene*, char*); }; -/* shader params */ -struct VSparams +struct Shaderparams { SUparams *su; Vertex *v; - uint idx; -}; - -struct FSparams -{ - SUparams *su; - Point p; - Vertex v; /* only for the attributes (varyings) */ + Point p; /* fragment position (fshader-only) */ + uint idx; /* vertex index (vshader-only) */ - void (*toraster)(FSparams*, char*, void*); + Vertexattr *(*getuniform)(Shaderparams*, char*); + Vertexattr *(*getattr)(Shaderparams*, char*); + void (*setattr)(Shaderparams*, char*, int, void*); + void (*toraster)(Shaderparams*, char*, void*); }; /* shader unit params */ @@ -226,15 +220,15 @@ struct SUparams uvlong uni_time; - Point3 (*vshader)(VSparams*); - Color (*fshader)(FSparams*); + Point3 (*vshader)(Shaderparams*); + Color (*fshader)(Shaderparams*); }; struct Shadertab { char *name; - Point3 (*vshader)(VSparams*); /* vertex shader */ - Color (*fshader)(FSparams*); /* fragment shader */ + Point3 (*vshader)(Shaderparams*); /* vertex shader */ + Color (*fshader)(Shaderparams*); /* fragment shader */ }; struct Renderer -- cgit v1.2.3