From bc68a4014a8321eede5851fe33ac7acd199ec3f9 Mon Sep 17 00:00:00 2001 From: rodri Date: Sat, 10 Feb 2024 19:00:31 +0000 Subject: reuse the modeltex for inception mode. --- main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index c35d738..226ac15 100644 --- a/main.c +++ b/main.c @@ -322,33 +322,32 @@ redraw(void) void drawproc(void *) { - Memimage *scrtex; uvlong t0, Δt; int fd; threadsetname("drawproc"); - scrtex = nil; fd = -1; if(inception){ fd = open("/dev/screen", OREAD); if(fd < 0) sysfatal("open: %r"); - if((scrtex = readmemimage(fd)) == nil) + freememimage(modeltex); + if((modeltex = readmemimage(fd)) == nil) sysfatal("readmemimage: %r"); } t0 = nsec(); for(;;){ - shootcamera(maincam, model, inception? scrtex: modeltex, shader); + shootcamera(maincam, model, modeltex, shader); Δt = nsec() - t0; if(Δt > HZ2MS(60)*1000000ULL){ nbsend(drawc, nil); t0 += Δt; if(inception){ - freememimage(scrtex); + freememimage(modeltex); seek(fd, 0, 0); - if((scrtex = readmemimage(fd)) == nil) + if((modeltex = readmemimage(fd)) == nil) sysfatal("readmemimage: %r"); } } -- cgit v1.2.3