Back to index

radiance  4R0+20100331
rgldomat.c
Go to the documentation of this file.
00001 #ifndef lint
00002 static const char    RCSid[] = "$Id: rgldomat.c,v 3.4 2003/11/14 17:22:06 schorsch Exp $";
00003 #endif
00004 /*
00005  * Invocation routines for Radiance -> OpenGL materials.
00006  */
00007 
00008 #include "copyright.h"
00009 
00010 #include "radogl.h"
00011 
00012 
00013 void
00014 domatobj(mp, cent)          /* generate OpenGL material for object */
00015 register MATREC      *mp;
00016 FVECT  cent;
00017 {
00018        GLfloat       vec[4];
00019 
00020        if ((mp == NULL) | !domats)
00021               return;
00022        if (islight(mp->type)) {
00023               vec[0] = colval(mp->u.l.emission,RED);
00024               vec[1] = colval(mp->u.l.emission,GRN);
00025               vec[2] = colval(mp->u.l.emission,BLU);
00026               vec[3] = 1.;
00027               glMaterialfv(GL_FRONT, GL_EMISSION, vec);
00028               vec[0] = vec[1] = vec[2] = 0.; vec[3] = 1.;
00029               glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, vec);
00030               glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, vec);
00031        } else {
00032               vec[0] = colval(mp->u.m.ambdiff,RED);
00033               vec[1] = colval(mp->u.m.ambdiff,GRN);
00034               vec[2] = colval(mp->u.m.ambdiff,BLU);
00035               vec[3] = 1.;
00036               glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, vec);
00037               vec[0] = colval(mp->u.m.specular,RED);
00038               vec[1] = colval(mp->u.m.specular,GRN);
00039               vec[2] = colval(mp->u.m.specular,BLU);
00040               vec[3] = 1.;
00041               glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, vec);
00042               glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, mp->u.m.specexp);
00043               vec[0] = vec[1] = vec[2] = 0.; vec[3] = 1.;
00044               glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, vec);
00045        }
00046        rgl_checkerr("in domatobj");
00047 }
00048 
00049 
00050 void
00051 domatvert(mp, v, n)         /* generate OpenGL material for vertex */
00052 MATREC *mp;
00053 FVECT  v, n;
00054 {
00055        /* unimplemented */
00056 }