- 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;
- }
-}
-
-void Game::FadeLoadingScreen(float howmuch)
-{
- static float loadprogress,minprogress,maxprogress;
-
- float size=1;
- glLoadIdentity();
- //Clear to black
- glClearColor(0,0,0,1);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- loadprogress=howmuch;
-
- //loadprogress=abs(Random()%100);
-
- //Background
-
- //glEnable(GL_TEXTURE_2D);
- glDisable(GL_TEXTURE_2D);
- //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- 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,0,0,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,0);
- glVertex3f(-1, -1, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(1, -1, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(1, 1, 0.0f);
- glTexCoord2f(0,1);
- 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);
- */
- swap_gl_buffers();
- loadscreencolor=0;
-}
-
-
-void Game::InitGame()
-{
-#if PLATFORM_MACOSX
- ProcessSerialNumber PSN;
- ProcessInfoRec pinfo;
- FSSpec pspec;
- OSStatus err;
- /* set up process serial number */
- PSN.highLongOfPSN = 0;
- PSN.lowLongOfPSN = kCurrentProcess;
- /* set up info block */
- pinfo.processInfoLength = sizeof(pinfo);
- pinfo.processName = NULL;
- pinfo.processAppSpec = &pspec;
- /* grab the vrefnum and directory */
- err = GetProcessInformation(&PSN, &pinfo);
- if (err == noErr) {
- vRefNum = pspec.vRefNum;
- dirID = pspec.parID;
- }
-#endif
-
- LOGFUNC;
-
- autocam=0;
-
- int i,j;
-
- numchallengelevels=14;
-
- /*char tempstring[256];
- sprintf (tempstring, "%s", registrationname);
- long num1;
- long num2;
- long num3;
- long num4;
- long long longnum;
- longnum = MD5_string ( tempstring);
- //longnum = 1111111111111111;
- num1 = longnum/100000000;
- num2 = longnum%100000000;
- sprintf (tempstring, "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
- */
-
- FILE *tfile;
-
- accountactive=-1;
-
- sprintf (mapname, ":Data:Users");
- tfile=fopen( ConvertFileName(mapname), "rb" );
- if(tfile)
- {
- funpackf(tfile, "Bi", &numaccounts);
- funpackf(tfile, "Bi", &accountactive);
- if(numaccounts>0)
- {
- for(i=0;i<numaccounts;i++)
- {
- funpackf(tfile, "Bf", &accountcampaigntime[i]);
- funpackf(tfile, "Bf", &accountcampaignscore[i]);
- funpackf(tfile, "Bf", &accountcampaignfasttime[i]);
- funpackf(tfile, "Bf", &accountcampaignhighscore[i]);
- funpackf(tfile, "Bi", &accountdifficulty[i]);
- funpackf(tfile, "Bi", &accountprogress[i]);
- funpackf(tfile, "Bi", &accountcampaignchoicesmade[i]);
- for(j=0;j<accountcampaignchoicesmade[i];j++)
- {
- funpackf(tfile, "Bi", &accountcampaignchoices[i][j]);
- if (accountcampaignchoices[i][j] >= 10)
- {
- accountcampaignchoices[i][j] = 0;
- }
- }
- funpackf(tfile, "Bf", &accountpoints[i]);
- for(j=0;j<50;j++)
- {
- funpackf(tfile, "Bf", &accounthighscore[i][j]);
- funpackf(tfile, "Bf", &accountfasttime[i][j]);
- }
- for(j=0;j<60;j++)
- {
- funpackf(tfile, "Bb", &accountunlocked[i][j]);
- }
- int temp;
- funpackf(tfile, "Bi", &temp);
- if(temp>0)
- {
- for(j=0;j<temp;j++)
- {
- funpackf(tfile, "Bb", &accountname[i][j]);
- }
- }
- }
- }
-
- fclose(tfile);
- }
-
- tintr=1;
- tintg=1;
- tintb=1;
-
- whichjointstartarray[0]=righthip;
- whichjointendarray[0]=rightfoot;
-
- whichjointstartarray[1]=righthip;
- whichjointendarray[1]=rightankle;
-
- whichjointstartarray[2]=righthip;
- whichjointendarray[2]=rightknee;
-
- whichjointstartarray[3]=rightknee;
- whichjointendarray[3]=rightankle;
-
- whichjointstartarray[4]=rightankle;
- whichjointendarray[4]=rightfoot;
-
- whichjointstartarray[5]=lefthip;
- whichjointendarray[5]=leftfoot;
-
- whichjointstartarray[6]=lefthip;
- whichjointendarray[6]=leftankle;
-
- whichjointstartarray[7]=lefthip;
- whichjointendarray[7]=leftknee;
-
- whichjointstartarray[8]=leftknee;
- whichjointendarray[8]=leftankle;
-
- whichjointstartarray[9]=leftankle;
- whichjointendarray[9]=leftfoot;
-
- whichjointstartarray[10]=abdomen;
- whichjointendarray[10]=rightshoulder;
-
- whichjointstartarray[11]=abdomen;
- whichjointendarray[11]=rightelbow;
-
- whichjointstartarray[12]=abdomen;
- whichjointendarray[12]=rightwrist;
-
- whichjointstartarray[13]=abdomen;
- whichjointendarray[13]=righthand;
-
- whichjointstartarray[14]=rightshoulder;
- whichjointendarray[14]=rightelbow;
-
- whichjointstartarray[15]=rightelbow;
- whichjointendarray[15]=rightwrist;
-
- whichjointstartarray[16]=rightwrist;
- whichjointendarray[16]=righthand;
-
- whichjointstartarray[17]=abdomen;
- whichjointendarray[17]=leftshoulder;
-
- whichjointstartarray[18]=abdomen;
- whichjointendarray[18]=leftelbow;
-
- whichjointstartarray[19]=abdomen;
- whichjointendarray[19]=leftwrist;
-
- whichjointstartarray[20]=abdomen;
- whichjointendarray[20]=lefthand;
-
- whichjointstartarray[21]=leftshoulder;
- whichjointendarray[21]=leftelbow;
-
- whichjointstartarray[22]=leftelbow;
- whichjointendarray[22]=leftwrist;
-
- whichjointstartarray[23]=leftwrist;
- whichjointendarray[23]=lefthand;
-
- whichjointstartarray[24]=abdomen;
- whichjointendarray[24]=neck;
-
- whichjointstartarray[25]=neck;
- whichjointendarray[25]=head;
-
- FadeLoadingScreen(0);
-
- stillloading=1;
-
- texture.data = ( GLubyte* )malloc( 1024*1024*4 );
-
- int temptexdetail=texdetail;
- texdetail=1;
- text.LoadFontTexture(":Data:Textures:Font.png");
- text.BuildFont();
- texdetail=temptexdetail;
-
- FadeLoadingScreen(10);
-
- if(detail==2){
- texdetail=1;
- terraindetail=1;
- }
- if(detail==1){
- texdetail=2;
- terraindetail=1;
- }
- if(detail==0){
- texdetail=4;
- terraindetail=1;
- //terraindetail=2;
- }
-
- for (int it = 0; it < 100; ++it)
- {
- channels[it] = -1;
- samp[it] = NULL;
- }
- for (int it = 0; it < 20; ++it)
- {
- strm[it] = NULL;
- }
-
- LOG("Initializing sound system...");
-
- int output = -1;