- static float loadprogress,minprogress,maxprogress;
- static AbsoluteTime time = {0,0};
- static AbsoluteTime frametime = {0,0};
- AbsoluteTime currTime = UpTime ();
- double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
-
- if (0 > deltaTime) // if negative microseconds
- deltaTime /= -1000000.0;
- else // else milliseconds
- deltaTime /= 1000.0;
-
- multiplier=deltaTime;
- if(multiplier<.001)multiplier=.001;
- if(multiplier>10)multiplier=10;
- if(multiplier>.05){
- frametime = currTime; // reset for next time interval
-
- float size=1;
- glLoadIdentity();
- //Clear to black
- glClearColor(0,0,0,1);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-
- loadtime+=multiplier*4;
-
- loadprogress=loadtime;
- if(loadprogress>100)loadprogress=100;
-
- //loadprogress=abs(Random()%100);
-
- //Background
-
- glEnable(GL_TEXTURE_2D);
- glBindTexture( GL_TEXTURE_2D, loadscreentexture);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
- glDisable(GL_DEPTH_TEST); // Disables Depth Testing
- glDisable(GL_CULL_FACE);
- glDisable(GL_LIGHTING);
- glDepthMask(0);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glTranslatef(screenwidth/2,screenheight/2,0);
- glScalef((float)screenwidth/2,(float)screenheight/2,1);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_BLEND);
- glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
- //glColor4f(1,1,1,1);
- /*if(loadscreencolor==0)glColor4f(1,1,1,1);
- if(loadscreencolor==1)glColor4f(1,0,0,1);
- if(loadscreencolor==2)glColor4f(0,1,0,1);
- if(loadscreencolor==3)glColor4f(0,0,1,1);
- if(loadscreencolor==4)glColor4f(1,1,0,1);
- if(loadscreencolor==5)glColor4f(1,0,1,1);
- */
- glPushMatrix();
- //glScalef(.25,.25,.25);
- glBegin(GL_QUADS);
- glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
- glVertex3f(-1, -1, 0.0f);
- glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
- glVertex3f(1, -1, 0.0f);
- glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
- glVertex3f(1, 1, 0.0f);
- glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
- glVertex3f(-1, 1, 0.0f);
- glEnd();
- glPopMatrix();
- glEnable(GL_BLEND);
- glPushMatrix();
- //glScalef(.25,.25,.25);
- glBegin(GL_QUADS);
- glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
- glVertex3f(-1, -1, 0.0f);
- glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
- glVertex3f(1, -1, 0.0f);
- glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
- glVertex3f(1, 1, 0.0f);
- glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
- glVertex3f(-1, 1, 0.0f);
- glEnd();
- glPopMatrix();
- glDisable(GL_TEXTURE_2D);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glDisable(GL_BLEND);
- glDepthMask(1);
-
- glEnable(GL_TEXTURE_2D);
- glBindTexture( GL_TEXTURE_2D, loadscreentexture);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
- glDisable(GL_DEPTH_TEST); // Disables Depth Testing
- glDisable(GL_CULL_FACE);
- glDisable(GL_LIGHTING);
- glDepthMask(0);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glTranslatef(screenwidth/2,screenheight/2,0);
- glScalef((float)screenwidth/2*(1.5-(loadprogress)/200),(float)screenheight/2*(1.5-(loadprogress)/200),1);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE);
- glEnable(GL_BLEND);
- //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
- glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
- /*if(loadscreencolor==0)glColor4f(1,1,1,1);
- if(loadscreencolor==1)glColor4f(1,0,0,1);
- if(loadscreencolor==2)glColor4f(0,1,0,1);
- if(loadscreencolor==3)glColor4f(0,0,1,1);
- if(loadscreencolor==4)glColor4f(1,1,0,1);
- if(loadscreencolor==5)glColor4f(1,0,1,1);
- */
- glPushMatrix();
- //glScalef(.25,.25,.25);
- glBegin(GL_QUADS);
- glTexCoord2f(0+.5,0+.5);
- glVertex3f(-1, -1, 0.0f);
- glTexCoord2f(1+.5,0+.5);
- glVertex3f(1, -1, 0.0f);
- glTexCoord2f(1+.5,1+.5);
- glVertex3f(1, 1, 0.0f);
- glTexCoord2f(0+.5,1+.5);
- glVertex3f(-1, 1, 0.0f);
- glEnd();
- glPopMatrix();
- glDisable(GL_TEXTURE_2D);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glDisable(GL_BLEND);
- glDepthMask(1);
-
- glEnable(GL_TEXTURE_2D);
- glBindTexture( GL_TEXTURE_2D, loadscreentexture);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
- glDisable(GL_DEPTH_TEST); // Disables Depth Testing
- glDisable(GL_CULL_FACE);
- glDisable(GL_LIGHTING);
- glDepthMask(0);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glTranslatef(screenwidth/2,screenheight/2,0);
- glScalef((float)screenwidth/2*(100+loadprogress)/100,(float)screenheight/2*(100+loadprogress)/100,1);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE);
- glEnable(GL_BLEND);
- glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,.4);
- glPushMatrix();
- //glScalef(.25,.25,.25);
- glBegin(GL_QUADS);
- glTexCoord2f(0+.2,0+.8);
- glVertex3f(-1, -1, 0.0f);
- glTexCoord2f(1+.2,0+.8);
- glVertex3f(1, -1, 0.0f);
- glTexCoord2f(1+.2,1+.8);
- glVertex3f(1, 1, 0.0f);
- glTexCoord2f(0+.2,1+.8);
- glVertex3f(-1, 1, 0.0f);
- glEnd();
- glPopMatrix();
- glDisable(GL_TEXTURE_2D);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glDisable(GL_BLEND);
- glDepthMask(1);
-
- //Text
- /*
- glEnable(GL_TEXTURE_2D);
- static char string[256]="";
- sprintf (string, "LOADING... %d%",(int)loadprogress);
- glColor4f(1,1,1,.2);
- text.glPrint(280-280*loadprogress/100/2/4,125-125*loadprogress/100/2/4,string,1,1+loadprogress/100,640,480);
- glColor4f(1.2-loadprogress/100,1.2-loadprogress/100,1.2-loadprogress/100,1);
- text.glPrint(280,125,string,1,1,640,480);
- */
-
- if(flashamount>0){
- if(flashamount>1)flashamount=1;
- if(flashdelay<=0)flashamount-=multiplier;
- flashdelay--;
- if(flashamount<0)flashamount=0;
- glDisable(GL_DEPTH_TEST); // Disables Depth Testing
- glDisable(GL_CULL_FACE);
- glDisable(GL_LIGHTING);
- glDisable(GL_TEXTURE_2D);
- glDepthMask(0);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glScalef(screenwidth,screenheight,1);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- glColor4f(flashr,flashg,flashb,flashamount);
- glBegin(GL_QUADS);
- glVertex3f(0, 0, 0.0f);
- glVertex3f(256, 0, 0.0f);
- glVertex3f(256, 256, 0.0f);
- glVertex3f(0, 256, 0.0f);
- glEnd();
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glEnable(GL_DEPTH_TEST); // Enables Depth Testing
- glEnable(GL_CULL_FACE);
- glDisable(GL_BLEND);
- glDepthMask(1);
- }
-
- swap_gl_buffers();
- loadscreencolor=0;
- }
+ if (!visibleloading) {
+ return;
+ }
+
+ static float loadprogress;
+ static AbsoluteTime frametime = {0, 0};
+ AbsoluteTime currTime = UpTime ();
+ double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
+
+ if (0 > deltaTime) // if negative microseconds
+ deltaTime /= -1000000.0;
+ else // else milliseconds
+ deltaTime /= 1000.0;
+
+ multiplier = deltaTime;
+ if (multiplier < .001)
+ multiplier = .001;
+ if (multiplier > 10)
+ multiplier = 10;
+ if (multiplier > .05) {
+ frametime = currTime; // reset for next time interval
+
+ glLoadIdentity();
+ //Clear to black
+ glClearColor(0, 0, 0, 1);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+
+ loadtime += multiplier * 4;
+
+ loadprogress = loadtime;
+ if (loadprogress > 100)
+ loadprogress = 100;
+
+ //Background
+
+ glEnable(GL_TEXTURE_2D);
+ loadscreentexture.bind();
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_LIGHTING);
+ glDepthMask(0);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0, screenwidth, 0, screenheight, -100, 100);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+ glTranslatef(screenwidth / 2, screenheight / 2, 0);
+ glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_BLEND);
+ glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
+ glPushMatrix();
+ glBegin(GL_QUADS);
+ glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
+ glVertex3f(-1, -1, 0.0f);
+ glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
+ glVertex3f(1, -1, 0.0f);
+ glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
+ glVertex3f(1, 1, 0.0f);
+ glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
+ glVertex3f(-1, 1, 0.0f);
+ glEnd();
+ glPopMatrix();
+ glEnable(GL_BLEND);
+ glPushMatrix();
+ glBegin(GL_QUADS);
+ glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
+ glVertex3f(-1, -1, 0.0f);
+ glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
+ glVertex3f(1, -1, 0.0f);
+ glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
+ glVertex3f(1, 1, 0.0f);
+ glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
+ glVertex3f(-1, 1, 0.0f);
+ glEnd();
+ glPopMatrix();
+ glDisable(GL_TEXTURE_2D);
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glDisable(GL_BLEND);
+ glDepthMask(1);
+
+ glEnable(GL_TEXTURE_2D);
+ loadscreentexture.bind();
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_LIGHTING);
+ glDepthMask(0);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0, screenwidth, 0, screenheight, -100, 100);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+ glTranslatef(screenwidth / 2, screenheight / 2, 0);
+ glScalef((float)screenwidth / 2 * (1.5 - (loadprogress) / 200), (float)screenheight / 2 * (1.5 - (loadprogress) / 200), 1);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glEnable(GL_BLEND);
+ glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
+ glPushMatrix();
+ glBegin(GL_QUADS);
+ glTexCoord2f(0 + .5, 0 + .5);
+ glVertex3f(-1, -1, 0.0f);
+ glTexCoord2f(1 + .5, 0 + .5);
+ glVertex3f(1, -1, 0.0f);
+ glTexCoord2f(1 + .5, 1 + .5);
+ glVertex3f(1, 1, 0.0f);
+ glTexCoord2f(0 + .5, 1 + .5);
+ glVertex3f(-1, 1, 0.0f);
+ glEnd();
+ glPopMatrix();
+ glDisable(GL_TEXTURE_2D);
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glDisable(GL_BLEND);
+ glDepthMask(1);
+
+ glEnable(GL_TEXTURE_2D);
+ loadscreentexture.bind();
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_LIGHTING);
+ glDepthMask(0);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0, screenwidth, 0, screenheight, -100, 100);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+ glTranslatef(screenwidth / 2, screenheight / 2, 0);
+ glScalef((float)screenwidth / 2 * (100 + loadprogress) / 100, (float)screenheight / 2 * (100 + loadprogress) / 100, 1);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glEnable(GL_BLEND);
+ glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, .4);
+ glPushMatrix();
+ glBegin(GL_QUADS);
+ glTexCoord2f(0 + .2, 0 + .8);
+ glVertex3f(-1, -1, 0.0f);
+ glTexCoord2f(1 + .2, 0 + .8);
+ glVertex3f(1, -1, 0.0f);
+ glTexCoord2f(1 + .2, 1 + .8);
+ glVertex3f(1, 1, 0.0f);
+ glTexCoord2f(0 + .2, 1 + .8);
+ glVertex3f(-1, 1, 0.0f);
+ glEnd();
+ glPopMatrix();
+ glDisable(GL_TEXTURE_2D);
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glDisable(GL_BLEND);
+ glDepthMask(1);
+
+ //Text
+
+ if (flashamount > 0) {
+ if (flashamount > 1)
+ flashamount = 1;
+ if (flashdelay <= 0)
+ flashamount -= multiplier;
+ flashdelay--;
+ if (flashamount < 0)
+ flashamount = 0;
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_TEXTURE_2D);
+ glDepthMask(0);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0, screenwidth, 0, screenheight, -100, 100);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+ glScalef(screenwidth, screenheight, 1);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+ glColor4f(flashr, flashg, flashb, flashamount);
+ glBegin(GL_QUADS);
+ glVertex3f(0, 0, 0.0f);
+ glVertex3f(256, 0, 0.0f);
+ glVertex3f(256, 256, 0.0f);
+ glVertex3f(0, 256, 0.0f);
+ glEnd();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_CULL_FACE);
+ glDisable(GL_BLEND);
+ glDepthMask(1);
+ }
+
+ swap_gl_buffers();
+ }