summaryrefslogtreecommitdiff
path: root/internal.h
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-08-29 18:19:15 +0000
committerrodri <rgl@antares-labs.eu>2024-08-29 18:19:15 +0000
commitf98dcc45225fa78341aba06137b05b9b6b89cb12 (patch)
tree906647ce3fa15d9b212a666ec0ac66b450827326 /internal.h
parent2c410b56f801708ec11a1af6cdd995d69e9db059 (diff)
downloadlibgraphics-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 'internal.h')
-rw-r--r--internal.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/internal.h b/internal.h
index 3190a19..c204d9a 100644
--- a/internal.h
+++ b/internal.h
@@ -38,6 +38,17 @@ void *erealloc(void*, ulong);
Memimage *eallocmemimage(Rectangle, ulong);
/* fb */
+Raster *allocraster(char*, Rectangle, ulong);
+void clearraster(Raster*, ulong);
+void fclearraster(Raster*, float);
+uchar *rasterbyteaddr(Raster*, Point);
+void rasterput(Raster*, Point, void*);
+void rasterget(Raster*, Point, void*);
+void rasterputcolor(Raster*, Point, ulong);
+ulong rastergetcolor(Raster*, Point);
+void rasterputfloat(Raster*, Point, float);
+float rastergetfloat(Raster*, Point);
+void freeraster(Raster*);
Framebuf *mkfb(Rectangle);
void rmfb(Framebuf*);
Framebufctl *mkfbctl(Rectangle);
@@ -61,10 +72,10 @@ void memsetl(void*, ulong, usize);
/* nanosec */
uvlong nanosec(void);
-/* ulong getpixel(Framebuf *fb, Point p) */
-#define getpixel(fb, p) (((fb)->cb)[Dx((fb)->r)*(p).y + (p).x])
-/* void putpixel(Framebuf *fb, Point p, ulong c) */
-#define putpixel(fb, p, c) (((fb)->cb)[Dx((fb)->r)*(p).y + (p).x] = (c))
+#define getpixel(fb, p) rastergetcolor(fb, p)
+#define putpixel(fb, p, c) rasterputcolor(fb, p, c)
+#define getdepth(fb, p) rastergetfloat(fb, p)
+#define putdepth(fb, p, z) rasterputfloat(fb, p, z)
/* void SWAP(type t, type *a, type *b) */
#define SWAP(t, a, b) {t tmp; tmp = *(a); *(a) = *(b); *(b) = tmp;}