]> git.mxchange.org Git - flightgear.git/blob - Main/splash.cxx
Converted to new logstream debugging facility. This allows release
[flightgear.git] / Main / splash.cxx
1 // splash.cxx -- draws the initial splash screen
2 //
3 // Written by Curtis Olson, started July 1998.  (With a little looking
4 // at Freidemann's panel code.) :-)
5 //
6 // Copyright (C) 1997  Michele F. America  - nomimarketing@mail.telepac.pt
7 //
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.
12 //
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.
17 //
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.
21 //
22 // $Id$
23 // (Log is kept at end of this file)
24
25
26 #ifdef HAVE_CONFIG_H
27 #  include <config.h>
28 #endif
29
30 #ifdef HAVE_WINDOWS_H          
31 #  include <windows.h>
32 #endif
33
34 #include <GL/glut.h>
35 #include <XGL/xgl.h>
36
37 #include <string.h>
38
39 #include <Debug/logstream.hxx>
40 #include <Main/options.hxx>
41 #include <Objects/texload.h>
42
43 #include "splash.hxx"
44
45
46 static GLuint splash_texid;
47 static GLubyte *splash_texbuf;
48
49
50 // Initialize the splash screen
51 void fgSplashInit ( void ) {
52     string tpath, fg_tpath;
53     int width, height;
54
55     FG_LOG( FG_GENERAL, FG_INFO, "Initializing splash screen" );
56 #ifdef GL_VERSION_1_1
57     xglGenTextures(1, &splash_texid);
58     xglBindTexture(GL_TEXTURE_2D, splash_texid);
59 #elif GL_EXT_texture_object
60     xglGenTexturesEXT(1, &splash_texid);
61     xglBindTextureEXT(GL_TEXTURE_2D, splash_texid);
62 #else
63 #  error port me
64 #endif
65
66     xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
67     xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);   
68     xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
69     xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
70
71     // load in the texture data
72     tpath = current_options.get_fg_root() + "/Textures/Splash2.rgb";
73
74     if ( (splash_texbuf = 
75           read_rgb_texture(tpath.c_str(), &width, &height)) == NULL )
76     {
77         // Try compressed
78         fg_tpath = tpath + ".gz";
79         if ( (splash_texbuf = 
80               read_rgb_texture(fg_tpath.c_str(), &width, &height)) == NULL )
81         {
82             FG_LOG( FG_GENERAL, FG_ALERT, 
83                     "Error in loading splash screen texture " << tpath );
84             exit(-1);
85         } 
86     } 
87
88     xglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, 
89                    GL_UNSIGNED_BYTE, (GLvoid *)(splash_texbuf) );
90 }
91
92
93 // Update the splash screen with progress specified from 0.0 to 1.0
94 void fgSplashUpdate ( double progress ) {
95     int xmin, ymin, xmax, ymax;
96     int xsize = 480;
97     int ysize = 380;
98
99     xmin = (640 - xsize) / 2;
100     xmax = xmin + xsize;
101
102     ymin = (480 - ysize) / 2;
103     ymax = ymin + ysize;
104
105     // first clear the screen;
106     xglClearColor(0.0, 0.0, 0.0, 1.0);
107     xglClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
108
109     // now draw the logo
110     xglMatrixMode(GL_PROJECTION);
111     xglPushMatrix();
112     xglLoadIdentity();
113     gluOrtho2D(0, 640, 0, 480);
114     xglMatrixMode(GL_MODELVIEW);
115     xglPushMatrix();
116     xglLoadIdentity();
117
118     xglDisable(GL_DEPTH_TEST);
119     xglDisable(GL_LIGHTING);
120     xglEnable(GL_TEXTURE_2D);
121 #ifdef GL_VERSION_1_1
122     xglBindTexture(GL_TEXTURE_2D, splash_texid);
123 #elif GL_EXT_texture_object
124     xglBindTextureEXT(GL_TEXTURE_2D, splash_texid);
125 #else
126 #  error port me
127 #endif
128     xglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
129
130     xglBegin(GL_POLYGON);
131     xglTexCoord2f(0.0, 0.0); glVertex2f(xmin, ymin);
132     xglTexCoord2f(1.0, 0.0); glVertex2f(xmax, ymin);
133     xglTexCoord2f(1.0, 1.0); glVertex2f(xmax, ymax);
134     xglTexCoord2f(0.0, 1.0); glVertex2f(xmin, ymax); 
135     xglEnd();
136
137     xglutSwapBuffers();
138
139     xglEnable(GL_DEPTH_TEST);
140     xglEnable(GL_LIGHTING);
141     xglDisable(GL_TEXTURE_2D);
142
143     xglMatrixMode(GL_PROJECTION);
144     xglPopMatrix();
145     xglMatrixMode(GL_MODELVIEW);
146     xglPopMatrix();
147 }
148
149
150 // $Log$
151 // Revision 1.7  1998/11/06 21:18:14  curt
152 // Converted to new logstream debugging facility.  This allows release
153 // builds with no messages at all (and no performance impact) by using
154 // the -DFG_NDEBUG flag.
155 //
156 // Revision 1.6  1998/10/17 01:34:25  curt
157 // C++ ifying ...
158 //
159 // Revision 1.5  1998/09/26 13:17:29  curt
160 // Clear screen to "black" before drawing splash screen.
161 //
162 // Revision 1.4  1998/08/27 17:02:08  curt
163 // Contributions from Bernie Bright <bbright@c031.aone.net.au>
164 // - use strings for fg_root and airport_id and added methods to return
165 //   them as strings,
166 // - inlined all access methods,
167 // - made the parsing functions private methods,
168 // - deleted some unused functions.
169 // - propogated some of these changes out a bit further.
170 //
171 // Revision 1.3  1998/08/25 16:59:10  curt
172 // Directory reshuffling.
173 //
174 // Revision 1.2  1998/07/13 21:01:40  curt
175 // Wrote access functions for current fgOPTIONS.
176 //
177 // Revision 1.1  1998/07/06 02:42:36  curt
178 // Initial revision.
179 //
180