ref: af89f884a13a8ee2cc7d9d09cc88a3fbb145f177
parent: 231a3c4ea98d9448b96ab12aa3b34be30ecad0f2
author: rodri <rgl@antares-labs.eu>
date: Mon Mar 25 18:28:39 EDT 2024
use the new renderer interface.
--- a/main.c
+++ b/main.c
@@ -44,7 +44,7 @@
Keyboardctl *kctl;
Channel *drawc;
int kdown;
-Shader *shader;
+Shadertab *shader;
Model *model;
Entity *subject;
Scene *scene;
@@ -413,7 +413,7 @@
return Pt3(uv.x, uv.y, smoothstep(0,1,uv.x+uv.y), 1);
}
-Shader shadertab[] = {
+Shadertab shadertab[] = {
{ "triangle", ivshader, triangleshader },
{ "circle", ivshader, circleshader },
{ "box", ivshader, boxshader },
@@ -423,7 +423,7 @@
{ "gouraud", gouraudvshader, gouraudshader },
{ "phong", phongvshader, phongshader },
};
-Shader *
+Shadertab *
getshader(char *name)
{
int i;
@@ -729,6 +729,7 @@
threadmain(int argc, char *argv[])
{
Viewport *v;
+ Renderer *rctl;
Channel *keyc;
char *texpath, *norpath, *sname, *mdlpath;
int i, fd;
@@ -783,10 +784,12 @@
refreshmodel(model);
}
- if(initdraw(nil, nil, "3d") < 0)
- sysfatal("initdraw: %r");
if(memimageinit() != 0)
sysfatal("memimageinit: %r");
+ if((rctl = initgraphics()) == nil)
+ sysfatal("initgraphics: %r");
+ if(initdraw(nil, nil, "3d") < 0)
+ sysfatal("initdraw: %r");
if((mctl = initmouse(nil, screen)) == nil)
sysfatal("initmouse: %r");
@@ -796,6 +799,7 @@
placecamera(&cams[i], camcfgs[i].p, camcfgs[i].lookat, camcfgs[i].up);
configcamera(&cams[i], v, camcfgs[i].fov, camcfgs[i].clipn, camcfgs[i].clipf, camcfgs[i].ptype);
cams[i].s = scene;
+ cams[i].rctl = rctl;
}
maincam = &cams[3];
light.p = Pt3(0,100,100,1);