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){
26 static float qattenuation[]={0.0002f};
27 static float cattenuation[]={1.5f};
28 static float lattenuation[]={0.5f};
29 static float zattenuation[]={0.0f};
34 GLfloat LightAmbient[]= { whichsource->ambient[0], whichsource->ambient[1], whichsource->ambient[2], 1.0f};
35 GLfloat LightDiffuse[]= { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
36 GLfloat LightPosition[]= { whichsource->location.x, whichsource->location.y, whichsource->location.z, 0.0f };
38 //glLightfv(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, qattenuation);
39 glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
40 glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
41 glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
46 GLfloat LightAmbient[]= { 0, 0, 0, 1.0f};
47 GLfloat LightDiffuse[]= { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
48 GLfloat LightPosition[]= { whichsource->location.x, whichsource->location.y, whichsource->location.z, 1.0f };
50 glLightfv(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, qattenuation);
51 glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
52 glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
53 glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
58 GLfloat LightAmbient[]= { 0, 0, 0, 1.0f};
59 GLfloat LightDiffuse[]= { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
60 GLfloat LightPosition[]= { whichsource->location.x, whichsource->location.y, whichsource->location.z, 1.0f };
62 glLightfv(GL_LIGHT2, GL_QUADRATIC_ATTENUATION, qattenuation);
63 glLightfv(GL_LIGHT2, GL_POSITION, LightPosition);
64 glLightfv(GL_LIGHT2, GL_AMBIENT, LightAmbient);
65 glLightfv(GL_LIGHT2, GL_DIFFUSE, LightDiffuse);
70 GLfloat LightAmbient[]= { 0, 0, 0, 1.0f};
71 GLfloat LightDiffuse[]= { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
72 GLfloat LightPosition[]= { whichsource->location.x, whichsource->location.y, whichsource->location.z, 1.0f };
74 glLightfv(GL_LIGHT3, GL_QUADRATIC_ATTENUATION, qattenuation);
75 glLightfv(GL_LIGHT3, GL_POSITION, LightPosition);
76 glLightfv(GL_LIGHT3, GL_AMBIENT, LightAmbient);
77 glLightfv(GL_LIGHT3, GL_DIFFUSE, LightDiffuse);
82 GLfloat LightAmbient[]= { 0, 0, 0, 1.0f};
83 GLfloat LightDiffuse[]= { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
84 GLfloat LightPosition[]= { whichsource->location.x, whichsource->location.y, whichsource->location.z, 1.0f };
86 glLightfv(GL_LIGHT4, GL_QUADRATIC_ATTENUATION, qattenuation);
87 glLightfv(GL_LIGHT4, GL_POSITION, LightPosition);
88 glLightfv(GL_LIGHT4, GL_AMBIENT, LightAmbient);
89 glLightfv(GL_LIGHT4, GL_DIFFUSE, LightDiffuse);
94 GLfloat LightAmbient[]= { 0, 0, 0, 1.0f};
95 GLfloat LightDiffuse[]= { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
96 GLfloat LightPosition[]= { whichsource->location.x, whichsource->location.y, whichsource->location.z, 1.0f };
98 glLightfv(GL_LIGHT5, GL_QUADRATIC_ATTENUATION, qattenuation);
99 glLightfv(GL_LIGHT5, GL_POSITION, LightPosition);
100 glLightfv(GL_LIGHT5, GL_AMBIENT, LightAmbient);
101 glLightfv(GL_LIGHT5, GL_DIFFUSE, LightDiffuse);
106 GLfloat LightAmbient[]= { 0, 0, 0, 1.0f};
107 GLfloat LightDiffuse[]= { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
108 GLfloat LightPosition[]= { whichsource->location.x, whichsource->location.y, whichsource->location.z, 1.0f };
110 glLightfv(GL_LIGHT6, GL_QUADRATIC_ATTENUATION, qattenuation);
111 glLightfv(GL_LIGHT6, GL_POSITION, LightPosition);
112 glLightfv(GL_LIGHT6, GL_AMBIENT, LightAmbient);
113 glLightfv(GL_LIGHT6, GL_DIFFUSE, LightDiffuse);
118 GLfloat LightAmbient[]= { 0, 0, 0, 1.0f};
119 GLfloat LightDiffuse[]= { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
120 GLfloat LightPosition[]= { whichsource->location.x, whichsource->location.y, whichsource->location.z, 1.0f };
122 glLightfv(GL_LIGHT7, GL_QUADRATIC_ATTENUATION, qattenuation);
123 glLightfv(GL_LIGHT7, GL_POSITION, LightPosition);
124 glLightfv(GL_LIGHT7, GL_AMBIENT, LightAmbient);
125 glLightfv(GL_LIGHT7, GL_DIFFUSE, LightDiffuse);
130 void SetUpMainLight(Light* whichsource, int whichlight, float ambientr, float ambientg, float ambientb){
131 static float qattenuation[]={0.0f};
136 GLfloat LightAmbient[]= { ambientr, ambientg, ambientb, 1.0f};
137 GLfloat LightDiffuse[]= { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
138 GLfloat LightPosition[]= { whichsource->location.x, whichsource->location.y, whichsource->location.z, 1.0f };
140 glLightfv(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, qattenuation);
141 glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
142 glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
143 glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);