2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "openal_wrapper.h"
24 #include "Animation.h"
27 extern float screenwidth,screenheight;
28 extern float viewdistance;
30 extern XYZ lightlocation;
31 extern float fadestart;
32 extern float texscale;
35 extern Skeleton testskeleton;
37 extern Terrain terrain;
38 //extern Sprites sprites;
39 extern int kTextureSize;
40 extern float texdetail;
41 extern float realtexdetail;
43 extern Objects objects;
45 extern bool cellophane;
46 extern GLubyte bloodText[512*512*3];
47 extern GLubyte wolfbloodText[512*512*3];
48 extern bool ismotionblur;
49 extern bool trilinear;
51 extern bool musictoggle;
52 extern int environment;
53 extern bool ambientsound;
54 extern float multiplier;
55 extern int netdatanew;
57 extern bool stillloading;
58 extern TGAImageRec texture;
62 extern bool visibleloading;
63 extern float flashamount,flashr,flashg,flashb;
64 extern int flashdelay;
65 extern int whichjointstartarray[26];
66 extern int whichjointendarray[26];
67 extern int difficulty;
68 extern float tintr,tintg,tintb;
69 extern float slomospeed;
70 extern bool gamestarted;
72 extern int numdialogues;
73 extern int numdialogueboxes[20];
74 extern int dialoguetype[20];
75 extern int dialogueboxlocation[20][20];
76 extern float dialogueboxcolor[20][20][3];
77 extern int dialogueboxsound[20][20];
78 extern char dialoguetext[20][20][128];
79 extern char dialoguename[20][20][64];
80 extern XYZ dialoguecamera[20][20];
81 extern float dialoguecamerayaw[20][20];
82 extern float dialoguecamerapitch[20][20];
83 extern int indialogue;
84 extern int whichdialogue;
85 extern float dialoguetime;
87 extern float accountcampaignhighscore[10];
88 extern float accountcampaignfasttime[10];
89 extern float accountcampaignscore[10];
90 extern float accountcampaigntime[10];
92 extern int accountcampaignchoicesmade[10];
93 extern int accountcampaignchoices[10][5000];
95 void LOG(const std::string &fmt, ...)
97 // !!! FIXME: write me.
104 if(Game::endgame==2){
105 Game::accountactive->endGame();
109 Account::saveFile(":Data:Users", Game::accountactive);
113 LOG("Shutting down sound system...");
115 OPENAL_StopSound(OPENAL_ALL);
117 // this is causing problems on Linux, but we'll force an _exit() a little
118 // later in the shutdown process. --ryan.
121 for (int i=0; i < sounds_count; ++i)
123 OPENAL_Sample_Free(samp[i]);
135 void Game::newGame(){
137 skybox = new SkyBox();
140 void Game::deleteGame(){
145 for(int i=0;i<10;i++){
146 if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
148 glDeleteTextures( 1, &cursortexture );
149 glDeleteTextures( 1, &Maparrowtexture );
150 glDeleteTextures( 1, &Mapboxtexture );
151 glDeleteTextures( 1, &Mapcircletexture );
152 glDeleteTextures( 1, &terraintexture );
153 glDeleteTextures( 1, &terraintexture2 );
154 if(screentexture>0)glDeleteTextures( 1, &screentexture );
155 if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
156 glDeleteTextures( 1, &hawktexture );
157 glDeleteTextures( 1, &logotexture );
158 glDeleteTextures( 1, &loadscreentexture );
165 void Game::LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha) {
166 *textureid = Texture::Load(fileName,mipmap,hasalpha);
169 void Game::LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize) {
170 *textureid = Texture::Load(fileName,mipmap,false,array,skinsize);
173 void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
180 LOG(std::string("Loading (S)...") + fileName);
183 float temptexdetail=texdetail;
185 //upload_image( fileName );
186 //LoadTGA( fileName );
188 // Converting file to something os specific
189 char * fixedFN = ConvertFileName(fileName);
192 unsigned char fileNamep[256];
193 CopyCStringToPascal(fixedFN, fileNamep);
195 upload_image( fileNamep ,0);
196 texdetail=temptexdetail;
200 bytesPerPixel=texture.bpp/8;
203 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
204 if((i+1)%4||bytesPerPixel==3){
205 array[tempnum]=texture.data[i];
214 //***************> ResizeGLScene() <******/
215 GLvoid Game::ReSizeGLScene(float fov, float pnear)
222 glViewport(0,0,screenwidth,screenheight);
224 glMatrixMode(GL_PROJECTION);
227 gluPerspective(fov,(GLfloat)screenwidth/(GLfloat)screenheight,pnear,viewdistance);
229 glMatrixMode(GL_MODELVIEW);
233 void Game::LoadingScreen()
235 static float loadprogress;
236 static AbsoluteTime time = {0,0};
237 static AbsoluteTime frametime = {0,0};
238 AbsoluteTime currTime = UpTime ();
239 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
241 if (0 > deltaTime) // if negative microseconds
242 deltaTime /= -1000000.0;
243 else // else milliseconds
246 multiplier=deltaTime;
247 if(multiplier<.001)multiplier=.001;
248 if(multiplier>10)multiplier=10;
250 frametime = currTime; // reset for next time interval
254 glClearColor(0,0,0,1);
255 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
258 loadtime+=multiplier*4;
260 loadprogress=loadtime;
261 if(loadprogress>100)loadprogress=100;
263 //loadprogress=abs(Random()%100);
267 glEnable(GL_TEXTURE_2D);
268 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
269 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
270 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
271 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
272 glDisable(GL_CULL_FACE);
273 glDisable(GL_LIGHTING);
275 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
276 glPushMatrix(); // Store The Projection Matrix
277 glLoadIdentity(); // Reset The Projection Matrix
278 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
279 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
280 glPushMatrix(); // Store The Modelview Matrix
281 glLoadIdentity(); // Reset The Modelview Matrix
282 glTranslatef(screenwidth/2,screenheight/2,0);
283 glScalef((float)screenwidth/2,(float)screenheight/2,1);
284 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
286 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
288 //glScalef(.25,.25,.25);
290 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
291 glVertex3f(-1, -1, 0.0f);
292 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
293 glVertex3f(1, -1, 0.0f);
294 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
295 glVertex3f(1, 1, 0.0f);
296 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
297 glVertex3f(-1, 1, 0.0f);
302 //glScalef(.25,.25,.25);
304 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
305 glVertex3f(-1, -1, 0.0f);
306 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
307 glVertex3f(1, -1, 0.0f);
308 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
309 glVertex3f(1, 1, 0.0f);
310 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
311 glVertex3f(-1, 1, 0.0f);
314 glDisable(GL_TEXTURE_2D);
315 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
316 glPopMatrix(); // Restore The Old Projection Matrix
317 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
318 glPopMatrix(); // Restore The Old Projection Matrix
322 glEnable(GL_TEXTURE_2D);
323 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
324 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
325 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
326 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
327 glDisable(GL_CULL_FACE);
328 glDisable(GL_LIGHTING);
330 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
331 glPushMatrix(); // Store The Projection Matrix
332 glLoadIdentity(); // Reset The Projection Matrix
333 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
334 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
335 glPushMatrix(); // Store The Modelview Matrix
336 glLoadIdentity(); // Reset The Modelview Matrix
337 glTranslatef(screenwidth/2,screenheight/2,0);
338 glScalef((float)screenwidth/2*(1.5-(loadprogress)/200),(float)screenheight/2*(1.5-(loadprogress)/200),1);
339 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
341 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
342 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
344 //glScalef(.25,.25,.25);
346 glTexCoord2f(0+.5,0+.5);
347 glVertex3f(-1, -1, 0.0f);
348 glTexCoord2f(1+.5,0+.5);
349 glVertex3f(1, -1, 0.0f);
350 glTexCoord2f(1+.5,1+.5);
351 glVertex3f(1, 1, 0.0f);
352 glTexCoord2f(0+.5,1+.5);
353 glVertex3f(-1, 1, 0.0f);
356 glDisable(GL_TEXTURE_2D);
357 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
358 glPopMatrix(); // Restore The Old Projection Matrix
359 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
360 glPopMatrix(); // Restore The Old Projection Matrix
364 glEnable(GL_TEXTURE_2D);
365 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
366 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
367 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
368 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
369 glDisable(GL_CULL_FACE);
370 glDisable(GL_LIGHTING);
372 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
373 glPushMatrix(); // Store The Projection Matrix
374 glLoadIdentity(); // Reset The Projection Matrix
375 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
376 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
377 glPushMatrix(); // Store The Modelview Matrix
378 glLoadIdentity(); // Reset The Modelview Matrix
379 glTranslatef(screenwidth/2,screenheight/2,0);
380 glScalef((float)screenwidth/2*(100+loadprogress)/100,(float)screenheight/2*(100+loadprogress)/100,1);
381 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
383 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,.4);
385 //glScalef(.25,.25,.25);
387 glTexCoord2f(0+.2,0+.8);
388 glVertex3f(-1, -1, 0.0f);
389 glTexCoord2f(1+.2,0+.8);
390 glVertex3f(1, -1, 0.0f);
391 glTexCoord2f(1+.2,1+.8);
392 glVertex3f(1, 1, 0.0f);
393 glTexCoord2f(0+.2,1+.8);
394 glVertex3f(-1, 1, 0.0f);
397 glDisable(GL_TEXTURE_2D);
398 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
399 glPopMatrix(); // Restore The Old Projection Matrix
400 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
401 glPopMatrix(); // Restore The Old Projection Matrix
408 if(flashamount>1)flashamount=1;
409 if(flashdelay<=0)flashamount-=multiplier;
411 if(flashamount<0)flashamount=0;
412 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
413 glDisable(GL_CULL_FACE);
414 glDisable(GL_LIGHTING);
415 glDisable(GL_TEXTURE_2D);
417 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
418 glPushMatrix(); // Store The Projection Matrix
419 glLoadIdentity(); // Reset The Projection Matrix
420 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
421 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
422 glPushMatrix(); // Store The Modelview Matrix
423 glLoadIdentity(); // Reset The Modelview Matrix
424 glScalef(screenwidth,screenheight,1);
425 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
427 glColor4f(flashr,flashg,flashb,flashamount);
429 glVertex3f(0, 0, 0.0f);
430 glVertex3f(256, 0, 0.0f);
431 glVertex3f(256, 256, 0.0f);
432 glVertex3f(0, 256, 0.0f);
434 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
435 glPopMatrix(); // Restore The Old Projection Matrix
436 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
437 glPopMatrix(); // Restore The Old Projection Matrix
438 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
439 glEnable(GL_CULL_FACE);
448 void FadeLoadingScreen(float howmuch)
450 static float loadprogress;
454 glClearColor(0,0,0,1);
455 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
457 loadprogress=howmuch;
459 //loadprogress=abs(Random()%100);
463 //glEnable(GL_TEXTURE_2D);
464 glDisable(GL_TEXTURE_2D);
465 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
466 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
467 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
468 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
469 glDisable(GL_CULL_FACE);
470 glDisable(GL_LIGHTING);
472 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
473 glPushMatrix(); // Store The Projection Matrix
474 glLoadIdentity(); // Reset The Projection Matrix
475 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
476 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
477 glPushMatrix(); // Store The Modelview Matrix
478 glLoadIdentity(); // Reset The Modelview Matrix
479 glTranslatef(screenwidth/2,screenheight/2,0);
480 glScalef((float)screenwidth/2,(float)screenheight/2,1);
481 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
483 glColor4f(loadprogress/100,0,0,1);
485 //glScalef(.25,.25,.25);
488 glVertex3f(-1, -1, 0.0f);
490 glVertex3f(1, -1, 0.0f);
492 glVertex3f(1, 1, 0.0f);
494 glVertex3f(-1, 1, 0.0f);
497 glDisable(GL_TEXTURE_2D);
498 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
499 glPopMatrix(); // Restore The Old Projection Matrix
500 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
501 glPopMatrix(); // Restore The Old Projection Matrix
509 void Game::InitGame()
512 ProcessSerialNumber PSN;
513 ProcessInfoRec pinfo;
516 /* set up process serial number */
517 PSN.highLongOfPSN = 0;
518 PSN.lowLongOfPSN = kCurrentProcess;
519 /* set up info block */
520 pinfo.processInfoLength = sizeof(pinfo);
521 pinfo.processName = NULL;
522 pinfo.processAppSpec = &pspec;
523 /* grab the vrefnum and directory */
524 err = GetProcessInformation(&PSN, &pinfo);
526 vRefNum = pspec.vRefNum;
533 numchallengelevels=14;
535 accountactive=Account::loadFile(":Data:Users");
541 whichjointstartarray[0]=righthip;
542 whichjointendarray[0]=rightfoot;
544 whichjointstartarray[1]=righthip;
545 whichjointendarray[1]=rightankle;
547 whichjointstartarray[2]=righthip;
548 whichjointendarray[2]=rightknee;
550 whichjointstartarray[3]=rightknee;
551 whichjointendarray[3]=rightankle;
553 whichjointstartarray[4]=rightankle;
554 whichjointendarray[4]=rightfoot;
556 whichjointstartarray[5]=lefthip;
557 whichjointendarray[5]=leftfoot;
559 whichjointstartarray[6]=lefthip;
560 whichjointendarray[6]=leftankle;
562 whichjointstartarray[7]=lefthip;
563 whichjointendarray[7]=leftknee;
565 whichjointstartarray[8]=leftknee;
566 whichjointendarray[8]=leftankle;
568 whichjointstartarray[9]=leftankle;
569 whichjointendarray[9]=leftfoot;
571 whichjointstartarray[10]=abdomen;
572 whichjointendarray[10]=rightshoulder;
574 whichjointstartarray[11]=abdomen;
575 whichjointendarray[11]=rightelbow;
577 whichjointstartarray[12]=abdomen;
578 whichjointendarray[12]=rightwrist;
580 whichjointstartarray[13]=abdomen;
581 whichjointendarray[13]=righthand;
583 whichjointstartarray[14]=rightshoulder;
584 whichjointendarray[14]=rightelbow;
586 whichjointstartarray[15]=rightelbow;
587 whichjointendarray[15]=rightwrist;
589 whichjointstartarray[16]=rightwrist;
590 whichjointendarray[16]=righthand;
592 whichjointstartarray[17]=abdomen;
593 whichjointendarray[17]=leftshoulder;
595 whichjointstartarray[18]=abdomen;
596 whichjointendarray[18]=leftelbow;
598 whichjointstartarray[19]=abdomen;
599 whichjointendarray[19]=leftwrist;
601 whichjointstartarray[20]=abdomen;
602 whichjointendarray[20]=lefthand;
604 whichjointstartarray[21]=leftshoulder;
605 whichjointendarray[21]=leftelbow;
607 whichjointstartarray[22]=leftelbow;
608 whichjointendarray[22]=leftwrist;
610 whichjointstartarray[23]=leftwrist;
611 whichjointendarray[23]=lefthand;
613 whichjointstartarray[24]=abdomen;
614 whichjointendarray[24]=neck;
616 whichjointstartarray[25]=neck;
617 whichjointendarray[25]=head;
619 FadeLoadingScreen(0);
623 texture.data = ( GLubyte* )malloc( 1024*1024*4 );
625 int temptexdetail=texdetail;
627 text->LoadFontTexture(":Data:Textures:Font.png");
629 texdetail=temptexdetail;
631 FadeLoadingScreen(10);
643 LOG("Initializing sound system...");
648 extern bool cmdline(const char *cmd);
649 unsigned char rc = 0;
650 output = OPENAL_OUTPUT_ALSA; // Try alsa first...
651 if (cmdline("forceoss")) // ...but let user override that.
652 output = OPENAL_OUTPUT_OSS;
653 else if (cmdline("nosound"))
654 output = OPENAL_OUTPUT_NOSOUND;
656 OPENAL_SetOutput(output);
657 if ((rc = OPENAL_Init(44100, 32, 0)) == false)
659 // if we tried ALSA and failed, fall back to OSS.
660 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) )
663 output = OPENAL_OUTPUT_OSS;
664 OPENAL_SetOutput(output);
665 rc = OPENAL_Init(44100, 32, 0);
672 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
673 OPENAL_SetOutput(output);
674 rc = OPENAL_Init(44100, 32, 0);
677 OPENAL_Init(44100, 32, 0);
680 OPENAL_SetSFXMasterVolume((int)(volume*255));
684 emit_stream_np(stream_menutheme);
686 LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1);
688 LoadTexture(":Data:Textures:MapCircle.png",&Mapcircletexture,0,1);
689 LoadTexture(":Data:Textures:MapBox.png",&Mapboxtexture,0,1);
690 LoadTexture(":Data:Textures:MapArrow.png",&Maparrowtexture,0,1);
692 temptexdetail=texdetail;
693 if(texdetail>2)texdetail=2;
694 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
695 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
696 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
697 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
698 LoadTexture(":Data:Textures:Eyelid.png",&Mainmenuitems[4],0,1);
699 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[5],0,0);
700 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[6],0,0);
702 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
703 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
704 texdetail=temptexdetail;
706 FadeLoadingScreen(95);
716 newscreenwidth=screenwidth;
717 newscreenheight=screenheight;
723 void LoadScreenTexture() {
724 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
726 if(!Game::screentexture)
727 glGenTextures( 1, &Game::screentexture );
728 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
731 glEnable(GL_TEXTURE_2D);
732 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
733 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
734 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
736 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
739 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
740 void Game::LoadStuff()
742 static float temptexdetail;
743 static float viewdistdetail;
755 for(i=0;i<maxplayers;i++)
757 if (glIsTexture(player[i].skeleton.drawmodel.textureptr))
759 glDeleteTextures(1, &player[i].skeleton.drawmodel.textureptr);
761 player[i].skeleton.drawmodel.textureptr=0;;
765 LoadTexture(":Data:Textures:fire.jpg",&loadscreentexture,1,0);
767 temptexdetail=texdetail;
769 text->LoadFontTexture(":Data:Textures:Font.png");
771 texdetail=temptexdetail;
776 viewdistance=50*megascale*viewdistdetail;
788 realtexdetail=texdetail;
793 LOG("Loading weapon data...");
795 LoadTexture(":Data:Textures:knife.png",&Weapon::knifetextureptr,0,1);
796 LoadTexture(":Data:Textures:bloodknife.png",&Weapon::bloodknifetextureptr,0,1);
797 LoadTexture(":Data:Textures:lightbloodknife.png",&Weapon::lightbloodknifetextureptr,0,1);
798 LoadTexture(":Data:Textures:sword.jpg",&Weapon::swordtextureptr,1,0);
799 LoadTexture(":Data:Textures:Swordblood.jpg",&Weapon::bloodswordtextureptr,1,0);
800 LoadTexture(":Data:Textures:Swordbloodlight.jpg",&Weapon::lightbloodswordtextureptr,1,0);
801 LoadTexture(":Data:Textures:Staff.jpg",&Weapon::stafftextureptr,1,0);
803 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1);
804 Weapon::throwingknifemodel.Scale(.001,.001,.001);
805 //Weapon::throwingknifemodel.Rotate(0,0,-90);
806 Weapon::throwingknifemodel.Rotate(90,0,0);
807 Weapon::throwingknifemodel.Rotate(0,90,0);
808 Weapon::throwingknifemodel.flat=0;
809 Weapon::throwingknifemodel.CalculateNormals(1);
810 //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1);
812 Weapon::swordmodel.load((char *)":Data:Models:sword.solid",1);
813 Weapon::swordmodel.Scale(.001,.001,.001);
814 //Weapon::swordmodel.Rotate(0,0,-90);
815 Weapon::swordmodel.Rotate(90,0,0);
816 Weapon::swordmodel.Rotate(0,90,0);
817 Weapon::swordmodel.Rotate(0,0,90);
818 Weapon::swordmodel.flat=1;
819 Weapon::swordmodel.CalculateNormals(1);
820 //Weapon::swordmodel.ScaleNormals(-1,-1,-1);
822 Weapon::staffmodel.load((char *)":Data:Models:staff.solid",1);
823 Weapon::staffmodel.Scale(.005,.005,.005);
824 //Weapon::staffmodel.Rotate(0,0,-90);
825 Weapon::staffmodel.Rotate(90,0,0);
826 Weapon::staffmodel.Rotate(0,90,0);
827 Weapon::staffmodel.Rotate(0,0,90);
828 Weapon::staffmodel.flat=1;
829 Weapon::staffmodel.CalculateNormals(1);
830 //Weapon::staffmodel.ScaleNormals(-1,-1,-1);
832 LoadTexture(":Data:Textures:shadow.png",&terrain.shadowtexture,0,1);
834 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture,0,1);
836 LoadTexture(":Data:Textures:break.png",&terrain.breaktexture,0,1);
838 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture2,0,1);
841 LoadTexture(":Data:Textures:footprint.png",&terrain.footprinttexture,0,1);
843 LoadTexture(":Data:Textures:bodyprint.png",&terrain.bodyprinttexture,0,1);
845 LoadTexture(":Data:Textures:hawk.png",&hawktexture,0,1);
847 LoadTexture(":Data:Textures:logo.png",&logotexture,0,1);
850 LoadTexture(":Data:Textures:cloud.png",&Sprite::cloudtexture,1,1);
851 LoadTexture(":Data:Textures:cloudimpact.png",&Sprite::cloudimpacttexture,1,1);
852 LoadTexture(":Data:Textures:bloodparticle.png",&Sprite::bloodtexture,1,1);
853 LoadTexture(":Data:Textures:snowflake.png",&Sprite::snowflaketexture,1,1);
854 LoadTexture(":Data:Textures:flame.png",&Sprite::flametexture,1,1);
855 LoadTexture(":Data:Textures:bloodflame.png",&Sprite::bloodflametexture,1,1);
856 LoadTexture(":Data:Textures:smoke.png",&Sprite::smoketexture,1,1);
857 LoadTexture(":Data:Textures:shine.png",&Sprite::shinetexture,1,0);
858 LoadTexture(":Data:Textures:splinter.png",&Sprite::splintertexture,1,1);
859 LoadTexture(":Data:Textures:leaf.png",&Sprite::leaftexture,1,1);
860 LoadTexture(":Data:Textures:tooth.png",&Sprite::toothtexture,1,1);
864 ReSizeGLScene(90,.01);
869 if(detail)kTextureSize=1024;
870 if(detail==1)kTextureSize=512;
871 if(detail==0)kTextureSize=256;
873 //Set up distant light
879 light.ambient[2]=.24;
882 light.location.z=-.2;
883 Normalise(&light.location);
893 texscale=.2/megascale/viewdistdetail;
894 terrain.scale=3*megascale*viewdistdetail;
896 viewer.x=terrain.size/2*terrain.scale;
897 viewer.z=terrain.size/2*terrain.scale;
899 hawk.load((char *)":Data:Models:hawk.solid",1);
900 hawk.Scale(.03,.03,.03);
902 hawk.CalculateNormals(0);
903 hawk.ScaleNormals(-1,-1,-1);
904 hawkcoords.x=terrain.size/2*terrain.scale-5-7;
905 hawkcoords.z=terrain.size/2*terrain.scale-5-7;
906 hawkcoords.y=terrain.getHeight(hawkcoords.x,hawkcoords.z)+25;
908 eye.load((char *)":Data:Models:eye.solid",1);
909 eye.Scale(.03,.03,.03);
910 eye.CalculateNormals(0);
912 cornea.load((char *)":Data:Models:cornea.solid",1);
913 cornea.Scale(.03,.03,.03);
914 cornea.CalculateNormals(0);
916 iris.load((char *)":Data:Models:iris.solid",1);
917 iris.Scale(.03,.03,.03);
918 iris.CalculateNormals(0);
920 LoadSave(":Data:Textures:Bloodfur.png",0,1,&bloodText[0],0);
921 LoadSave(":Data:Textures:Wolfbloodfur.png",0,1,&wolfbloodText[0],0);
931 //Fix knife stab, too lazy to do it manually
935 for(i=0;i<player[0].skeleton.num_joints;i++){
936 for(j=0;j<animation[knifesneakattackanim].numframes;j++){
937 animation[knifesneakattackanim].position[i][j]+=moveamount;
943 for(i=0;i<player[0].skeleton.num_joints;i++){
944 for(j=0;j<animation[knifesneakattackedanim].numframes;j++){
945 animation[knifesneakattackedanim].position[i][j]+=moveamount;
951 for(i=0;i<player[0].skeleton.num_joints;i++){
952 animation[dead1anim].position[i][1]=animation[dead1anim].position[i][0];
953 animation[dead2anim].position[i][1]=animation[dead2anim].position[i][0];
954 animation[dead3anim].position[i][1]=animation[dead3anim].position[i][0];
955 animation[dead4anim].position[i][1]=animation[dead4anim].position[i][0];
957 animation[dead1anim].speed[0]=0.001;
958 animation[dead2anim].speed[0]=0.001;
959 animation[dead3anim].speed[0]=0.001;
960 animation[dead4anim].speed[0]=0.001;
962 animation[dead1anim].speed[1]=0.001;
963 animation[dead2anim].speed[1]=0.001;
964 animation[dead3anim].speed[1]=0.001;
965 animation[dead4anim].speed[1]=0.001;
967 for(i=0;i<player[0].skeleton.num_joints;i++){
968 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
969 animation[swordsneakattackanim].position[i][j]+=moveamount;
973 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
974 animation[swordsneakattackanim].weapontarget[j]+=moveamount;
979 for(i=0;i<player[0].skeleton.num_joints;i++){
980 for(j=0;j<animation[swordsneakattackedanim].numframes;j++){
981 animation[swordsneakattackedanim].position[i][j]+=moveamount;
986 temptexdetail=texdetail;
988 texdetail=temptexdetail;
997 emit_sound_at(fireendsound);