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 lightambient[3],lightbrightness[3];
32 extern float fadestart;
33 extern float texscale;
36 extern Skeleton testskeleton;
38 extern Terrain terrain;
39 //extern Sprites sprites;
40 extern int kTextureSize;
41 extern float texdetail;
42 extern float realtexdetail;
44 extern Objects objects;
46 extern bool cellophane;
47 extern GLubyte bloodText[512*512*3];
48 extern GLubyte wolfbloodText[512*512*3];
49 extern bool ismotionblur;
50 extern bool trilinear;
52 extern bool musictoggle;
53 extern int environment;
54 extern bool ambientsound;
55 extern float multiplier;
56 extern int netdatanew;
58 extern bool stillloading;
59 extern TGAImageRec texture;
63 extern bool visibleloading;
64 extern float flashamount,flashr,flashg,flashb;
65 extern int flashdelay;
66 extern int whichjointstartarray[26];
67 extern int whichjointendarray[26];
68 extern int difficulty;
69 extern float tintr,tintg,tintb;
70 extern float slomospeed;
71 extern bool gamestarted;
73 extern int numdialogues;
74 extern int numdialogueboxes[20];
75 extern int dialoguetype[20];
76 extern int dialogueboxlocation[20][20];
77 extern float dialogueboxcolor[20][20][3];
78 extern int dialogueboxsound[20][20];
79 extern char dialoguetext[20][20][128];
80 extern char dialoguename[20][20][64];
81 extern XYZ dialoguecamera[20][20];
82 extern float dialoguecamerarotation[20][20];
83 extern float dialoguecamerarotation2[20][20];
84 extern int indialogue;
85 extern int whichdialogue;
86 extern float dialoguetime;
88 extern float accountcampaignhighscore[10];
89 extern float accountcampaignfasttime[10];
90 extern float accountcampaignscore[10];
91 extern float accountcampaigntime[10];
93 extern int accountcampaignchoicesmade[10];
94 extern int accountcampaignchoices[10][5000];
96 void LOG(const std::string &fmt, ...)
98 // !!! FIXME: write me.
106 accountactive->endGame();
110 Account::saveFile(":Data:Users", accountactive);
114 LOG("Shutting down sound system...");
116 OPENAL_StopSound(OPENAL_ALL);
118 // this is causing problems on Linux, but we'll force an _exit() a little
119 // later in the shutdown process. --ryan.
122 for (int i=0; i < sounds_count; ++i)
124 OPENAL_Sample_Free(samp[i]);
137 void Game::LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha) {
138 *textureid = Texture::Load(fileName,mipmap,hasalpha);
141 void Game::LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize) {
142 *textureid = Texture::Load(fileName,mipmap,false,array,skinsize);
145 void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
152 LOG(std::string("Loading (S)...") + fileName);
155 float temptexdetail=texdetail;
157 //upload_image( fileName );
158 //LoadTGA( fileName );
160 // Converting file to something os specific
161 char * fixedFN = ConvertFileName(fileName);
164 unsigned char fileNamep[256];
165 CopyCStringToPascal(fixedFN, fileNamep);
167 upload_image( fileNamep ,0);
168 texdetail=temptexdetail;
172 bytesPerPixel=texture.bpp/8;
175 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
176 if((i+1)%4||bytesPerPixel==3){
177 array[tempnum]=texture.data[i];
184 bool Game::AddClothes(const char *fileName, GLubyte *array)
191 //upload_image( fileName );
192 //LoadTGA( fileName );
194 unsigned char fileNamep[256];
195 CopyCStringToPascal(fileName,fileNamep);
198 opened=upload_image( fileNamep ,1);
211 bytesPerPixel=texture.bpp/8;
215 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
216 if(bytesPerPixel==3)alphanum=255;
217 else if((i+1)%4==0)alphanum=texture.data[i];
219 if((i+1)%4||bytesPerPixel==3){
220 if((i%4)==0)texture.data[i]*=tintr;
221 if((i%4)==1)texture.data[i]*=tintg;
222 if((i%4)==2)texture.data[i]*=tintb;
223 array[tempnum]=(float)array[tempnum]*(1-alphanum/255)+(float)texture.data[i]*(alphanum/255);
233 //***************> ResizeGLScene() <******/
234 GLvoid Game::ReSizeGLScene(float fov, float pnear)
241 glViewport(0,0,screenwidth,screenheight);
243 glMatrixMode(GL_PROJECTION);
246 gluPerspective(fov,(GLfloat)screenwidth/(GLfloat)screenheight,pnear,viewdistance);
248 glMatrixMode(GL_MODELVIEW);
252 void Game::LoadingScreen()
254 static float loadprogress;
255 static AbsoluteTime time = {0,0};
256 static AbsoluteTime frametime = {0,0};
257 AbsoluteTime currTime = UpTime ();
258 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
260 if (0 > deltaTime) // if negative microseconds
261 deltaTime /= -1000000.0;
262 else // else milliseconds
265 multiplier=deltaTime;
266 if(multiplier<.001)multiplier=.001;
267 if(multiplier>10)multiplier=10;
269 frametime = currTime; // reset for next time interval
273 glClearColor(0,0,0,1);
274 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
277 loadtime+=multiplier*4;
279 loadprogress=loadtime;
280 if(loadprogress>100)loadprogress=100;
282 //loadprogress=abs(Random()%100);
286 glEnable(GL_TEXTURE_2D);
287 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
288 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
289 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
290 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
291 glDisable(GL_CULL_FACE);
292 glDisable(GL_LIGHTING);
294 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
295 glPushMatrix(); // Store The Projection Matrix
296 glLoadIdentity(); // Reset The Projection Matrix
297 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
298 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
299 glPushMatrix(); // Store The Modelview Matrix
300 glLoadIdentity(); // Reset The Modelview Matrix
301 glTranslatef(screenwidth/2,screenheight/2,0);
302 glScalef((float)screenwidth/2,(float)screenheight/2,1);
303 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
305 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
307 //glScalef(.25,.25,.25);
309 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
310 glVertex3f(-1, -1, 0.0f);
311 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
312 glVertex3f(1, -1, 0.0f);
313 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
314 glVertex3f(1, 1, 0.0f);
315 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
316 glVertex3f(-1, 1, 0.0f);
321 //glScalef(.25,.25,.25);
323 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
324 glVertex3f(-1, -1, 0.0f);
325 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
326 glVertex3f(1, -1, 0.0f);
327 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
328 glVertex3f(1, 1, 0.0f);
329 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
330 glVertex3f(-1, 1, 0.0f);
333 glDisable(GL_TEXTURE_2D);
334 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
335 glPopMatrix(); // Restore The Old Projection Matrix
336 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
337 glPopMatrix(); // Restore The Old Projection Matrix
341 glEnable(GL_TEXTURE_2D);
342 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
343 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
344 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
345 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
346 glDisable(GL_CULL_FACE);
347 glDisable(GL_LIGHTING);
349 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
350 glPushMatrix(); // Store The Projection Matrix
351 glLoadIdentity(); // Reset The Projection Matrix
352 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
353 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
354 glPushMatrix(); // Store The Modelview Matrix
355 glLoadIdentity(); // Reset The Modelview Matrix
356 glTranslatef(screenwidth/2,screenheight/2,0);
357 glScalef((float)screenwidth/2*(1.5-(loadprogress)/200),(float)screenheight/2*(1.5-(loadprogress)/200),1);
358 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
360 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
361 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
363 //glScalef(.25,.25,.25);
365 glTexCoord2f(0+.5,0+.5);
366 glVertex3f(-1, -1, 0.0f);
367 glTexCoord2f(1+.5,0+.5);
368 glVertex3f(1, -1, 0.0f);
369 glTexCoord2f(1+.5,1+.5);
370 glVertex3f(1, 1, 0.0f);
371 glTexCoord2f(0+.5,1+.5);
372 glVertex3f(-1, 1, 0.0f);
375 glDisable(GL_TEXTURE_2D);
376 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
377 glPopMatrix(); // Restore The Old Projection Matrix
378 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
379 glPopMatrix(); // Restore The Old Projection Matrix
383 glEnable(GL_TEXTURE_2D);
384 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
385 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
386 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
387 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
388 glDisable(GL_CULL_FACE);
389 glDisable(GL_LIGHTING);
391 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
392 glPushMatrix(); // Store The Projection Matrix
393 glLoadIdentity(); // Reset The Projection Matrix
394 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
395 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
396 glPushMatrix(); // Store The Modelview Matrix
397 glLoadIdentity(); // Reset The Modelview Matrix
398 glTranslatef(screenwidth/2,screenheight/2,0);
399 glScalef((float)screenwidth/2*(100+loadprogress)/100,(float)screenheight/2*(100+loadprogress)/100,1);
400 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
402 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,.4);
404 //glScalef(.25,.25,.25);
406 glTexCoord2f(0+.2,0+.8);
407 glVertex3f(-1, -1, 0.0f);
408 glTexCoord2f(1+.2,0+.8);
409 glVertex3f(1, -1, 0.0f);
410 glTexCoord2f(1+.2,1+.8);
411 glVertex3f(1, 1, 0.0f);
412 glTexCoord2f(0+.2,1+.8);
413 glVertex3f(-1, 1, 0.0f);
416 glDisable(GL_TEXTURE_2D);
417 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
418 glPopMatrix(); // Restore The Old Projection Matrix
419 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
420 glPopMatrix(); // Restore The Old Projection Matrix
427 if(flashamount>1)flashamount=1;
428 if(flashdelay<=0)flashamount-=multiplier;
430 if(flashamount<0)flashamount=0;
431 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
432 glDisable(GL_CULL_FACE);
433 glDisable(GL_LIGHTING);
434 glDisable(GL_TEXTURE_2D);
436 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
437 glPushMatrix(); // Store The Projection Matrix
438 glLoadIdentity(); // Reset The Projection Matrix
439 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
440 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
441 glPushMatrix(); // Store The Modelview Matrix
442 glLoadIdentity(); // Reset The Modelview Matrix
443 glScalef(screenwidth,screenheight,1);
444 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
446 glColor4f(flashr,flashg,flashb,flashamount);
448 glVertex3f(0, 0, 0.0f);
449 glVertex3f(256, 0, 0.0f);
450 glVertex3f(256, 256, 0.0f);
451 glVertex3f(0, 256, 0.0f);
453 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
454 glPopMatrix(); // Restore The Old Projection Matrix
455 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
456 glPopMatrix(); // Restore The Old Projection Matrix
457 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
458 glEnable(GL_CULL_FACE);
467 void Game::FadeLoadingScreen(float howmuch)
469 static float loadprogress;
473 glClearColor(0,0,0,1);
474 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
476 loadprogress=howmuch;
478 //loadprogress=abs(Random()%100);
482 //glEnable(GL_TEXTURE_2D);
483 glDisable(GL_TEXTURE_2D);
484 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
485 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
486 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
487 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
488 glDisable(GL_CULL_FACE);
489 glDisable(GL_LIGHTING);
491 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
492 glPushMatrix(); // Store The Projection Matrix
493 glLoadIdentity(); // Reset The Projection Matrix
494 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
495 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
496 glPushMatrix(); // Store The Modelview Matrix
497 glLoadIdentity(); // Reset The Modelview Matrix
498 glTranslatef(screenwidth/2,screenheight/2,0);
499 glScalef((float)screenwidth/2,(float)screenheight/2,1);
500 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
502 glColor4f(loadprogress/100,0,0,1);
504 //glScalef(.25,.25,.25);
507 glVertex3f(-1, -1, 0.0f);
509 glVertex3f(1, -1, 0.0f);
511 glVertex3f(1, 1, 0.0f);
513 glVertex3f(-1, 1, 0.0f);
516 glDisable(GL_TEXTURE_2D);
517 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
518 glPopMatrix(); // Restore The Old Projection Matrix
519 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
520 glPopMatrix(); // Restore The Old Projection Matrix
528 void Game::InitGame()
531 ProcessSerialNumber PSN;
532 ProcessInfoRec pinfo;
535 /* set up process serial number */
536 PSN.highLongOfPSN = 0;
537 PSN.lowLongOfPSN = kCurrentProcess;
538 /* set up info block */
539 pinfo.processInfoLength = sizeof(pinfo);
540 pinfo.processName = NULL;
541 pinfo.processAppSpec = &pspec;
542 /* grab the vrefnum and directory */
543 err = GetProcessInformation(&PSN, &pinfo);
545 vRefNum = pspec.vRefNum;
554 numchallengelevels=14;
556 accountactive=Account::loadFile(":Data:Users");
562 whichjointstartarray[0]=righthip;
563 whichjointendarray[0]=rightfoot;
565 whichjointstartarray[1]=righthip;
566 whichjointendarray[1]=rightankle;
568 whichjointstartarray[2]=righthip;
569 whichjointendarray[2]=rightknee;
571 whichjointstartarray[3]=rightknee;
572 whichjointendarray[3]=rightankle;
574 whichjointstartarray[4]=rightankle;
575 whichjointendarray[4]=rightfoot;
577 whichjointstartarray[5]=lefthip;
578 whichjointendarray[5]=leftfoot;
580 whichjointstartarray[6]=lefthip;
581 whichjointendarray[6]=leftankle;
583 whichjointstartarray[7]=lefthip;
584 whichjointendarray[7]=leftknee;
586 whichjointstartarray[8]=leftknee;
587 whichjointendarray[8]=leftankle;
589 whichjointstartarray[9]=leftankle;
590 whichjointendarray[9]=leftfoot;
592 whichjointstartarray[10]=abdomen;
593 whichjointendarray[10]=rightshoulder;
595 whichjointstartarray[11]=abdomen;
596 whichjointendarray[11]=rightelbow;
598 whichjointstartarray[12]=abdomen;
599 whichjointendarray[12]=rightwrist;
601 whichjointstartarray[13]=abdomen;
602 whichjointendarray[13]=righthand;
604 whichjointstartarray[14]=rightshoulder;
605 whichjointendarray[14]=rightelbow;
607 whichjointstartarray[15]=rightelbow;
608 whichjointendarray[15]=rightwrist;
610 whichjointstartarray[16]=rightwrist;
611 whichjointendarray[16]=righthand;
613 whichjointstartarray[17]=abdomen;
614 whichjointendarray[17]=leftshoulder;
616 whichjointstartarray[18]=abdomen;
617 whichjointendarray[18]=leftelbow;
619 whichjointstartarray[19]=abdomen;
620 whichjointendarray[19]=leftwrist;
622 whichjointstartarray[20]=abdomen;
623 whichjointendarray[20]=lefthand;
625 whichjointstartarray[21]=leftshoulder;
626 whichjointendarray[21]=leftelbow;
628 whichjointstartarray[22]=leftelbow;
629 whichjointendarray[22]=leftwrist;
631 whichjointstartarray[23]=leftwrist;
632 whichjointendarray[23]=lefthand;
634 whichjointstartarray[24]=abdomen;
635 whichjointendarray[24]=neck;
637 whichjointstartarray[25]=neck;
638 whichjointendarray[25]=head;
640 FadeLoadingScreen(0);
644 texture.data = ( GLubyte* )malloc( 1024*1024*4 );
646 int temptexdetail=texdetail;
648 text->LoadFontTexture(":Data:Textures:Font.png");
650 texdetail=temptexdetail;
652 FadeLoadingScreen(10);
664 LOG("Initializing sound system...");
669 extern bool cmdline(const char *cmd);
670 unsigned char rc = 0;
671 output = OPENAL_OUTPUT_ALSA; // Try alsa first...
672 if (cmdline("forceoss")) // ...but let user override that.
673 output = OPENAL_OUTPUT_OSS;
674 else if (cmdline("nosound"))
675 output = OPENAL_OUTPUT_NOSOUND;
677 OPENAL_SetOutput(output);
678 if ((rc = OPENAL_Init(44100, 32, 0)) == false)
680 // if we tried ALSA and failed, fall back to OSS.
681 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) )
684 output = OPENAL_OUTPUT_OSS;
685 OPENAL_SetOutput(output);
686 rc = OPENAL_Init(44100, 32, 0);
693 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
694 OPENAL_SetOutput(output);
695 rc = OPENAL_Init(44100, 32, 0);
698 OPENAL_Init(44100, 32, 0);
701 OPENAL_SetSFXMasterVolume((int)(volume*255));
705 emit_stream_np(stream_menutheme);
707 LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1);
709 LoadTexture(":Data:Textures:MapCircle.png",&Mapcircletexture,0,1);
710 LoadTexture(":Data:Textures:MapBox.png",&Mapboxtexture,0,1);
711 LoadTexture(":Data:Textures:MapArrow.png",&Maparrowtexture,0,1);
713 temptexdetail=texdetail;
714 if(texdetail>2)texdetail=2;
715 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
716 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
717 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
718 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
719 LoadTexture(":Data:Textures:Eyelid.png",&Mainmenuitems[4],0,1);
720 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[5],0,0);
721 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[6],0,0);
723 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
724 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
725 texdetail=temptexdetail;
727 FadeLoadingScreen(95);
737 newscreenwidth=screenwidth;
738 newscreenheight=screenheight;
744 void Game::LoadScreenTexture() {
745 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
748 glGenTextures( 1, &screentexture );
749 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
752 glEnable(GL_TEXTURE_2D);
753 glBindTexture( GL_TEXTURE_2D, screentexture);
754 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
755 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
757 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
760 void Game::LoadStuff()
762 static float temptexdetail;
763 static float viewdistdetail;
775 for(i=0;i<maxplayers;i++)
777 if (glIsTexture(player[i].skeleton.drawmodel.textureptr))
779 glDeleteTextures(1, &player[i].skeleton.drawmodel.textureptr);
781 player[i].skeleton.drawmodel.textureptr=0;;
785 LoadTexture(":Data:Textures:fire.jpg",&loadscreentexture,1,0);
787 temptexdetail=texdetail;
789 text->LoadFontTexture(":Data:Textures:Font.png");
791 texdetail=temptexdetail;
796 viewdistance=50*megascale*viewdistdetail;
810 realtexdetail=texdetail;
815 LOG("Loading weapon data...");
817 LoadTexture(":Data:Textures:knife.png",&Weapon::knifetextureptr,0,1);
818 LoadTexture(":Data:Textures:bloodknife.png",&Weapon::bloodknifetextureptr,0,1);
819 LoadTexture(":Data:Textures:lightbloodknife.png",&Weapon::lightbloodknifetextureptr,0,1);
820 LoadTexture(":Data:Textures:sword.jpg",&Weapon::swordtextureptr,1,0);
821 LoadTexture(":Data:Textures:Swordblood.jpg",&Weapon::bloodswordtextureptr,1,0);
822 LoadTexture(":Data:Textures:Swordbloodlight.jpg",&Weapon::lightbloodswordtextureptr,1,0);
823 LoadTexture(":Data:Textures:Staff.jpg",&Weapon::stafftextureptr,1,0);
825 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1);
826 Weapon::throwingknifemodel.Scale(.001,.001,.001);
827 //Weapon::throwingknifemodel.Rotate(0,0,-90);
828 Weapon::throwingknifemodel.Rotate(90,0,0);
829 Weapon::throwingknifemodel.Rotate(0,90,0);
830 Weapon::throwingknifemodel.flat=0;
831 Weapon::throwingknifemodel.CalculateNormals(1);
832 //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1);
834 Weapon::swordmodel.load((char *)":Data:Models:sword.solid",1);
835 Weapon::swordmodel.Scale(.001,.001,.001);
836 //Weapon::swordmodel.Rotate(0,0,-90);
837 Weapon::swordmodel.Rotate(90,0,0);
838 Weapon::swordmodel.Rotate(0,90,0);
839 Weapon::swordmodel.Rotate(0,0,90);
840 Weapon::swordmodel.flat=1;
841 Weapon::swordmodel.CalculateNormals(1);
842 //Weapon::swordmodel.ScaleNormals(-1,-1,-1);
844 Weapon::staffmodel.load((char *)":Data:Models:staff.solid",1);
845 Weapon::staffmodel.Scale(.005,.005,.005);
846 //Weapon::staffmodel.Rotate(0,0,-90);
847 Weapon::staffmodel.Rotate(90,0,0);
848 Weapon::staffmodel.Rotate(0,90,0);
849 Weapon::staffmodel.Rotate(0,0,90);
850 Weapon::staffmodel.flat=1;
851 Weapon::staffmodel.CalculateNormals(1);
852 //Weapon::staffmodel.ScaleNormals(-1,-1,-1);
854 LoadTexture(":Data:Textures:shadow.png",&terrain.shadowtexture,0,1);
856 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture,0,1);
858 LoadTexture(":Data:Textures:break.png",&terrain.breaktexture,0,1);
860 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture2,0,1);
863 LoadTexture(":Data:Textures:footprint.png",&terrain.footprinttexture,0,1);
865 LoadTexture(":Data:Textures:bodyprint.png",&terrain.bodyprinttexture,0,1);
867 LoadTexture(":Data:Textures:hawk.png",&hawktexture,0,1);
869 LoadTexture(":Data:Textures:logo.png",&logotexture,0,1);
872 LoadTexture(":Data:Textures:cloud.png",&Sprite::cloudtexture,1,1);
873 LoadTexture(":Data:Textures:cloudimpact.png",&Sprite::cloudimpacttexture,1,1);
874 LoadTexture(":Data:Textures:bloodparticle.png",&Sprite::bloodtexture,1,1);
875 LoadTexture(":Data:Textures:snowflake.png",&Sprite::snowflaketexture,1,1);
876 LoadTexture(":Data:Textures:flame.png",&Sprite::flametexture,1,1);
877 LoadTexture(":Data:Textures:bloodflame.png",&Sprite::bloodflametexture,1,1);
878 LoadTexture(":Data:Textures:smoke.png",&Sprite::smoketexture,1,1);
879 LoadTexture(":Data:Textures:shine.png",&Sprite::shinetexture,1,0);
880 LoadTexture(":Data:Textures:splinter.png",&Sprite::splintertexture,1,1);
881 LoadTexture(":Data:Textures:leaf.png",&Sprite::leaftexture,1,1);
882 LoadTexture(":Data:Textures:tooth.png",&Sprite::toothtexture,1,1);
886 ReSizeGLScene(90,.01);
891 if(detail)kTextureSize=1024;
892 if(detail==1)kTextureSize=512;
893 if(detail==0)kTextureSize=256;
895 //Set up distant light
901 light.ambient[2]=.24;
904 light.location.z=-.2;
905 Normalise(&light.location);
915 texscale=.2/megascale/viewdistdetail;
916 terrain.scale=3*megascale*viewdistdetail;
918 viewer.x=terrain.size/2*terrain.scale;
919 viewer.z=terrain.size/2*terrain.scale;
921 hawk.load((char *)":Data:Models:hawk.solid",1);
922 hawk.Scale(.03,.03,.03);
924 hawk.CalculateNormals(0);
925 hawk.ScaleNormals(-1,-1,-1);
926 hawkcoords.x=terrain.size/2*terrain.scale-5-7;
927 hawkcoords.z=terrain.size/2*terrain.scale-5-7;
928 hawkcoords.y=terrain.getHeight(hawkcoords.x,hawkcoords.z)+25;
930 eye.load((char *)":Data:Models:eye.solid",1);
931 eye.Scale(.03,.03,.03);
932 eye.CalculateNormals(0);
934 cornea.load((char *)":Data:Models:cornea.solid",1);
935 cornea.Scale(.03,.03,.03);
936 cornea.CalculateNormals(0);
938 iris.load((char *)":Data:Models:iris.solid",1);
939 iris.Scale(.03,.03,.03);
940 iris.CalculateNormals(0);
942 LoadSave(":Data:Textures:Bloodfur.png",0,1,&bloodText[0],0);
943 LoadSave(":Data:Textures:Wolfbloodfur.png",0,1,&wolfbloodText[0],0);
952 rabbitcoords=player[0].coords;
953 rabbitcoords.y=terrain.getHeight(rabbitcoords.x,rabbitcoords.z);
956 //Fix knife stab, too lazy to do it manually
960 for(i=0;i<player[0].skeleton.num_joints;i++){
961 for(j=0;j<animation[knifesneakattackanim].numframes;j++){
962 animation[knifesneakattackanim].position[i][j]+=moveamount;
968 for(i=0;i<player[0].skeleton.num_joints;i++){
969 for(j=0;j<animation[knifesneakattackedanim].numframes;j++){
970 animation[knifesneakattackedanim].position[i][j]+=moveamount;
976 for(i=0;i<player[0].skeleton.num_joints;i++){
977 animation[dead1anim].position[i][1]=animation[dead1anim].position[i][0];
978 animation[dead2anim].position[i][1]=animation[dead2anim].position[i][0];
979 animation[dead3anim].position[i][1]=animation[dead3anim].position[i][0];
980 animation[dead4anim].position[i][1]=animation[dead4anim].position[i][0];
982 animation[dead1anim].speed[0]=0.001;
983 animation[dead2anim].speed[0]=0.001;
984 animation[dead3anim].speed[0]=0.001;
985 animation[dead4anim].speed[0]=0.001;
987 animation[dead1anim].speed[1]=0.001;
988 animation[dead2anim].speed[1]=0.001;
989 animation[dead3anim].speed[1]=0.001;
990 animation[dead4anim].speed[1]=0.001;
992 for(i=0;i<player[0].skeleton.num_joints;i++){
993 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
994 animation[swordsneakattackanim].position[i][j]+=moveamount;
998 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
999 animation[swordsneakattackanim].weapontarget[j]+=moveamount;
1004 for(i=0;i<player[0].skeleton.num_joints;i++){
1005 for(j=0;j<animation[swordsneakattackedanim].numframes;j++){
1006 animation[swordsneakattackedanim].position[i][j]+=moveamount;
1011 temptexdetail=texdetail;
1013 texdetail=temptexdetail;
1018 LoadScreenTexture();
1022 emit_sound_at(fireendsound);