summaryrefslogtreecommitdiff
path: root/graphics.h
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-10-01 20:21:13 +0000
committerrodri <rgl@antares-labs.eu>2024-10-01 20:21:13 +0000
commitb6a336aff26fbc94e7803719a8aeb8fa29eddb9b (patch)
treeee3049837fc0edf7e3d2133aa711457bbf9b8859 /graphics.h
parent453d100ac7734cd64652aa4d3a0685e3494428f7 (diff)
downloadlibgraphics-b6a336aff26fbc94e7803719a8aeb8fa29eddb9b.tar.gz
libgraphics-b6a336aff26fbc94e7803719a8aeb8fa29eddb9b.tar.bz2
libgraphics-b6a336aff26fbc94e7803719a8aeb8fa29eddb9b.zip
implement a uniforms interface through Shadertab.
Diffstat (limited to 'graphics.h')
-rw-r--r--graphics.h24
1 files changed, 11 insertions, 13 deletions
diff --git a/graphics.h b/graphics.h
index 3479c7d..047334d 100644
--- a/graphics.h
+++ b/graphics.h
@@ -51,6 +51,7 @@ typedef struct Color Color;
typedef struct Texture Texture;
typedef struct Cubemap Cubemap;
typedef struct Vertexattr Vertexattr;
+typedef struct Vertexattrs Vertexattrs;
typedef struct Vertex Vertex;
typedef struct LightSource LightSource;
typedef struct Material Material;
@@ -123,6 +124,12 @@ struct Vertexattr
};
};
+struct Vertexattrs
+{
+ Vertexattr *attrs;
+ ulong nattrs;
+};
+
struct Vertex
{
Point3 p; /* position */
@@ -131,10 +138,7 @@ struct Vertex
Point2 uv; /* texture coordinate */
Material *mtl;
Point3 tangent;
-
- /* TODO it'd be neat to use a dynamic hash table instead */
- Vertexattr *attrs; /* attributes (aka varyings) */
- ulong nattrs;
+ Vertexattrs; /* attributes (varyings) */
};
struct LightSource
@@ -219,15 +223,11 @@ struct Shaderparams
struct SUparams
{
Framebuf *fb;
+ Shadertab *stab;
Renderjob *job;
Camera *camera;
Entity *entity;
Primitive *eb, *ee;
-
- uvlong uni_time;
-
- Point3 (*vshader)(Shaderparams*);
- Color (*fshader)(Shaderparams*);
};
struct Shadertab
@@ -235,6 +235,7 @@ struct Shadertab
char *name;
Point3 (*vshader)(Shaderparams*); /* vertex shader */
Color (*fshader)(Shaderparams*); /* fragment shader */
+ Vertexattrs; /* uniforms */
};
struct Rendertime
@@ -387,6 +388,7 @@ void rmviewport(Viewport*);
/* render */
Renderer *initgraphics(void);
+void setuniform(Shadertab*, char*, int, void*);
/* xform */
Point3 model2world(Entity*, Point3);
@@ -421,10 +423,6 @@ Scene *dupscene(Scene*);
void delscene(Scene*);
void clearscene(Scene*);
-/* vertex */
-void addvattr(Vertex*, char*, int, void*);
-Vertexattr *getvattr(Vertex*, char*);
-
/* texture */
Texture *alloctexture(int, Memimage*);
Texture *duptexture(Texture*);