| 1 |
– |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* Routines for handling OpenGL light sources |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
+ |
#include "copyright.h" |
| 9 |
+ |
|
| 10 |
|
#include "radogl.h" |
| 11 |
|
|
| 12 |
|
double expval = 0.; /* global exposure value */ |
| 15 |
|
|
| 16 |
|
int dolights = MAXLIGHTS; /* do how many more light sources? */ |
| 17 |
|
|
| 18 |
< |
static int lightid[MAXLIGHTS] = {GL_LIGHT0, GL_LIGHT1, GL_LIGHT2, |
| 18 |
> |
int glightid[MAXLIGHTS] = {GL_LIGHT0, GL_LIGHT1, GL_LIGHT2, |
| 19 |
|
GL_LIGHT3, GL_LIGHT4, GL_LIGHT5, GL_LIGHT6, GL_LIGHT7}; |
| 20 |
|
|
| 21 |
|
static int lightlist; /* light list id */ |
| 36 |
|
|
| 37 |
|
static int nlights; /* number of defined lights */ |
| 38 |
|
|
| 39 |
< |
static int l_flatsrc(), l_spheresrc(), l_source(); |
| 39 |
> |
static void l_flatsrc(int), l_sphsrc(int), l_source(int); |
| 40 |
|
|
| 41 |
|
|
| 42 |
+ |
void |
| 43 |
|
lightinit() /* initialize lighting */ |
| 44 |
|
{ |
| 45 |
|
GLfloat ambv[4]; |
| 46 |
– |
register int i; |
| 46 |
|
|
| 47 |
|
if (!dolights) |
| 48 |
|
return; |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
|
| 63 |
+ |
void |
| 64 |
|
lightclean() /* clean up light source commands */ |
| 65 |
|
{ |
| 66 |
|
if ((dolights += nlights) <= 0) |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
+ |
void |
| 73 |
|
lightdefs() /* define light source list */ |
| 74 |
|
{ |
| 74 |
– |
register int i; |
| 75 |
– |
|
| 75 |
|
if (!nlights) |
| 76 |
|
return; |
| 77 |
|
glNewList(lightlist, GL_COMPILE); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
|
| 100 |
+ |
int |
| 101 |
|
o_source(o) /* record a distant source */ |
| 102 |
|
register OBJREC *o; |
| 103 |
|
{ |
| 158 |
|
} |
| 159 |
|
|
| 160 |
|
|
| 161 |
< |
static |
| 161 |
> |
static void |
| 162 |
|
l_source(n) /* convert a distant source */ |
| 163 |
|
register int n; |
| 164 |
|
{ |
| 165 |
|
register MATREC *m = lightrec[n].m; |
| 166 |
< |
int thislight = lightid[n]; |
| 166 |
> |
int thislight = glightid[n]; |
| 167 |
|
GLfloat vec[4]; |
| 168 |
|
/* assign direction */ |
| 169 |
|
VCOPY(vec, lightrec[n].pos); |
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
|
| 185 |
< |
static |
| 185 |
> |
static void |
| 186 |
|
l_flatsrc(n) /* convert a flat source */ |
| 187 |
|
register int n; |
| 188 |
|
{ |
| 189 |
|
GLfloat vec[4]; |
| 190 |
|
register MATREC *m = lightrec[n].m; |
| 191 |
< |
int thislight = lightid[n]; |
| 191 |
> |
int thislight = glightid[n]; |
| 192 |
|
/* assign position */ |
| 193 |
|
VCOPY(vec, lightrec[n].pos); vec[3] = 1.; |
| 194 |
|
glLightfv(thislight, GL_POSITION, vec); |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
|
| 220 |
< |
static |
| 220 |
> |
static void |
| 221 |
|
l_sphsrc(n) /* convert a spherical source */ |
| 222 |
|
register int n; |
| 223 |
|
{ |
| 224 |
|
GLfloat vec[4]; |
| 225 |
|
register MATREC *m = lightrec[n].m; |
| 226 |
< |
int thislight = lightid[n]; |
| 226 |
> |
int thislight = glightid[n]; |
| 227 |
|
/* assign position */ |
| 228 |
|
VCOPY(vec, lightrec[n].pos); vec[3] = 1.; |
| 229 |
|
glLightfv(thislight, GL_POSITION, vec); |