]> git.mxchange.org Git - flightgear.git/blob - Main/splash.cxx
Directory reshuffling.
[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 <Aircraft/aircraft.h>
40 #include <Debug/fg_debug.h>
41 #include <Main/options.hxx>
42 #include <Objects/texload.h>
43
44 #include "splash.hxx"
45
46
47 static GLuint splash_texid;
48 static GLubyte *splash_texbuf;
49
50
51 // Initialize the splash screen
52 void fgSplashInit ( void ) {
53     char tpath[256], fg_tpath[256];
54     int width, height;
55
56     fgPrintf( FG_GENERAL, FG_INFO, "Initializing splash screen\n");
57 #ifdef GL_VERSION_1_1
58     xglGenTextures(1, &splash_texid);
59     xglBindTexture(GL_TEXTURE_2D, splash_texid);
60 #elif GL_EXT_texture_object
61     xglGenTexturesEXT(1, &splash_texid);
62     xglBindTextureEXT(GL_TEXTURE_2D, splash_texid);
63 #else
64 #  error port me
65 #endif
66
67     xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
68     xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);   
69     xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
70     xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
71
72     // load in the texture data
73     current_options.get_fg_root(tpath);
74     strcat(tpath, "/Textures/");
75     strcat(tpath, "Splash2.rgb");
76
77     if ( (splash_texbuf = read_rgb_texture(tpath, &width, &height)) == NULL ) {
78         // Try compressed
79         strcpy(fg_tpath, tpath);
80         strcat(fg_tpath, ".gz");
81         if ( (splash_texbuf = read_rgb_texture(fg_tpath, &width, &height)) 
82              == NULL ) {
83             fgPrintf( FG_GENERAL, FG_EXIT, 
84                       "Error in loading splash screen texture %s\n", tpath );
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     xglMatrixMode(GL_PROJECTION);
106     xglPushMatrix();
107     xglLoadIdentity();
108     gluOrtho2D(0, 640, 0, 480);
109     xglMatrixMode(GL_MODELVIEW);
110     xglPushMatrix();
111     xglLoadIdentity();
112
113     xglDisable(GL_DEPTH_TEST);
114     xglDisable(GL_LIGHTING);
115     xglEnable(GL_TEXTURE_2D);
116 #ifdef GL_VERSION_1_1
117     xglBindTexture(GL_TEXTURE_2D, splash_texid);
118 #elif GL_EXT_texture_object
119     xglBindTextureEXT(GL_TEXTURE_2D, splash_texid);
120 #else
121 #  error port me
122 #endif
123     xglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
124
125     xglBegin(GL_POLYGON);
126     xglTexCoord2f(0.0, 0.0); glVertex2f(xmin, ymin);
127     xglTexCoord2f(1.0, 0.0); glVertex2f(xmax, ymin);
128     xglTexCoord2f(1.0, 1.0); glVertex2f(xmax, ymax);
129     xglTexCoord2f(0.0, 1.0); glVertex2f(xmin, ymax); 
130     xglEnd();
131
132     xglutSwapBuffers();
133
134     xglEnable(GL_DEPTH_TEST);
135     xglEnable(GL_LIGHTING);
136     xglDisable(GL_TEXTURE_2D);
137
138     xglMatrixMode(GL_PROJECTION);
139     xglPopMatrix();
140     xglMatrixMode(GL_MODELVIEW);
141     xglPopMatrix();
142 }
143
144
145 // $Log$
146 // Revision 1.3  1998/08/25 16:59:10  curt
147 // Directory reshuffling.
148 //
149 // Revision 1.2  1998/07/13 21:01:40  curt
150 // Wrote access functions for current fgOPTIONS.
151 //
152 // Revision 1.1  1998/07/06 02:42:36  curt
153 // Initial revision.
154 //
155