summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--camera.c4
-rw-r--r--graphics.h3
-rw-r--r--render.c7
-rw-r--r--viewport.c7
4 files changed, 15 insertions, 6 deletions
diff --git a/camera.c b/camera.c
index 67bca08..a6bf601 100644
--- a/camera.c
+++ b/camera.c
@@ -86,17 +86,15 @@ shootcamera(Camera *c, Shadertab *s)
job = emalloc(sizeof *job);
memset(job, 0, sizeof *job);
- job->fb = c->vp->fbctl->fb[c->vp->fbctl->idx^1]; /* address the back buffer */
+ job->v = c->vp;
job->scene = c->s;
job->shaders = s;
job->donec = chancreate(sizeof(void*), 0);
- c->vp->fbctl->reset(c->vp->fbctl);
t0 = nanosec();
sendp(c->rctl->c, job);
recvp(job->donec);
t1 = nanosec();
- c->vp->fbctl->swap(c->vp->fbctl);
chanfree(job->donec);
free(job);
diff --git a/graphics.h b/graphics.h
index fdd1463..f109be3 100644
--- a/graphics.h
+++ b/graphics.h
@@ -176,7 +176,7 @@ struct Renderer
struct Renderjob
{
- Framebuf *fb;
+ Viewport *v;
Scene *scene;
Shadertab *shaders;
Channel *donec;
@@ -215,6 +215,7 @@ struct Viewport
void (*draw)(Viewport*, Image*);
void (*memdraw)(Viewport*, Memimage*);
+ Framebuf *(*getfb)(Viewport*);
};
struct Camera
diff --git a/render.c b/render.c
index be19582..6be8179 100644
--- a/render.c
+++ b/render.c
@@ -509,6 +509,7 @@ renderer(void *arg)
job->nrem = sc->nents;
job->lastid = 0;
job->time0 = nanosec();
+ job->v->fbctl->reset(job->v->fbctl);
if(jobq.tl == nil){
jobq.tl = jobq.hd = job;
@@ -526,7 +527,7 @@ sendparams:
if(ent != nil && ent != &sc->ents){
params = emalloc(sizeof *params);
memset(params, 0, sizeof *params);
- params->fb = job->fb;
+ params->fb = job->v->getfb(job->v);
params->id = job->lastid++;
params->frag = rgb(DBlack);
params->donec = donec;
@@ -548,8 +549,10 @@ sendparams:
}
break;
case DONE:
- if(--params2->job->nrem < 1)
+ if(--params2->job->nrem < 1){
+ params2->job->v->fbctl->swap(params2->job->v->fbctl);
send(params2->job->donec, nil);
+ }
freememimage(params2->frag);
free(params2);
diff --git a/viewport.c b/viewport.c
index 0e9b9c5..2089d50 100644
--- a/viewport.c
+++ b/viewport.c
@@ -20,6 +20,12 @@ viewport_memdraw(Viewport *v, Memimage *dst)
v->fbctl->memdraw(v->fbctl, dst);
}
+static Framebuf *
+viewport_getfb(Viewport *v)
+{
+ return v->fbctl->fb[v->fbctl->idx^1]; /* address the back buffer */
+}
+
Viewport *
mkviewport(Rectangle r)
{
@@ -32,6 +38,7 @@ mkviewport(Rectangle r)
v->fbctl = mkfbctl(r);
v->draw = viewport_draw;
v->memdraw = viewport_memdraw;
+ v->getfb = viewport_getfb;
return v;
}