From 04d50b8bbe324fdb7a8a1e724fbc59c4050862f0 Mon Sep 17 00:00:00 2001 From: rodri Date: Sat, 13 Jul 2024 10:23:52 +0000 Subject: fix the geometry glitches when moving things around. it's possible for interactive programs to keep updating the geometry of the scene during rendering, which caused primitives to look deformed or shattered in the final image. to avoid this we take a snapshot of the current state of things (scene and camera), and render based on that copy. --- util.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'util.c') diff --git a/util.c b/util.c index db538a3..0b9003e 100644 --- a/util.c +++ b/util.c @@ -84,3 +84,18 @@ rgb(ulong c) memfillcolor(i, c); return i; } + +Memimage * +dupmemimage(Memimage *i) +{ + Memimage *ni; + + if(i == nil) + return nil; + + ni = allocmemimaged(i->r, i->chan, i->data); + if(ni == nil) + sysfatal("allocmemimaged: %r"); + ni->data->ref++; + return ni; +} -- cgit v1.2.3