]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/splash.cxx
Added FGScript.{cpp,h}
[flightgear.git] / src / Main / splash.cxx
index dea67dd6970806df348994b1da98b1ca8761603c..092a3d3714f933b811159d1758bf940545eae71e 100644 (file)
@@ -26,7 +26,7 @@
 #  include <config.h>
 #endif
 
-#ifdef FG_MATH_EXCEPTION_CLASH
+#ifdef SG_MATH_EXCEPTION_CLASH
 #  include <math.h>
 #endif
 
 #endif
 
 #include <GL/glut.h>
-#include <simgear/xgl.h>
+#include <GL/gl.h>
 
 #include <string.h>
 
-#include <simgear/logstream.hxx>
-#include <simgear/fg_random.h>
-#include <simgear/fgpath.hxx>
+#include <simgear/debug/logstream.hxx>
+#include <simgear/math/sg_random.h>
+#include <simgear/misc/sg_path.hxx>
 
-#include <Main/options.hxx>
 #include <Objects/texload.h>
 
+#include "globals.hxx"
+#include "fg_props.hxx"
 #include "splash.hxx"
-#include "views.hxx"
 
 
 static GLuint splash_texid;
@@ -58,28 +58,28 @@ static GLubyte *splash_texbuf;
 void fgSplashInit ( void ) {
     int width, height;
 
-    FG_LOG( FG_GENERAL, FG_INFO, "Initializing splash screen" );
+    SG_LOG( SG_GENERAL, SG_INFO, "Initializing splash screen" );
 #ifdef GL_VERSION_1_1
-    xglGenTextures(1, &splash_texid);
-    xglBindTexture(GL_TEXTURE_2D, splash_texid);
+    glGenTextures(1, &splash_texid);
+    glBindTexture(GL_TEXTURE_2D, splash_texid);
 #elif GL_EXT_texture_object
-    xglGenTexturesEXT(1, &splash_texid);
-    xglBindTextureEXT(GL_TEXTURE_2D, splash_texid);
+    glGenTexturesEXT(1, &splash_texid);
+    glBindTextureEXT(GL_TEXTURE_2D, splash_texid);
 #else
 #  error port me
 #endif
 
-    xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
-    xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);   
-    xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    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);
 
     // load in the texture data
-    int num = (int)(fg_random() * 4.0 + 1.0);
+    int num = (int)(sg_random() * 4.0 + 1.0);
     char num_str[256];
     sprintf(num_str, "%d", num);
 
-    FGPath tpath( current_options.get_fg_root() );
+    SGPath tpath( globals->get_fg_root() );
     tpath.append( "Textures/Splash" );
     tpath.concat( num_str );
     tpath.concat( ".rgb" );
@@ -88,18 +88,18 @@ void fgSplashInit ( void ) {
          read_rgb_texture(tpath.c_str(), &width, &height)) == NULL )
     {
        // Try compressed
-       FGPath fg_tpath = tpath;
+       SGPath fg_tpath = tpath;
        fg_tpath.concat( ".gz" );
        if ( (splash_texbuf = 
              read_rgb_texture(fg_tpath.c_str(), &width, &height)) == NULL )
        {
-           FG_LOG( FG_GENERAL, FG_ALERT, 
+           SG_LOG( SG_GENERAL, SG_ALERT, 
                    "Error in loading splash screen texture " << tpath.str() );
            exit(-1);
        } 
     } 
 
-    xglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, 
+    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, 
                   GL_UNSIGNED_BYTE, (GLvoid *)(splash_texbuf) );
 }
 
@@ -110,58 +110,60 @@ void fgSplashUpdate ( double progress ) {
     int xsize = 480;
     int ysize = 380;
 
-    if ( !current_view.get_winWidth() || !current_view.get_winHeight() ) {
+    if ( !fgGetInt("/sim/startup/xsize")
+        || !fgGetInt("/sim/startup/ysize") ) {
        return;
     }
 
-    xmin = (current_view.get_winWidth() - xsize) / 2;
+    xmin = (fgGetInt("/sim/startup/xsize") - xsize) / 2;
     xmax = xmin + xsize;
 
-    ymin = (current_view.get_winHeight() - ysize) / 2;
+    ymin = (fgGetInt("/sim/startup/ysize") - ysize) / 2;
     ymax = ymin + ysize;
 
     // first clear the screen;
-    xglClearColor(0.0, 0.0, 0.0, 1.0);
-    xglClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
+    glClearColor(0.0, 0.0, 0.0, 1.0);
+    glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
 
     // now draw the logo
-    xglMatrixMode(GL_PROJECTION);
-    xglPushMatrix();
-    xglLoadIdentity();
-    gluOrtho2D(0, current_view.get_winWidth(), 0, current_view.get_winHeight());
-    xglMatrixMode(GL_MODELVIEW);
-    xglPushMatrix();
-    xglLoadIdentity();
-
-    xglDisable(GL_DEPTH_TEST);
-    xglDisable(GL_LIGHTING);
-    xglEnable(GL_TEXTURE_2D);
+    glMatrixMode(GL_PROJECTION);
+    glPushMatrix();
+    glLoadIdentity();
+    gluOrtho2D(0, fgGetInt("/sim/startup/xsize"),
+              0, fgGetInt("/sim/startup/ysize"));
+    glMatrixMode(GL_MODELVIEW);
+    glPushMatrix();
+    glLoadIdentity();
+
+    glDisable(GL_DEPTH_TEST);
+    glDisable(GL_LIGHTING);
+    glEnable(GL_TEXTURE_2D);
 #ifdef GL_VERSION_1_1
-    xglBindTexture(GL_TEXTURE_2D, splash_texid);
+    glBindTexture(GL_TEXTURE_2D, splash_texid);
 #elif GL_EXT_texture_object
-    xglBindTextureEXT(GL_TEXTURE_2D, splash_texid);
+    glBindTextureEXT(GL_TEXTURE_2D, splash_texid);
 #else
 #  error port me
 #endif
-    xglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
+    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
 
-    xglBegin(GL_POLYGON);
-    xglTexCoord2f(0.0, 0.0); glVertex2f(xmin, ymin);
-    xglTexCoord2f(1.0, 0.0); glVertex2f(xmax, ymin);
-    xglTexCoord2f(1.0, 1.0); glVertex2f(xmax, ymax);
-    xglTexCoord2f(0.0, 1.0); glVertex2f(xmin, ymax); 
-    xglEnd();
+    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();
 
-    xglutSwapBuffers();
+    glutSwapBuffers();
 
-    xglEnable(GL_DEPTH_TEST);
-    xglEnable(GL_LIGHTING);
-    xglDisable(GL_TEXTURE_2D);
+    glEnable(GL_DEPTH_TEST);
+    glEnable(GL_LIGHTING);
+    glDisable(GL_TEXTURE_2D);
 
-    xglMatrixMode(GL_PROJECTION);
-    xglPopMatrix();
-    xglMatrixMode(GL_MODELVIEW);
-    xglPopMatrix();
+    glMatrixMode(GL_PROJECTION);
+    glPopMatrix();
+    glMatrixMode(GL_MODELVIEW);
+    glPopMatrix();
 }