2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /**> HEADER FILES <**/
25 void SetUpLight(Light* whichsource, int whichlight)
27 static float qattenuation[] = {0.0002f};
30 if (whichlight == 0) {
31 GLfloat LightAmbient[] = { whichsource->ambient[0], whichsource->ambient[1], whichsource->ambient[2], 1.0f};
32 GLfloat LightDiffuse[] = { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
33 GLfloat LightPosition[] = { whichsource->location.x, whichsource->location.y, whichsource->location.z, 0.0f };
35 //glLightfv(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, qattenuation);
36 glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
37 glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
38 glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
41 GLenum lightselect = GL_LIGHT1;
44 lightselect = GL_LIGHT2;
47 lightselect = GL_LIGHT3;
50 lightselect = GL_LIGHT4;
53 lightselect = GL_LIGHT5;
56 lightselect = GL_LIGHT6;
59 lightselect = GL_LIGHT7;
63 GLfloat LightAmbient[] = { 0, 0, 0, 1.0f};
64 GLfloat LightDiffuse[] = { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
65 GLfloat LightPosition[] = { whichsource->location.x, whichsource->location.y, whichsource->location.z, 1.0f };
67 glLightfv(lightselect, GL_QUADRATIC_ATTENUATION, qattenuation);
68 glLightfv(lightselect, GL_POSITION, LightPosition);
69 glLightfv(lightselect, GL_AMBIENT, LightAmbient);
70 glLightfv(lightselect, GL_DIFFUSE, LightDiffuse);
71 glEnable(lightselect);
76 void SetUpMainLight(Light* whichsource, int whichlight, float ambientr, float ambientg, float ambientb)
78 static float qattenuation[] = {0.0f};
82 if (whichlight == 0) {
83 GLfloat LightAmbient[] = { ambientr, ambientg, ambientb, 1.0f};
84 GLfloat LightDiffuse[] = { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
85 GLfloat LightPosition[] = { whichsource->location.x, whichsource->location.y, whichsource->location.z, 1.0f };
87 glLightfv(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, qattenuation);
88 glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
89 glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
90 glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);