]> git.mxchange.org Git - flightgear.git/blob - Time/fg_time.hxx
45e37ee906d14a9597e14f3916c4d9d22d5d5c73
[flightgear.git] / Time / fg_time.hxx
1 //
2 // fg_time.hxx -- data structures and routines for managing time related stuff.
3 //
4 // Written by Curtis Olson, started August 1997.
5 //
6 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 // $Id$
23 // (Log is kept at end of this file)
24
25
26 #ifndef _FG_TIME_HXX
27 #define _FG_TIME_HXX
28
29
30 #ifndef __cplusplus                                                          
31 # error This library requires C++
32 #endif                                   
33
34
35 #ifdef HAVE_CONFIG_H
36 #  include <config.h>
37 #endif
38
39 #ifdef HAVE_WINDOWS_H
40 #  include <windows.h>
41 #endif
42
43 #include <GL/glut.h>
44 #include <time.h>
45
46 #include <Include/fg_types.h>
47 #include <Flight/flight.h>
48
49
50 // Define a structure containing global time parameters
51 struct fgTIME {
52     // the date/time in various forms
53     // Unix "calendar" time in seconds
54     time_t cur_time;
55
56     // Break down of GMT time
57     struct tm *gmt;
58
59     // Julian date
60     double jd;
61
62     // modified Julian date
63     double mjd;
64
65     // side real time at prime meridian
66     double gst;
67
68     // local side real time
69     double lst;
70
71     // the difference between the precise sidereal time algorithm
72     // result and the course result.  
73     // course + diff has good accuracy for the short term
74     double gst_diff;
75
76     // An offset in seconds from the true time.  Allows us to adjust
77     // the effective time of day.
78     long int warp;
79
80     // How much to change the value of warp each iteration.  Allows us
81     // to make time progress faster than normal.
82     long int warp_delta; 
83 };
84
85 extern struct fgTIME cur_time_params;
86
87
88 typedef struct fg_timestamp_t {
89     long seconds;
90     long millis;
91 } fg_timestamp;
92
93
94 // Portability wrap to get current time.
95 void timestamp(fg_timestamp *timestamp);
96
97
98 // Return duration in millis from first to last
99 long timediff(fg_timestamp *first, fg_timestamp *last);
100
101
102 // Return new timestamp given a time stamp and an interval to add in
103 void timesum(fg_timestamp *res, fg_timestamp *start, long millis);
104
105
106 // Initialize the time dependent variables
107 void fgTimeInit(struct fgTIME *t);
108
109
110 // Update the time dependent variables
111 void fgTimeUpdate(fgFLIGHT *f, struct fgTIME *t);
112
113
114 #endif // _FG_TIME_HXX
115
116
117 // $Log$
118 // Revision 1.1  1998/04/24 00:52:28  curt
119 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
120 // Fog color fixes.
121 // Separated out lighting calcs into their own file.
122 //
123 // Revision 1.20  1998/04/22 13:24:05  curt
124 // C++ - ifiing the code a bit.
125 // Starting to reorginize some of the lighting calcs to use a table lookup.
126 //
127 // Revision 1.19  1998/04/21 17:01:44  curt
128 // Fixed a problems where a pointer to a function was being passed around.  In
129 // one place this functions arguments were defined as ( void ) while in another
130 // place they were defined as ( int ).  The correct answer was ( int ).
131 //
132 // Prepairing for C++ integration.
133 //
134 // Revision 1.18  1998/04/08 23:35:40  curt
135 // Tweaks to Gnu automake/autoconf system.
136 //
137 // Revision 1.17  1998/04/03 22:12:56  curt
138 // Converting to Gnu autoconf system.
139 // Centralized time handling differences.
140 //
141 // Revision 1.16  1998/02/07 15:29:47  curt
142 // Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
143 // <chotchkiss@namg.us.anritsu.com>
144 //
145 // Revision 1.15  1998/01/27 00:48:06  curt
146 // Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
147 // system and commandline/config file processing code.
148 //
149 // Revision 1.14  1998/01/22 02:59:43  curt
150 // Changed #ifdef FILE_H to #ifdef _FILE_H
151 //
152 // Revision 1.13  1998/01/19 19:27:20  curt
153 // Merged in make system changes from Bob Kuehne <rpk@sgi.com>
154 // This should simplify things tremendously.
155 //
156 // Revision 1.12  1998/01/05 18:44:37  curt
157 // Add an option to advance/decrease time from keyboard.
158 //
159 // Revision 1.11  1997/12/19 23:35:07  curt
160 // Lot's of tweaking with sky rendering and lighting.
161 //
162 // Revision 1.10  1997/12/15 23:55:07  curt
163 // Add xgl wrappers for debugging.
164 // Generate terrain normals on the fly.
165 //
166 // Revision 1.9  1997/12/10 22:37:55  curt
167 // Prepended "fg" on the name of all global structures that didn't have it yet.
168 // i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
169 //
170 // Revision 1.8  1997/12/09 04:25:38  curt
171 // Working on adding a global lighting params structure.
172 //
173 // Revision 1.7  1997/11/25 19:25:41  curt
174 // Changes to integrate Durk's moon/sun code updates + clean up.
175 //
176 // Revision 1.6  1997/09/20 03:34:35  curt
177 // Still trying to get those durned stars aligned properly.
178 //
179 // Revision 1.5  1997/09/16 15:50:31  curt
180 // Working on star alignment and time issues.
181 //
182 // Revision 1.4  1997/09/13 02:00:08  curt
183 // Mostly working on stars and generating sidereal time for accurate star
184 // placement.
185 //
186 // Revision 1.3  1997/09/04 02:17:39  curt
187 // Shufflin' stuff.
188 //
189 // Revision 1.2  1997/08/27 03:30:36  curt
190 // Changed naming scheme of basic shared structures.
191 //
192 // Revision 1.1  1997/08/13 21:56:00  curt
193 // Initial revision.
194 //