diff options
author | rodri <rgl@antares-labs.eu> | 2024-10-01 20:21:13 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-10-01 20:21:13 +0000 |
commit | b6a336aff26fbc94e7803719a8aeb8fa29eddb9b (patch) | |
tree | ee3049837fc0edf7e3d2133aa711457bbf9b8859 /graphics.h | |
parent | 453d100ac7734cd64652aa4d3a0685e3494428f7 (diff) | |
download | libgraphics-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.h | 24 |
1 files changed, 11 insertions, 13 deletions
@@ -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*); |