1998-07-06 02:42:36 +00:00
|
|
|
// splash.cxx -- draws the initial splash screen
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started July 1998. (With a little looking
|
|
|
|
// at Freidemann's panel code.) :-)
|
|
|
|
//
|
|
|
|
// Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2001-03-23 22:42:49 +00:00
|
|
|
#ifdef SG_MATH_EXCEPTION_CLASH
|
1999-05-08 02:33:13 +00:00
|
|
|
# include <math.h>
|
|
|
|
#endif
|
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
#ifdef HAVE_WINDOWS_H
|
1998-07-06 02:42:36 +00:00
|
|
|
# include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
#include <plib/pu.h>
|
2004-11-18 19:53:00 +00:00
|
|
|
#include <simgear/compiler.h>
|
|
|
|
|
|
|
|
#include SG_GLU_H
|
2004-03-31 21:10:32 +00:00
|
|
|
|
2000-02-16 23:01:03 +00:00
|
|
|
#include <simgear/debug/logstream.hxx>
|
2003-04-12 09:48:32 +00:00
|
|
|
#include <simgear/screen/texture.hxx>
|
2000-12-04 05:26:40 +00:00
|
|
|
#include <simgear/math/sg_random.h>
|
2001-03-25 14:20:12 +00:00
|
|
|
#include <simgear/misc/sg_path.hxx>
|
1998-07-06 02:42:36 +00:00
|
|
|
|
The following changes were made to flightgear-0.7.5 code to implement the follow
ing features:
a) ADA Flight model - ADA.cxx, ADA.hxx, flight.hxx
b) Fighter a/c HUD - flight.hxx, hud.hxx, hud.cxx, cockpit.cxx, hud_ladr.c
xx, hud_card.cxx
c) 3-window display - options.hxx, options.cxx, viewer.cxx
d) Moving objects (ship) - main.cxx
e) Patches - main.cxx
ADA.cxx, ADA.hxx
--------------------------
Interface to the external ADA flight dynamics package.
flight.hxx
----------
Included prototypes for accepting additional data fron the External flight
model for fighter aircraft HUD
Hud.hxx
-------
Included prototypes for accepting additional data for fighter HUD from Exernal F
light model.
Defined FIGHTER_HUD pre-processor directive to enable compilation of fighter hud
code.
hud.cxx, cockpit.cxx, hud_ladr.cxx, hud_card.cxx
---------------------------------------
Included code to initialise additional reticles/text for fighter HUD which is co
nditionally
compiled if FIGHTER_HUD is defined.
options.hxx
-----------
Added window_offset, and function to retrieve its value for 3 windows
options.cxx
-----------
Changed few options to suit ADA/CEF projection system/screens and checks for win
dow offset.
views.cxx
---------
Added code to retrieve view offset for window.
Main.cxx
--------
Added code to load and move an aircraft carrier.
Patch to enable clouds from command line until Curtis fixes it. By default cloud
s are disabled.
2000-10-19 19:46:13 +00:00
|
|
|
#include "globals.hxx"
|
2001-01-13 22:06:39 +00:00
|
|
|
#include "fg_props.hxx"
|
1998-07-06 02:42:36 +00:00
|
|
|
#include "splash.hxx"
|
2004-03-31 21:10:32 +00:00
|
|
|
#include "fg_os.hxx"
|
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
static const int fontsize = 19;
|
|
|
|
static const char fontname[] = "default.txf";
|
2005-05-06 15:48:48 +00:00
|
|
|
static const char *progress_text = 0;
|
1998-07-06 02:42:36 +00:00
|
|
|
|
|
|
|
|
2003-04-09 20:28:42 +00:00
|
|
|
static SGTexture splash;
|
2005-05-06 09:08:44 +00:00
|
|
|
static fntTexFont font;
|
|
|
|
static fntRenderer info;
|
1998-07-06 02:42:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Initialize the splash screen
|
2003-12-22 21:49:11 +00:00
|
|
|
void fgSplashInit ( const char *splash_texture ) {
|
2005-05-06 09:08:44 +00:00
|
|
|
fgRequestRedraw();
|
|
|
|
|
2005-05-04 21:28:42 +00:00
|
|
|
if (!fgGetBool("/sim/startup/splash-screen"))
|
|
|
|
return;
|
|
|
|
|
2001-03-24 06:03:11 +00:00
|
|
|
SG_LOG( SG_GENERAL, SG_INFO, "Initializing splash screen" );
|
1998-07-06 02:42:36 +00:00
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
|
|
|
|
SGPath fontpath;
|
|
|
|
char* envp = ::getenv("FG_FONTS");
|
|
|
|
if (envp != NULL) {
|
|
|
|
fontpath.set(envp);
|
|
|
|
} else {
|
|
|
|
fontpath.set(globals->get_fg_root());
|
|
|
|
fontpath.append("Fonts");
|
|
|
|
}
|
|
|
|
SGPath path(fontpath);
|
|
|
|
path.append(fontname);
|
|
|
|
|
|
|
|
font.load((char *)path.c_str());
|
|
|
|
|
|
|
|
info.setFont(&font);
|
|
|
|
info.setPointSize(fontsize);
|
|
|
|
|
|
|
|
|
2003-04-09 20:28:42 +00:00
|
|
|
splash.bind();
|
1998-07-06 02:42:36 +00:00
|
|
|
|
2001-03-25 14:20:12 +00:00
|
|
|
SGPath tpath( globals->get_fg_root() );
|
2003-12-22 21:59:43 +00:00
|
|
|
if (splash_texture == NULL || !strcmp(splash_texture, "")) {
|
2003-12-22 21:49:11 +00:00
|
|
|
// load in the texture data
|
|
|
|
int num = (int)(sg_random() * 5.0 + 1.0);
|
2003-12-22 21:59:43 +00:00
|
|
|
char num_str[5];
|
|
|
|
snprintf(num_str, 4, "%d", num);
|
2003-12-22 21:49:11 +00:00
|
|
|
|
|
|
|
tpath.append( "Textures/Splash" );
|
|
|
|
tpath.concat( num_str );
|
|
|
|
tpath.concat( ".rgb" );
|
|
|
|
} else
|
|
|
|
tpath.append( splash_texture );
|
1998-07-06 02:42:36 +00:00
|
|
|
|
2003-04-09 20:28:42 +00:00
|
|
|
splash.read_rgb_texture(tpath.c_str());
|
|
|
|
if (!splash.usable())
|
1998-08-27 17:01:55 +00:00
|
|
|
{
|
2005-05-06 09:08:44 +00:00
|
|
|
// Try compressed
|
|
|
|
SGPath fg_tpath = tpath;
|
|
|
|
fg_tpath.concat( ".gz" );
|
2003-04-09 20:28:42 +00:00
|
|
|
|
|
|
|
splash.read_rgb_texture(fg_tpath.c_str());
|
2005-05-06 09:08:44 +00:00
|
|
|
if ( !splash.usable() )
|
|
|
|
{
|
|
|
|
SG_LOG( SG_GENERAL, SG_ALERT,
|
|
|
|
"Error in loading splash screen texture " << tpath.str() );
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
1998-07-06 02:42:36 +00:00
|
|
|
|
2003-04-09 20:28:42 +00:00
|
|
|
splash.select();
|
1998-07-06 02:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
void fgSplashProgress ( const char *s )
|
|
|
|
{
|
2005-05-06 15:48:48 +00:00
|
|
|
progress_text = s;
|
2005-05-06 09:08:44 +00:00
|
|
|
fgRequestRedraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-04 21:28:42 +00:00
|
|
|
// Update the splash screen with alpha specified from 0.0 to 1.0
|
|
|
|
void fgSplashUpdate ( float alpha ) {
|
2005-05-06 09:08:44 +00:00
|
|
|
int screen_width = fgGetInt("/sim/startup/xsize", 0);
|
|
|
|
int screen_height = fgGetInt("/sim/startup/ysize", 0);
|
1998-07-06 02:42:36 +00:00
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
if (!screen_width || !screen_height)
|
|
|
|
return;
|
1999-06-28 18:19:26 +00:00
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
int size = screen_width < (screen_height - 5 * fontsize)
|
|
|
|
? screen_width : screen_height - 5 * fontsize;
|
|
|
|
if (size > 512)
|
|
|
|
size = 512;
|
1998-07-06 02:42:36 +00:00
|
|
|
|
2005-05-06 09:08:44 +00:00
|
|
|
int xmin, ymin, xmax, ymax;
|
|
|
|
xmin = (screen_width - size) / 2;
|
|
|
|
xmax = xmin + size;
|
|
|
|
|
|
|
|
ymin = (screen_height - size) / 2;
|
|
|
|
ymax = ymin + size;
|
1998-07-06 02:42:36 +00:00
|
|
|
|
2001-05-15 22:30:39 +00:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPushMatrix();
|
|
|
|
glLoadIdentity();
|
2005-05-06 09:08:44 +00:00
|
|
|
gluOrtho2D(0, screen_width, 0, screen_height);
|
2001-05-15 22:30:39 +00:00
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPushMatrix();
|
|
|
|
glLoadIdentity();
|
1998-07-06 02:42:36 +00:00
|
|
|
|
2001-05-15 22:30:39 +00:00
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
glDisable(GL_LIGHTING);
|
2002-11-17 01:21:13 +00:00
|
|
|
|
|
|
|
// draw the background
|
|
|
|
glColor4f( 0.0, 0.0, 0.0, alpha );
|
|
|
|
glBegin(GL_POLYGON);
|
|
|
|
glVertex2f(0.0, 0.0);
|
2005-05-06 09:08:44 +00:00
|
|
|
glVertex2f(screen_width, 0.0);
|
|
|
|
glVertex2f(screen_width, screen_height);
|
|
|
|
glVertex2f(0.0, screen_height);
|
2002-11-17 01:21:13 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
// now draw the logo
|
2005-05-06 09:08:44 +00:00
|
|
|
if (fgGetBool("/sim/startup/splash-screen", true)) {
|
2005-05-04 21:28:42 +00:00
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
splash.bind();
|
|
|
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
|
|
|
|
|
|
glColor4f( 1.0, 1.0, 1.0, alpha );
|
|
|
|
glBegin(GL_POLYGON);
|
|
|
|
glTexCoord2f(0.0, 0.0); glVertex2f(xmin, ymin);
|
|
|
|
glTexCoord2f(1.0, 0.0); glVertex2f(xmax, ymin);
|
|
|
|
glTexCoord2f(1.0, 1.0); glVertex2f(xmax, ymax);
|
2005-05-06 09:08:44 +00:00
|
|
|
glTexCoord2f(0.0, 1.0); glVertex2f(xmin, ymax);
|
2005-05-04 21:28:42 +00:00
|
|
|
glEnd();
|
|
|
|
}
|
1998-07-06 02:42:36 +00:00
|
|
|
|
2005-05-06 15:48:48 +00:00
|
|
|
if (progress_text && fgGetBool("/sim/startup/splash-progress", true)) {
|
2005-05-06 09:08:44 +00:00
|
|
|
glEnable(GL_ALPHA_TEST);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glAlphaFunc(GL_GREATER, 0.1f);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
float left, right, bot, top;
|
|
|
|
|
|
|
|
info.begin();
|
2005-05-06 15:48:48 +00:00
|
|
|
glColor4f(1.0, 0.9, 0.0, alpha);
|
|
|
|
font.getBBox(progress_text, fontsize, 0, &left, &right, &bot, &top);
|
2005-05-06 09:08:44 +00:00
|
|
|
info.start2f((screen_width - right) / 2.0, 10.0 - bot);
|
2005-05-06 15:48:48 +00:00
|
|
|
info.puts(progress_text);
|
2005-05-06 09:08:44 +00:00
|
|
|
|
|
|
|
const char *s = fgGetString("/sim/startup/splash-title", "");
|
|
|
|
font.getBBox(s, fontsize, 0, &left, &right, &bot, &top);
|
|
|
|
info.start2f((screen_width - right) / 2.0, screen_height - top - bot - 10.0);
|
|
|
|
info.puts(s);
|
|
|
|
info.end();
|
|
|
|
}
|
|
|
|
|
2001-05-15 22:30:39 +00:00
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glEnable(GL_LIGHTING);
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
1998-07-06 02:42:36 +00:00
|
|
|
|
2001-05-15 22:30:39 +00:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPopMatrix();
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPopMatrix();
|
1998-07-06 02:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|