]> git.mxchange.org Git - flightgear.git/blob - Scenery/scenery.c
e74ad2854bfc509b1ab1d731bec196363f64b999
[flightgear.git] / Scenery / scenery.c
1 /* -*- Mode: C++ -*-
2  *
3  * scenery.c -- data structures and routines for managing scenery.
4  *
5  * Written by Curtis Olson, started May 1997.
6  *
7  * Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  * $Id$
24  * (Log is kept at end of this file)
25  **************************************************************************/
26
27
28 #include <config.h>
29
30 #ifdef HAVE_WINDOWS_H
31 #  include <windows.h>
32 #endif
33
34 #include <GL/glut.h>
35 #include <XGL/xgl.h>
36
37 #include <stdio.h>
38 #include <string.h>
39
40 #include <Include/general.h>
41 #include <Main/fg_debug.h>
42 #include <Scenery/obj.h>
43 #include <Scenery/scenery.h>
44 #include <Scenery/texload.h>
45
46
47 /* Temporary hack until we get a better texture management system running */
48 GLint area_texture;
49
50
51 /* Shared structure to hold current scenery parameters */
52 struct fgSCENERY scenery;
53
54
55 /* Initialize the Scenery Management system */
56 int fgSceneryInit( void ) {
57     fgGENERAL *g;
58     char path[1024];
59     GLubyte *texbuf;
60     int width, height;
61
62     g = &general;
63
64     fgPrintf(FG_TERRAIN, FG_INFO, "Initializing scenery subsystem\n");
65
66     /* set the default terrain detail level */
67     // scenery.terrain_skip = 6;
68
69     /* temp: load in a demo texture */
70     path[0] = '\0';
71     strcat(path, g->root_dir);
72     strcat(path, "/Textures/");
73     strcat(path, "forest.rgb");
74
75     if ( (texbuf = read_rgb_texture(path, &width, &height)) == NULL ) {
76         fgPrintf( FG_GENERAL, FG_EXIT, "Error in loading textures!\n" );
77         return(0);
78     } 
79
80     xglTexImage2D(GL_TEXTURE_2D, 0, 3, height, width, 0,
81                   GL_RGB, GL_UNSIGNED_BYTE, texbuf);
82
83     return(1);
84 }
85
86
87 /* Tell the scenery manager where we are so it can load the proper data, and
88  * build the proper structures. */
89 void fgSceneryUpdate(double lon, double lat, double elev) {
90     fgGENERAL *g;
91     double max_radius;
92     char path[1024];
93
94     g = &general;
95
96     /* a hardcoded hack follows */
97
98     /* this routine should parse the file, and make calls back to the
99      * scenery management system to build the appropriate structures */
100     path[0] = '\0';
101     strcat(path, g->root_dir);
102     strcat(path, "/Scenery/");
103     strcat(path, "mesa-e.obj");
104
105     // fgPrintf(FG_TERRAIN, FG_DEBUG, "  Loading Scenery: %s\n", path);
106
107     // area_terrain = fgObjLoad(path, &scenery.center, &max_radius);
108 }
109
110
111 /* Render out the current scene */
112 void fgSceneryRender( void ) {
113 }
114
115
116 /* $Log$
117 /* Revision 1.38  1998/04/03 22:11:37  curt
118 /* Converting to Gnu autoconf system.
119 /*
120  * Revision 1.37  1998/03/23 21:23:05  curt
121  * Debugging output tweaks.
122  *
123  * Revision 1.36  1998/03/14 00:30:50  curt
124  * Beginning initial terrain texturing experiments.
125  *
126  * Revision 1.35  1998/01/31 00:43:26  curt
127  * Added MetroWorks patches from Carmen Volpe.
128  *
129  * Revision 1.34  1998/01/27 03:26:43  curt
130  * Playing with new fgPrintf command.
131  *
132  * Revision 1.33  1998/01/19 19:27:17  curt
133  * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
134  * This should simplify things tremendously.
135  *
136  * Revision 1.32  1998/01/19 18:40:37  curt
137  * Tons of little changes to clean up the code and to remove fatal errors
138  * when building with the c++ compiler.
139  *
140  * Revision 1.31  1998/01/13 00:23:11  curt
141  * Initial changes to support loading and management of scenery tiles.  Note,
142  * there's still a fair amount of work left to be done.
143  *
144  * Revision 1.30  1998/01/07 03:22:29  curt
145  * Moved astro stuff to .../Src/Astro/
146  *
147  * Revision 1.29  1997/12/30 20:47:52  curt
148  * Integrated new event manager with subsystem initializations.
149  *
150  * Revision 1.28  1997/12/15 23:55:02  curt
151  * Add xgl wrappers for debugging.
152  * Generate terrain normals on the fly.
153  *
154  * Revision 1.27  1997/12/12 21:41:30  curt
155  * More light/material property tweaking ... still a ways off.
156  *
157  * Revision 1.26  1997/12/12 19:52:58  curt
158  * Working on lightling and material properties.
159  *
160  * Revision 1.25  1997/12/10 22:37:51  curt
161  * Prepended "fg" on the name of all global structures that didn't have it yet.
162  * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
163  *
164  * Revision 1.24  1997/12/08 22:51:18  curt
165  * Enhanced to handle ccw and cw tri-stripe winding.  This is a temporary
166  * admission of defeat.  I will eventually go back and get all the stripes
167  * wound the same way (ccw).
168  *
169  * Revision 1.23  1997/11/25 19:25:37  curt
170  * Changes to integrate Durk's moon/sun code updates + clean up.
171  *
172  * Revision 1.22  1997/10/28 21:00:22  curt
173  * Changing to new terrain format.
174  *
175  * Revision 1.21  1997/10/25 03:24:24  curt
176  * Incorporated sun, moon, and star positioning code contributed by Durk Talsma.
177  *
178  * Revision 1.20  1997/10/25 03:18:27  curt
179  * Incorporated sun, moon, and planet position and rendering code contributed
180  * by Durk Talsma.
181  *
182  * Revision 1.19  1997/09/05 14:17:30  curt
183  * More tweaking with stars.
184  *
185  * Revision 1.18  1997/09/05 01:35:59  curt
186  * Working on getting stars right.
187  *
188  * Revision 1.17  1997/08/29 17:55:27  curt
189  * Worked on properly aligning the stars.
190  *
191  * Revision 1.16  1997/08/27 21:32:29  curt
192  * Restructured view calculation code.  Added stars.
193  *
194  * Revision 1.15  1997/08/27 03:30:32  curt
195  * Changed naming scheme of basic shared structures.
196  *
197  * Revision 1.14  1997/08/25 20:27:24  curt
198  * Merged in initial HUD and Joystick code.
199  *
200  * Revision 1.13  1997/08/22 21:34:41  curt
201  * Doing a bit of reorganizing and house cleaning.
202  *
203  * Revision 1.12  1997/08/19 23:55:08  curt
204  * Worked on better simulating real lighting.
205  *
206  * Revision 1.11  1997/08/13 20:24:22  curt
207  * Changed default detail level.
208  *
209  * Revision 1.10  1997/08/06 00:24:30  curt
210  * Working on correct real time sun lighting.
211  *
212  * Revision 1.9  1997/08/04 17:08:11  curt
213  * Testing cvs on IRIX 6.x
214  *
215  * Revision 1.8  1997/07/18 23:41:27  curt
216  * Tweaks for building with Cygnus Win32 compiler.
217  *
218  * Revision 1.7  1997/07/16 20:04:52  curt
219  * Minor tweaks to aid Win32 port.
220  *
221  * Revision 1.6  1997/07/14 16:26:05  curt
222  * Testing/playing -- placed objects randomly across the entire terrain.
223  *
224  * Revision 1.5  1997/07/11 03:23:19  curt
225  * Solved some scenery display/orientation problems.  Still have a positioning
226  * (or transformation?) problem.
227  *
228  * Revision 1.4  1997/07/11 01:30:03  curt
229  * More tweaking of terrian floor.
230  *
231  * Revision 1.3  1997/06/29 21:16:50  curt
232  * More twiddling with the Scenery Management system.
233  *
234  * Revision 1.2  1997/06/27 20:03:37  curt
235  * Working on Makefile structure.
236  *
237  * Revision 1.1  1997/06/27 02:26:30  curt
238  * Initial revision.
239  *
240  */