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
|
|
|
|
|
1998-07-06 02:42:36 +00:00
|
|
|
#ifdef HAVE_WINDOWS_H
|
|
|
|
# include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <GL/glut.h>
|
2001-05-15 22:30:39 +00:00
|
|
|
#include <GL/gl.h>
|
1998-07-06 02:42:36 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2000-02-16 23:01:03 +00:00
|
|
|
#include <simgear/debug/logstream.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>
|
2000-02-15 03:30:01 +00:00
|
|
|
|
1999-05-13 02:10:52 +00:00
|
|
|
#include <Objects/texload.h>
|
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"
|
|
|
|
|
|
|
|
|
|
|
|
static GLuint splash_texid;
|
|
|
|
static GLubyte *splash_texbuf;
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize the splash screen
|
|
|
|
void fgSplashInit ( void ) {
|
|
|
|
int width, height;
|
|
|
|
|
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
|
|
|
#ifdef GL_VERSION_1_1
|
2001-05-15 22:30:39 +00:00
|
|
|
glGenTextures(1, &splash_texid);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, splash_texid);
|
1998-07-06 02:42:36 +00:00
|
|
|
#elif GL_EXT_texture_object
|
2001-05-15 22:30:39 +00:00
|
|
|
glGenTexturesEXT(1, &splash_texid);
|
|
|
|
glBindTextureEXT(GL_TEXTURE_2D, splash_texid);
|
1998-07-06 02:42:36 +00:00
|
|
|
#else
|
|
|
|
# error port me
|
|
|
|
#endif
|
|
|
|
|
2001-05-15 22:30:39 +00:00
|
|
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
|
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
|
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
|
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
1998-07-06 02:42:36 +00:00
|
|
|
|
|
|
|
// load in the texture data
|
2000-12-04 05:26:40 +00:00
|
|
|
int num = (int)(sg_random() * 4.0 + 1.0);
|
1999-03-08 21:56:37 +00:00
|
|
|
char num_str[256];
|
|
|
|
sprintf(num_str, "%d", num);
|
1999-04-27 19:27:45 +00:00
|
|
|
|
2001-03-25 14:20:12 +00:00
|
|
|
SGPath tpath( globals->get_fg_root() );
|
1999-04-27 19:27:45 +00:00
|
|
|
tpath.append( "Textures/Splash" );
|
|
|
|
tpath.concat( num_str );
|
|
|
|
tpath.concat( ".rgb" );
|
1998-07-06 02:42:36 +00:00
|
|
|
|
1998-08-27 17:01:55 +00:00
|
|
|
if ( (splash_texbuf =
|
|
|
|
read_rgb_texture(tpath.c_str(), &width, &height)) == NULL )
|
|
|
|
{
|
1998-07-06 02:42:36 +00:00
|
|
|
// Try compressed
|
2001-03-25 14:20:12 +00:00
|
|
|
SGPath fg_tpath = tpath;
|
1999-04-27 19:27:45 +00:00
|
|
|
fg_tpath.concat( ".gz" );
|
1998-08-27 17:01:55 +00:00
|
|
|
if ( (splash_texbuf =
|
|
|
|
read_rgb_texture(fg_tpath.c_str(), &width, &height)) == NULL )
|
|
|
|
{
|
2001-03-24 06:03:11 +00:00
|
|
|
SG_LOG( SG_GENERAL, SG_ALERT,
|
1999-04-27 19:27:45 +00:00
|
|
|
"Error in loading splash screen texture " << tpath.str() );
|
1998-11-06 21:17:31 +00:00
|
|
|
exit(-1);
|
1998-07-06 02:42:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-15 22:30:39 +00:00
|
|
|
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,
|
1998-07-06 02:42:36 +00:00
|
|
|
GL_UNSIGNED_BYTE, (GLvoid *)(splash_texbuf) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update the splash screen with progress specified from 0.0 to 1.0
|
|
|
|
void fgSplashUpdate ( double progress ) {
|
|
|
|
int xmin, ymin, xmax, ymax;
|
|
|
|
int xsize = 480;
|
|
|
|
int ysize = 380;
|
|
|
|
|
2001-01-13 22:06:39 +00:00
|
|
|
if ( !fgGetInt("/sim/startup/xsize")
|
|
|
|
|| !fgGetInt("/sim/startup/ysize") ) {
|
1999-06-28 18:19:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-01-13 22:06:39 +00:00
|
|
|
xmin = (fgGetInt("/sim/startup/xsize") - xsize) / 2;
|
1998-07-06 02:42:36 +00:00
|
|
|
xmax = xmin + xsize;
|
|
|
|
|
2001-01-13 22:06:39 +00:00
|
|
|
ymin = (fgGetInt("/sim/startup/ysize") - ysize) / 2;
|
1998-07-06 02:42:36 +00:00
|
|
|
ymax = ymin + ysize;
|
|
|
|
|
1998-09-26 13:17:29 +00:00
|
|
|
// first clear the screen;
|
2001-05-15 22:30:39 +00:00
|
|
|
glClearColor(0.0, 0.0, 0.0, 1.0);
|
|
|
|
glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
|
1998-09-26 13:17:29 +00:00
|
|
|
|
|
|
|
// now draw the logo
|
2001-05-15 22:30:39 +00:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPushMatrix();
|
|
|
|
glLoadIdentity();
|
2001-01-13 22:06:39 +00:00
|
|
|
gluOrtho2D(0, fgGetInt("/sim/startup/xsize"),
|
|
|
|
0, fgGetInt("/sim/startup/ysize"));
|
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);
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
1998-07-06 02:42:36 +00:00
|
|
|
#ifdef GL_VERSION_1_1
|
2001-05-15 22:30:39 +00:00
|
|
|
glBindTexture(GL_TEXTURE_2D, splash_texid);
|
1998-07-06 02:42:36 +00:00
|
|
|
#elif GL_EXT_texture_object
|
2001-05-15 22:30:39 +00:00
|
|
|
glBindTextureEXT(GL_TEXTURE_2D, splash_texid);
|
1998-07-06 02:42:36 +00:00
|
|
|
#else
|
|
|
|
# error port me
|
|
|
|
#endif
|
2001-05-15 22:30:39 +00:00
|
|
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
1998-07-06 02:42:36 +00:00
|
|
|
|
2001-05-15 22:30:39 +00:00
|
|
|
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);
|
|
|
|
glTexCoord2f(0.0, 1.0); glVertex2f(xmin, ymax);
|
|
|
|
glEnd();
|
1998-07-06 02:42:36 +00:00
|
|
|
|
2001-05-15 22:30:39 +00:00
|
|
|
glutSwapBuffers();
|
1998-07-06 02:42:36 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|