1 // splash.cxx -- draws the initial splash screen
3 // Written by Curtis Olson, started July 1998. (With a little looking
4 // at Freidemann's panel code.) :-)
6 // Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt
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.
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.
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.
29 #ifdef SG_MATH_EXCEPTION_CLASH
41 #include <simgear/debug/logstream.hxx>
42 #include <simgear/screen/texture.hxx>
43 #include <simgear/math/sg_random.h>
44 #include <simgear/misc/sg_path.hxx>
46 #include "globals.hxx"
47 #include "fg_props.hxx"
53 static SGTexture splash;
56 // Initialize the splash screen
57 void fgSplashInit ( const char *splash_texture ) {
58 SG_LOG( SG_GENERAL, SG_INFO, "Initializing splash screen" );
62 SGPath tpath( globals->get_fg_root() );
63 if (splash_texture == NULL || !strcmp(splash_texture, "")) {
64 // load in the texture data
65 int num = (int)(sg_random() * 5.0 + 1.0);
67 snprintf(num_str, 4, "%d", num);
69 tpath.append( "Textures/Splash" );
70 tpath.concat( num_str );
71 tpath.concat( ".rgb" );
73 tpath.append( splash_texture );
75 splash.read_rgb_texture(tpath.c_str());
79 SGPath fg_tpath = tpath;
80 fg_tpath.concat( ".gz" );
82 splash.read_rgb_texture(fg_tpath.c_str());
83 if ( !splash.usable() )
85 SG_LOG( SG_GENERAL, SG_ALERT,
86 "Error in loading splash screen texture " << tpath.str() );
95 // Update the splash screen with progress specified from 0.0 to 1.0
96 void fgSplashUpdate ( double progress, float alpha ) {
97 int xmin, ymin, xmax, ymax;
101 if ( !fgGetInt("/sim/startup/xsize")
102 || !fgGetInt("/sim/startup/ysize") ) {
106 xmin = (fgGetInt("/sim/startup/xsize") - xsize) / 2;
109 ymin = (fgGetInt("/sim/startup/ysize") - ysize) / 2;
112 glMatrixMode(GL_PROJECTION);
115 gluOrtho2D(0, fgGetInt("/sim/startup/xsize"),
116 0, fgGetInt("/sim/startup/ysize"));
117 glMatrixMode(GL_MODELVIEW);
121 glDisable(GL_DEPTH_TEST);
122 glDisable(GL_LIGHTING);
124 // draw the background
125 glColor4f( 0.0, 0.0, 0.0, alpha );
127 glVertex2f(0.0, 0.0);
128 glVertex2f(fgGetInt("/sim/startup/xsize"), 0.0);
129 glVertex2f(fgGetInt("/sim/startup/xsize"), fgGetInt("/sim/startup/ysize"));
130 glVertex2f(0.0, fgGetInt("/sim/startup/ysize"));
134 glEnable(GL_TEXTURE_2D);
136 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
138 glColor4f( 1.0, 1.0, 1.0, alpha );
140 glTexCoord2f(0.0, 0.0); glVertex2f(xmin, ymin);
141 glTexCoord2f(1.0, 0.0); glVertex2f(xmax, ymin);
142 glTexCoord2f(1.0, 1.0); glVertex2f(xmax, ymax);
143 glTexCoord2f(0.0, 1.0); glVertex2f(xmin, ymax);
146 glEnable(GL_DEPTH_TEST);
147 glEnable(GL_LIGHTING);
148 glDisable(GL_TEXTURE_2D);
150 glMatrixMode(GL_PROJECTION);
152 glMatrixMode(GL_MODELVIEW);