]> icculus.org git repositories - taylor/freespace2.git/blob - include/starfield.h
rendering functions mostly done; more complete shader setup
[taylor/freespace2.git] / include / starfield.h
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell 
5  * or otherwise commercially exploit the source or things you created based on
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/Starfield/StarField.h $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * Code to handle and draw starfields, background space image bitmaps, floating
16  * debris, etc.
17  *
18  * $Log$
19  * Revision 1.3  2003/05/25 02:30:42  taylor
20  * Freespace 1 support
21  *
22  * Revision 1.2  2002/06/09 04:41:15  relnev
23  * added copyright header
24  *
25  * Revision 1.1.1.1  2002/05/03 03:28:12  root
26  * Initial import.
27  *
28  * 
29  * 11    7/21/99 8:10p Dave
30  * First run of supernova effect.
31  * 
32  * 10    6/03/99 6:37p Dave
33  * More TNT fun. Made perspective bitmaps more flexible.
34  * 
35  * 9     5/09/99 6:00p Dave
36  * Lots of cool new effects. E3 build tweaks.
37  * 
38  * 8     5/07/99 1:59p Johnson
39  * Tweaked background bitmaps a bit.
40  * 
41  * 7     4/23/99 5:53p Dave
42  * Started putting in new pof nebula support into Fred.
43  * 
44  * 6     4/07/99 6:22p Dave
45  * Fred and Freespace support for multiple background bitmaps and suns.
46  * Fixed link errors on all subprojects. Moved encrypt_init() to
47  * cfile_init() and lcl_init(), since its safe to call twice.
48  * 
49  * 5     3/31/99 8:24p Dave
50  * Beefed up all kinds of stuff, incluging beam weapons, nebula effects
51  * and background nebulae. Added per-ship non-dimming pixel colors.
52  * 
53  * 4     11/14/98 5:33p Dave
54  * Lots of nebula work. Put in ship contrails.
55  * 
56  * 3     11/05/98 5:55p Dave
57  * Big pass at reducing #includes
58  * 
59  * 2     10/07/98 10:54a Dave
60  * Initial checkin.
61  * 
62  * 1     10/07/98 10:51a Dave
63  * 
64  * 21    4/11/98 6:53p John
65  * Added first rev of subspace effect.
66  * 
67  * 20    4/07/98 4:17p John
68  * Made Fred be able to move suns.  Made suns actually affect the lighting
69  * in the game.
70  * 
71  * 19    3/21/98 7:36p Lawrance
72  * Move jump nodes to own lib.
73  * 
74  * 18    3/19/98 12:29p Lawrance
75  * Fix jumpnode targeting bug on the target monitor
76  * 
77  * 17    3/15/98 3:41p Allender
78  * new sexpression to gauge whether a ship warped out in proximity of jump
79  * node
80  * 
81  * 16    3/11/98 5:33p Lawrance
82  * Support rendering and targeting of jump nodes
83  * 
84  * 15    3/10/98 4:26p Hoffoss
85  * Changed jump node structure to include a name.  Position is now taken
86  * from the object (each jump node has an associated object now).
87  * 
88  * 14    3/06/98 5:30p Hoffoss
89  * Added jump node rendering code to FreeSpace.
90  * 
91  * 13    2/26/98 10:08p Hoffoss
92  * Rewrote state saving and restoring to fix bugs and simplify the code.
93  * 
94  * 12    2/06/98 3:08p Mike
95  * More asteroid stuff, including resolving conflicts between the two
96  * asteroid_field structs!
97  * 
98  * 11    1/18/98 4:24p John
99  * Detect when view camera "cuts" and tell the star code about it so it
100  * won't blur stars and debris between the last frame and this frame.
101  * 
102  * 10    8/25/97 5:56p Hoffoss
103  * Added multiple asteroid field support, loading and saving of asteroid
104  * fields, and ship score field to Fred.
105  * 
106  * 9     8/05/97 10:18a Lawrance
107  * my_rand() being used temporarily instead of rand()
108  * 
109  * 8     2/17/97 3:06p Hoffoss
110  * Changed header description.
111  * 
112  * 7     2/14/97 3:29p Hoffoss
113  * Added header for MSDEV to fill in.
114  *
115  * $NoKeywords: $
116  */
117
118 #ifndef _STARFIELD_H
119 #define _STARFIELD_H
120
121 #include "parselo.h"
122 #include "cfile.h"
123
124 #define MAX_STARFIELD_BITMAP_LISTS      1
125 #define MAX_STARFIELD_BITMAPS                   60
126 #define MAX_ASTEROID_FIELDS                     4
127
128 // nice low polygon background
129 #define BACKGROUND_MODEL_FILENAME                                       "spherec.pof"
130
131 // global info (not individual instances)
132 typedef struct starfield_bitmap {
133         char filename[MAX_FILENAME_LEN+1];                              // bitmap filename
134         char glow_filename[MAX_FILENAME_LEN+1];         // only for suns        
135         int bitmap;                                                                                             // bitmap handle
136         int glow_bitmap;                                                                                // only for suns
137         int xparent;    
138         float r, g, b, i;                                                                               // only for suns
139 } starfield_bitmap;
140
141 // starfield bitmap instance
142 typedef struct starfield_bitmap_instance {
143         char filename[MAX_FILENAME_LEN+1];                              // used to match up into the starfield_bitmap array     
144         float scale_x, scale_y;                                                         // x and y scale
145         int div_x, div_y;                                                                               // # of x and y divisions
146         angles ang;                                                                                             // angles from fred
147 #ifdef MAKE_FS1
148         matrix m;                       // straight matrix instead of angles to matrix
149         int sun_light;          // FIXME: not sure what this is supposed to do
150         float rot;                      // rotation rate - always 0?
151 #endif
152 } starfield_bitmap_instance;
153
154 // background bitmaps
155 extern starfield_bitmap Starfield_bitmaps[MAX_STARFIELD_BITMAPS];
156 extern starfield_bitmap_instance Starfield_bitmap_instance[MAX_STARFIELD_BITMAPS];
157 extern int Num_starfield_bitmaps;
158
159 // sun bitmaps and sun glow bitmaps
160 extern starfield_bitmap Sun_bitmaps[MAX_STARFIELD_BITMAPS];
161 extern starfield_bitmap_instance Suns[MAX_STARFIELD_BITMAPS];
162 extern int Num_suns;
163
164 extern const int MAX_STARS;
165 extern int Num_stars;
166
167 // call on game startup
168 void stars_init();
169
170 // call this in game_post_level_init() so we know whether we're running in full nebula mode or not
171 void stars_level_init();
172
173 // This *must* be called to initialize the lighting.
174 // You can turn off all the stars and suns and nebulas, though.
175 void stars_draw(int show_stars, int show_suns, int show_nebulas, int show_subspace);
176 // void calculate_bitmap_matrix(starfield_bitmaps *bm, vector *v);
177 // void calculate_bitmap_points(starfield_bitmaps *bm, float bank = 0.0f);
178
179 // draw the corresponding glow for sun_n
180 void stars_draw_sun_glow(int sun_n);
181
182 // Call when the viewer camera "cuts" so stars and debris
183 // don't draw incorrect blurs between last frame and this frame.
184 void stars_camera_cut();
185
186 // call this to set a specific model as the background model
187 void stars_set_background_model(const char *model_name, const char *texture_name);
188
189 // lookup a starfield bitmap, return index or -1 on fail
190 int stars_find_bitmap(const char *name);
191
192 // lookup a sun by bitmap filename, return index or -1 on fail
193 int stars_find_sun(const char *name);
194
195 // get the world coords of the sun pos on the unit sphere.
196 void stars_get_sun_pos(int sun_n, vector *pos);
197
198 #endif
199