]> git.mxchange.org Git - flightgear.git/blob - Time/light.hxx
polar3d.h renamed to polar3d.hxx
[flightgear.git] / Time / light.hxx
1 // light.hxx -- lighting routines
2 //
3 // Written by Curtis Olson, started April 1998.
4 //
5 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _LIGHT_HXX
25 #define _LIGHT_HXX
26
27
28 #ifndef __cplusplus                                                          
29 # error This library requires C++
30 #endif                                   
31
32
33 #ifdef HAVE_CONFIG_H
34 #  include <config.h>
35 #endif
36
37 #ifdef HAVE_WINDOWS_H
38 #  include <windows.h>
39 #endif
40
41 #include <GL/glut.h>
42 #include <XGL/xgl.h>
43
44 #include <Include/fg_types.h>
45 #include <Math/interpolater.hxx>
46
47
48 // Define a structure containing the global lighting parameters
49 class fgLIGHT {
50
51     // Lighting look up tables (based on sun angle with local horizon)
52     fgINTERPTABLE *ambient_tbl;
53     fgINTERPTABLE *diffuse_tbl;
54     fgINTERPTABLE *sky_tbl;
55
56 public:
57
58     ///////////////////////////////////////////////////////////
59     // position of the sun in various forms
60
61     // in geocentric coordinates
62     double sun_lon, sun_gc_lat;
63
64     // in cartesian coordiantes
65     fgPoint3d fg_sunpos;
66
67     // (in view coordinates)
68     GLfloat sun_vec[4];
69
70     // inverse (in view coordinates)
71     GLfloat sun_vec_inv[4];
72
73     // the angle between the sun and the local horizontal
74     double sun_angle;
75
76     ///////////////////////////////////////////////////////////
77     // Derived lighting values
78
79     // ambient component
80     GLfloat scene_ambient[3];
81
82     // diffuse component
83     GLfloat scene_diffuse[3];
84
85     // fog color
86     GLfloat fog_color[4];
87
88     // clear screen color
89     GLfloat sky_color[4];
90
91     // Constructor
92     fgLIGHT( void );
93
94     // initialize lighting tables
95     void Init( void );
96
97     // update lighting parameters based on current sun position
98     void Update( void);
99
100     // Destructor
101     ~fgLIGHT( void );
102 };
103
104
105 // Global shared light parameter structure
106 extern fgLIGHT cur_light_params;
107
108
109 // wrapper function for updating light parameters via the event scheduler
110 void fgLightUpdate ( void );
111
112
113 #endif // _LIGHT_HXX
114
115
116 // $Log$
117 // Revision 1.5  1998/07/08 14:48:39  curt
118 // polar3d.h renamed to polar3d.hxx
119 //
120 // Revision 1.4  1998/05/20 20:54:17  curt
121 // Converted fgLIGHT to a C++ class.
122 //
123 // Revision 1.3  1998/05/02 01:53:18  curt
124 // Fine tuning mktime() support because of varying behavior on different
125 // platforms.
126 //
127 // Revision 1.2  1998/04/24 00:52:31  curt
128 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
129 // Fog color fixes.
130 // Separated out lighting calcs into their own file.
131 //
132 // Revision 1.1  1998/04/22 13:24:06  curt
133 // C++ - ifiing the code a bit.
134 // Starting to reorginize some of the lighting calcs to use a table lookup.
135 //
136 //