shithub: libgraphics

Download patch

ref: 4d711e22d597a42e1478e2f3c2d3c23312520309
parent: d22a9cf1583075186a19282c7566b520ec1dcd81
author: rodri <rgl@antares-labs.eu>
date: Mon Apr 1 12:16:49 EDT 2024

viewport: add a way to access front and back buffers.

--- a/graphics.h
+++ b/graphics.h
@@ -216,6 +216,7 @@
 	void (*draw)(Viewport*, Image*);
 	void (*memdraw)(Viewport*, Memimage*);
 	Framebuf *(*getfb)(Viewport*);
+	Framebuf *(*getbb)(Viewport*);
 };
 
 struct Camera
--- a/render.c
+++ b/render.c
@@ -527,7 +527,7 @@
 			if(ent != nil && ent != &sc->ents){
 				params = emalloc(sizeof *params);
 				memset(params, 0, sizeof *params);
-				params->fb = job->v->getfb(job->v);
+				params->fb = job->v->getbb(job->v);
 				params->id = job->lastid++;
 				params->frag = rgb(DBlack);
 				params->donec = donec;
--- a/viewport.c
+++ b/viewport.c
@@ -23,9 +23,15 @@
 static Framebuf *
 viewport_getfb(Viewport *v)
 {
-	return v->fbctl->fb[v->fbctl->idx^1];	/* address the back buffer */
+	return v->fbctl->fb[v->fbctl->idx];	/* front buffer */
 }
 
+static Framebuf *
+viewport_getbb(Viewport *v)
+{
+	return v->fbctl->fb[v->fbctl->idx^1];	/* back buffer */
+}
+
 Viewport *
 mkviewport(Rectangle r)
 {
@@ -39,6 +45,7 @@
 	v->draw = viewport_draw;
 	v->memdraw = viewport_memdraw;
 	v->getfb = viewport_getfb;
+	v->getbb = viewport_getbb;
 	return v;
 }