diff options
author | rodri <rgl@antares-labs.eu> | 2024-08-29 18:19:15 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-08-29 18:19:15 +0000 |
commit | f98dcc45225fa78341aba06137b05b9b6b89cb12 (patch) | |
tree | 906647ce3fa15d9b212a666ec0ac66b450827326 /graphics.h | |
parent | 2c410b56f801708ec11a1af6cdd995d69e9db059 (diff) | |
download | libgraphics-f98dcc45225fa78341aba06137b05b9b6b89cb12.tar.gz libgraphics-f98dcc45225fa78341aba06137b05b9b6b89cb12.tar.bz2 libgraphics-f98dcc45225fa78341aba06137b05b9b6b89cb12.zip |
implement a general raster interface for the framebuffers.
got a bit tired of having to add a ulong *buf every time
i needed to get some data out of the shaders, so i made
it possible to create as many extra buffers as needed,
which then can be addressed from the fragment shader
and drawn using the same drawing routines that were used
for the color buffer.
these so called Rasters are very similar to the OpenGL
FBOs, in case you are familiar, but we address them by
strings instead of numbers. and they can also be used as
textures if you create one (see alloctexture) and then
memdraw into it after every shot.
Diffstat (limited to 'graphics.h')
-rw-r--r-- | graphics.h | 40 |
1 files changed, 31 insertions, 9 deletions
@@ -23,6 +23,10 @@ enum { LightDirectional, LightSpot, + /* raster formats */ + COLOR32 = 0, + FLOAT32, + /* texture formats */ RAWTexture = 0, /* unmanaged */ sRGBTexture, @@ -50,6 +54,7 @@ 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 SUparams SUparams; typedef struct Shadertab Shadertab; @@ -59,6 +64,7 @@ typedef struct Renderjob Renderjob; typedef struct Fragment Fragment; typedef struct Astk Astk; typedef struct Abuf Abuf; +typedef struct Raster Raster; typedef struct Framebuf Framebuf; typedef struct Framebufctl Framebufctl; typedef struct Viewport Viewport; @@ -205,6 +211,8 @@ struct FSparams SUparams *su; Point p; Vertex v; /* only for the attributes (varyings) */ + + void (*toraster)(FSparams*, char*, void*); }; /* shader unit params */ @@ -278,13 +286,24 @@ struct Abuf ulong nact; }; +struct Raster +{ + Rectangle r; + char *name; + ulong chan; + ulong *data; + + Raster *next; +}; + struct Framebuf { - ulong *cb; /* color buffer */ - float *zb; /* z/depth buffer */ - ulong *nb; /* normals buffer (DBG only) */ - Abuf abuf; /* A-buffer */ Rectangle r; + Raster *rasters; /* [0] color, [1] depth, [n] user-defined */ + Abuf abuf; /* A-buffer */ + + void (*createraster)(Framebuf*, char*, ulong); + Raster *(*fetchraster)(Framebuf*, char*); }; struct Framebufctl @@ -294,11 +313,12 @@ struct Framebufctl uint idx; /* front buffer index */ uint upfilter; /* upscaling filter */ - void (*draw)(Framebufctl*, Image*, Point, Point); - void (*memdraw)(Framebufctl*, Memimage*, Point, Point); - void (*drawnormals)(Framebufctl*, Image*); + void (*draw)(Framebufctl*, Image*, char*, Point, Point); + void (*memdraw)(Framebufctl*, Memimage*, char*, Point, Point); void (*swap)(Framebufctl*); void (*reset)(Framebufctl*, ulong); + void (*createraster)(Framebufctl*, char*, ulong); + Raster *(*fetchraster)(Framebufctl*, char*); Framebuf *(*getfb)(Framebufctl*); Framebuf *(*getbb)(Framebufctl*); }; @@ -309,13 +329,15 @@ struct Viewport Framebufctl *fbctl; Rectangle r; - void (*draw)(Viewport*, Image*); - void (*memdraw)(Viewport*, Memimage*); + void (*draw)(Viewport*, Image*, char*); + void (*memdraw)(Viewport*, Memimage*, char*); void (*setscale)(Viewport*, double, double); void (*setscalefilter)(Viewport*, int); Framebuf *(*getfb)(Viewport*); int (*getwidth)(Viewport*); int (*getheight)(Viewport*); + void (*createraster)(Viewport*, char*, ulong); + Raster *(*fetchraster)(Viewport*, char*); }; struct Camera |