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/math/sg_random.h>
43 #include <simgear/misc/sg_path.hxx>
45 #include <Objects/texload.h>
47 #include "globals.hxx"
48 #include "fg_props.hxx"
52 static GLuint splash_texid;
53 static GLubyte *splash_texbuf;
56 // Initialize the splash screen
57 void fgSplashInit ( void ) {
60 SG_LOG( SG_GENERAL, SG_INFO, "Initializing splash screen" );
62 glGenTextures(1, &splash_texid);
63 glBindTexture(GL_TEXTURE_2D, splash_texid);
64 #elif GL_EXT_texture_object
65 glGenTexturesEXT(1, &splash_texid);
66 glBindTextureEXT(GL_TEXTURE_2D, splash_texid);
71 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
72 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
73 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
74 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
76 // load in the texture data
77 int num = (int)(sg_random() * 4.0 + 1.0);
79 sprintf(num_str, "%d", num);
81 SGPath tpath( globals->get_fg_root() );
82 tpath.append( "Textures/Splash" );
83 tpath.concat( num_str );
84 tpath.concat( ".rgb" );
87 read_rgb_texture(tpath.c_str(), &width, &height)) == NULL )
90 SGPath fg_tpath = tpath;
91 fg_tpath.concat( ".gz" );
93 read_rgb_texture(fg_tpath.c_str(), &width, &height)) == NULL )
95 SG_LOG( SG_GENERAL, SG_ALERT,
96 "Error in loading splash screen texture " << tpath.str() );
101 glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,
102 GL_UNSIGNED_BYTE, (GLvoid *)(splash_texbuf) );
106 // Update the splash screen with progress specified from 0.0 to 1.0
107 void fgSplashUpdate ( double progress, float alpha ) {
108 int xmin, ymin, xmax, ymax;
112 if ( !fgGetInt("/sim/startup/xsize")
113 || !fgGetInt("/sim/startup/ysize") ) {
117 xmin = (fgGetInt("/sim/startup/xsize") - xsize) / 2;
120 ymin = (fgGetInt("/sim/startup/ysize") - ysize) / 2;
123 glMatrixMode(GL_PROJECTION);
126 gluOrtho2D(0, fgGetInt("/sim/startup/xsize"),
127 0, fgGetInt("/sim/startup/ysize"));
128 glMatrixMode(GL_MODELVIEW);
132 glDisable(GL_DEPTH_TEST);
133 glDisable(GL_LIGHTING);
135 // draw the background
136 glColor4f( 0.0, 0.0, 0.0, alpha );
138 glVertex2f(0.0, 0.0);
139 glVertex2f(fgGetInt("/sim/startup/xsize"), 0.0);
140 glVertex2f(fgGetInt("/sim/startup/xsize"), fgGetInt("/sim/startup/ysize"));
141 glVertex2f(0.0, fgGetInt("/sim/startup/ysize"));
145 glEnable(GL_TEXTURE_2D);
146 #ifdef GL_VERSION_1_1
147 glBindTexture(GL_TEXTURE_2D, splash_texid);
148 #elif GL_EXT_texture_object
149 glBindTextureEXT(GL_TEXTURE_2D, splash_texid);
153 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
155 glColor4f( 1.0, 1.0, 1.0, alpha );
157 glTexCoord2f(0.0, 0.0); glVertex2f(xmin, ymin);
158 glTexCoord2f(1.0, 0.0); glVertex2f(xmax, ymin);
159 glTexCoord2f(1.0, 1.0); glVertex2f(xmax, ymax);
160 glTexCoord2f(0.0, 1.0); glVertex2f(xmin, ymax);
165 glEnable(GL_DEPTH_TEST);
166 glEnable(GL_LIGHTING);
167 glDisable(GL_TEXTURE_2D);
169 glMatrixMode(GL_PROJECTION);
171 glMatrixMode(GL_MODELVIEW);