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 FG_MATH_EXCEPTION_CLASH
38 #include <simgear/xgl/xgl.h>
42 #include <simgear/debug/logstream.hxx>
43 #include <simgear/math/sg_random.h>
44 #include <simgear/misc/fgpath.hxx>
46 #include <Objects/texload.h>
48 #include "globals.hxx"
49 #include "fg_props.hxx"
53 static GLuint splash_texid;
54 static GLubyte *splash_texbuf;
57 // Initialize the splash screen
58 void fgSplashInit ( void ) {
61 FG_LOG( FG_GENERAL, FG_INFO, "Initializing splash screen" );
63 xglGenTextures(1, &splash_texid);
64 xglBindTexture(GL_TEXTURE_2D, splash_texid);
65 #elif GL_EXT_texture_object
66 xglGenTexturesEXT(1, &splash_texid);
67 xglBindTextureEXT(GL_TEXTURE_2D, splash_texid);
72 xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
73 xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
74 xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
75 xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
77 // load in the texture data
78 int num = (int)(sg_random() * 4.0 + 1.0);
80 sprintf(num_str, "%d", num);
82 FGPath tpath( globals->get_fg_root() );
83 tpath.append( "Textures/Splash" );
84 tpath.concat( num_str );
85 tpath.concat( ".rgb" );
88 read_rgb_texture(tpath.c_str(), &width, &height)) == NULL )
91 FGPath fg_tpath = tpath;
92 fg_tpath.concat( ".gz" );
94 read_rgb_texture(fg_tpath.c_str(), &width, &height)) == NULL )
96 FG_LOG( FG_GENERAL, FG_ALERT,
97 "Error in loading splash screen texture " << tpath.str() );
102 xglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,
103 GL_UNSIGNED_BYTE, (GLvoid *)(splash_texbuf) );
107 // Update the splash screen with progress specified from 0.0 to 1.0
108 void fgSplashUpdate ( double progress ) {
109 int xmin, ymin, xmax, ymax;
113 if ( !fgGetInt("/sim/startup/xsize")
114 || !fgGetInt("/sim/startup/ysize") ) {
118 xmin = (fgGetInt("/sim/startup/xsize") - xsize) / 2;
121 ymin = (fgGetInt("/sim/startup/ysize") - ysize) / 2;
124 // first clear the screen;
125 xglClearColor(0.0, 0.0, 0.0, 1.0);
126 xglClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
129 xglMatrixMode(GL_PROJECTION);
132 gluOrtho2D(0, fgGetInt("/sim/startup/xsize"),
133 0, fgGetInt("/sim/startup/ysize"));
134 xglMatrixMode(GL_MODELVIEW);
138 xglDisable(GL_DEPTH_TEST);
139 xglDisable(GL_LIGHTING);
140 xglEnable(GL_TEXTURE_2D);
141 #ifdef GL_VERSION_1_1
142 xglBindTexture(GL_TEXTURE_2D, splash_texid);
143 #elif GL_EXT_texture_object
144 xglBindTextureEXT(GL_TEXTURE_2D, splash_texid);
148 xglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
150 xglBegin(GL_POLYGON);
151 xglTexCoord2f(0.0, 0.0); glVertex2f(xmin, ymin);
152 xglTexCoord2f(1.0, 0.0); glVertex2f(xmax, ymin);
153 xglTexCoord2f(1.0, 1.0); glVertex2f(xmax, ymax);
154 xglTexCoord2f(0.0, 1.0); glVertex2f(xmin, ymax);
159 xglEnable(GL_DEPTH_TEST);
160 xglEnable(GL_LIGHTING);
161 xglDisable(GL_TEXTURE_2D);
163 xglMatrixMode(GL_PROJECTION);
165 xglMatrixMode(GL_MODELVIEW);