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 int oldmainmenu;
64 extern bool visibleloading;
65 extern float flashamount,flashr,flashg,flashb;
66 extern int flashdelay;
67 extern int whichjointstartarray[26];
68 extern int whichjointendarray[26];
69 extern int difficulty;
70 extern float tintr,tintg,tintb;
71 extern float slomospeed;
72 extern bool gamestarted;
74 extern int numdialogues;
75 extern int numdialogueboxes[20];
76 extern int dialoguetype[20];
77 extern int dialogueboxlocation[20][20];
78 extern float dialogueboxcolor[20][20][3];
79 extern int dialogueboxsound[20][20];
80 extern char dialoguetext[20][20][128];
81 extern char dialoguename[20][20][64];
82 extern XYZ dialoguecamera[20][20];
83 extern float dialoguecamerarotation[20][20];
84 extern float dialoguecamerarotation2[20][20];
85 extern int indialogue;
86 extern int whichdialogue;
87 extern float dialoguetime;
89 extern float accountcampaignhighscore[10];
90 extern float accountcampaignfasttime[10];
91 extern float accountcampaignscore[10];
92 extern float accountcampaigntime[10];
94 extern int accountcampaignchoicesmade[10];
95 extern int accountcampaignchoices[10][5000];
97 void LOG(const std::string &fmt, ...)
99 // !!! FIXME: write me.
107 accountactive->endGame();
111 Account::saveFile(":Data:Users", accountactive);
115 LOG("Shutting down sound system...");
117 OPENAL_StopSound(OPENAL_ALL);
119 // this is causing problems on Linux, but we'll force an _exit() a little
120 // later in the shutdown process. --ryan.
123 for (int i=0; i < sounds_count; ++i)
125 OPENAL_Sample_Free(samp[i]);
138 void Game::LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha) {
139 *textureid = Texture::Load(fileName,mipmap,hasalpha);
142 void Game::LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize) {
143 *textureid = Texture::Load(fileName,mipmap,false,array,skinsize);
146 void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
153 LOG(std::string("Loading (S)...") + fileName);
156 float temptexdetail=texdetail;
158 //upload_image( fileName );
159 //LoadTGA( fileName );
161 // Converting file to something os specific
162 char * fixedFN = ConvertFileName(fileName);
165 unsigned char fileNamep[256];
166 CopyCStringToPascal(fixedFN, fileNamep);
168 upload_image( fileNamep ,0);
169 texdetail=temptexdetail;
173 bytesPerPixel=texture.bpp/8;
176 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
177 if((i+1)%4||bytesPerPixel==3){
178 array[tempnum]=texture.data[i];
185 bool Game::AddClothes(const char *fileName, GLubyte *array)
192 //upload_image( fileName );
193 //LoadTGA( fileName );
195 unsigned char fileNamep[256];
196 CopyCStringToPascal(fileName,fileNamep);
199 opened=upload_image( fileNamep ,1);
212 bytesPerPixel=texture.bpp/8;
216 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
217 if(bytesPerPixel==3)alphanum=255;
218 else if((i+1)%4==0)alphanum=texture.data[i];
220 if((i+1)%4||bytesPerPixel==3){
221 if((i%4)==0)texture.data[i]*=tintr;
222 if((i%4)==1)texture.data[i]*=tintg;
223 if((i%4)==2)texture.data[i]*=tintb;
224 array[tempnum]=(float)array[tempnum]*(1-alphanum/255)+(float)texture.data[i]*(alphanum/255);
234 //***************> ResizeGLScene() <******/
235 GLvoid Game::ReSizeGLScene(float fov, float pnear)
242 glViewport(0,0,screenwidth,screenheight);
244 glMatrixMode(GL_PROJECTION);
247 gluPerspective(fov,(GLfloat)screenwidth/(GLfloat)screenheight,pnear,viewdistance);
249 glMatrixMode(GL_MODELVIEW);
253 void Game::LoadingScreen()
255 static float loadprogress;
256 static AbsoluteTime time = {0,0};
257 static AbsoluteTime frametime = {0,0};
258 AbsoluteTime currTime = UpTime ();
259 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
261 if (0 > deltaTime) // if negative microseconds
262 deltaTime /= -1000000.0;
263 else // else milliseconds
266 multiplier=deltaTime;
267 if(multiplier<.001)multiplier=.001;
268 if(multiplier>10)multiplier=10;
270 frametime = currTime; // reset for next time interval
274 glClearColor(0,0,0,1);
275 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
278 loadtime+=multiplier*4;
280 loadprogress=loadtime;
281 if(loadprogress>100)loadprogress=100;
283 //loadprogress=abs(Random()%100);
287 glEnable(GL_TEXTURE_2D);
288 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
289 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
290 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
291 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
292 glDisable(GL_CULL_FACE);
293 glDisable(GL_LIGHTING);
295 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
296 glPushMatrix(); // Store The Projection Matrix
297 glLoadIdentity(); // Reset The Projection Matrix
298 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
299 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
300 glPushMatrix(); // Store The Modelview Matrix
301 glLoadIdentity(); // Reset The Modelview Matrix
302 glTranslatef(screenwidth/2,screenheight/2,0);
303 glScalef((float)screenwidth/2,(float)screenheight/2,1);
304 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
306 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
308 //glScalef(.25,.25,.25);
310 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
311 glVertex3f(-1, -1, 0.0f);
312 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
313 glVertex3f(1, -1, 0.0f);
314 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
315 glVertex3f(1, 1, 0.0f);
316 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
317 glVertex3f(-1, 1, 0.0f);
322 //glScalef(.25,.25,.25);
324 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
325 glVertex3f(-1, -1, 0.0f);
326 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
327 glVertex3f(1, -1, 0.0f);
328 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
329 glVertex3f(1, 1, 0.0f);
330 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
331 glVertex3f(-1, 1, 0.0f);
334 glDisable(GL_TEXTURE_2D);
335 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
336 glPopMatrix(); // Restore The Old Projection Matrix
337 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
338 glPopMatrix(); // Restore The Old Projection Matrix
342 glEnable(GL_TEXTURE_2D);
343 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
344 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
345 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
346 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
347 glDisable(GL_CULL_FACE);
348 glDisable(GL_LIGHTING);
350 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
351 glPushMatrix(); // Store The Projection Matrix
352 glLoadIdentity(); // Reset The Projection Matrix
353 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
354 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
355 glPushMatrix(); // Store The Modelview Matrix
356 glLoadIdentity(); // Reset The Modelview Matrix
357 glTranslatef(screenwidth/2,screenheight/2,0);
358 glScalef((float)screenwidth/2*(1.5-(loadprogress)/200),(float)screenheight/2*(1.5-(loadprogress)/200),1);
359 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
361 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
362 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
364 //glScalef(.25,.25,.25);
366 glTexCoord2f(0+.5,0+.5);
367 glVertex3f(-1, -1, 0.0f);
368 glTexCoord2f(1+.5,0+.5);
369 glVertex3f(1, -1, 0.0f);
370 glTexCoord2f(1+.5,1+.5);
371 glVertex3f(1, 1, 0.0f);
372 glTexCoord2f(0+.5,1+.5);
373 glVertex3f(-1, 1, 0.0f);
376 glDisable(GL_TEXTURE_2D);
377 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
378 glPopMatrix(); // Restore The Old Projection Matrix
379 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
380 glPopMatrix(); // Restore The Old Projection Matrix
384 glEnable(GL_TEXTURE_2D);
385 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
386 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
387 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
388 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
389 glDisable(GL_CULL_FACE);
390 glDisable(GL_LIGHTING);
392 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
393 glPushMatrix(); // Store The Projection Matrix
394 glLoadIdentity(); // Reset The Projection Matrix
395 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
396 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
397 glPushMatrix(); // Store The Modelview Matrix
398 glLoadIdentity(); // Reset The Modelview Matrix
399 glTranslatef(screenwidth/2,screenheight/2,0);
400 glScalef((float)screenwidth/2*(100+loadprogress)/100,(float)screenheight/2*(100+loadprogress)/100,1);
401 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
403 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,.4);
405 //glScalef(.25,.25,.25);
407 glTexCoord2f(0+.2,0+.8);
408 glVertex3f(-1, -1, 0.0f);
409 glTexCoord2f(1+.2,0+.8);
410 glVertex3f(1, -1, 0.0f);
411 glTexCoord2f(1+.2,1+.8);
412 glVertex3f(1, 1, 0.0f);
413 glTexCoord2f(0+.2,1+.8);
414 glVertex3f(-1, 1, 0.0f);
417 glDisable(GL_TEXTURE_2D);
418 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
419 glPopMatrix(); // Restore The Old Projection Matrix
420 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
421 glPopMatrix(); // Restore The Old Projection Matrix
428 if(flashamount>1)flashamount=1;
429 if(flashdelay<=0)flashamount-=multiplier;
431 if(flashamount<0)flashamount=0;
432 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
433 glDisable(GL_CULL_FACE);
434 glDisable(GL_LIGHTING);
435 glDisable(GL_TEXTURE_2D);
437 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
438 glPushMatrix(); // Store The Projection Matrix
439 glLoadIdentity(); // Reset The Projection Matrix
440 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
441 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
442 glPushMatrix(); // Store The Modelview Matrix
443 glLoadIdentity(); // Reset The Modelview Matrix
444 glScalef(screenwidth,screenheight,1);
445 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
447 glColor4f(flashr,flashg,flashb,flashamount);
449 glVertex3f(0, 0, 0.0f);
450 glVertex3f(256, 0, 0.0f);
451 glVertex3f(256, 256, 0.0f);
452 glVertex3f(0, 256, 0.0f);
454 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
455 glPopMatrix(); // Restore The Old Projection Matrix
456 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
457 glPopMatrix(); // Restore The Old Projection Matrix
458 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
459 glEnable(GL_CULL_FACE);
468 void Game::FadeLoadingScreen(float howmuch)
470 static float loadprogress;
474 glClearColor(0,0,0,1);
475 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
477 loadprogress=howmuch;
479 //loadprogress=abs(Random()%100);
483 //glEnable(GL_TEXTURE_2D);
484 glDisable(GL_TEXTURE_2D);
485 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
486 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
487 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
488 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
489 glDisable(GL_CULL_FACE);
490 glDisable(GL_LIGHTING);
492 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
493 glPushMatrix(); // Store The Projection Matrix
494 glLoadIdentity(); // Reset The Projection Matrix
495 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
496 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
497 glPushMatrix(); // Store The Modelview Matrix
498 glLoadIdentity(); // Reset The Modelview Matrix
499 glTranslatef(screenwidth/2,screenheight/2,0);
500 glScalef((float)screenwidth/2,(float)screenheight/2,1);
501 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
503 glColor4f(loadprogress/100,0,0,1);
505 //glScalef(.25,.25,.25);
508 glVertex3f(-1, -1, 0.0f);
510 glVertex3f(1, -1, 0.0f);
512 glVertex3f(1, 1, 0.0f);
514 glVertex3f(-1, 1, 0.0f);
517 glDisable(GL_TEXTURE_2D);
518 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
519 glPopMatrix(); // Restore The Old Projection Matrix
520 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
521 glPopMatrix(); // Restore The Old Projection Matrix
529 void Game::InitGame()
532 ProcessSerialNumber PSN;
533 ProcessInfoRec pinfo;
536 /* set up process serial number */
537 PSN.highLongOfPSN = 0;
538 PSN.lowLongOfPSN = kCurrentProcess;
539 /* set up info block */
540 pinfo.processInfoLength = sizeof(pinfo);
541 pinfo.processName = NULL;
542 pinfo.processAppSpec = &pspec;
543 /* grab the vrefnum and directory */
544 err = GetProcessInformation(&PSN, &pinfo);
546 vRefNum = pspec.vRefNum;
555 numchallengelevels=14;
557 accountactive=Account::loadFile(":Data:Users");
563 whichjointstartarray[0]=righthip;
564 whichjointendarray[0]=rightfoot;
566 whichjointstartarray[1]=righthip;
567 whichjointendarray[1]=rightankle;
569 whichjointstartarray[2]=righthip;
570 whichjointendarray[2]=rightknee;
572 whichjointstartarray[3]=rightknee;
573 whichjointendarray[3]=rightankle;
575 whichjointstartarray[4]=rightankle;
576 whichjointendarray[4]=rightfoot;
578 whichjointstartarray[5]=lefthip;
579 whichjointendarray[5]=leftfoot;
581 whichjointstartarray[6]=lefthip;
582 whichjointendarray[6]=leftankle;
584 whichjointstartarray[7]=lefthip;
585 whichjointendarray[7]=leftknee;
587 whichjointstartarray[8]=leftknee;
588 whichjointendarray[8]=leftankle;
590 whichjointstartarray[9]=leftankle;
591 whichjointendarray[9]=leftfoot;
593 whichjointstartarray[10]=abdomen;
594 whichjointendarray[10]=rightshoulder;
596 whichjointstartarray[11]=abdomen;
597 whichjointendarray[11]=rightelbow;
599 whichjointstartarray[12]=abdomen;
600 whichjointendarray[12]=rightwrist;
602 whichjointstartarray[13]=abdomen;
603 whichjointendarray[13]=righthand;
605 whichjointstartarray[14]=rightshoulder;
606 whichjointendarray[14]=rightelbow;
608 whichjointstartarray[15]=rightelbow;
609 whichjointendarray[15]=rightwrist;
611 whichjointstartarray[16]=rightwrist;
612 whichjointendarray[16]=righthand;
614 whichjointstartarray[17]=abdomen;
615 whichjointendarray[17]=leftshoulder;
617 whichjointstartarray[18]=abdomen;
618 whichjointendarray[18]=leftelbow;
620 whichjointstartarray[19]=abdomen;
621 whichjointendarray[19]=leftwrist;
623 whichjointstartarray[20]=abdomen;
624 whichjointendarray[20]=lefthand;
626 whichjointstartarray[21]=leftshoulder;
627 whichjointendarray[21]=leftelbow;
629 whichjointstartarray[22]=leftelbow;
630 whichjointendarray[22]=leftwrist;
632 whichjointstartarray[23]=leftwrist;
633 whichjointendarray[23]=lefthand;
635 whichjointstartarray[24]=abdomen;
636 whichjointendarray[24]=neck;
638 whichjointstartarray[25]=neck;
639 whichjointendarray[25]=head;
641 FadeLoadingScreen(0);
645 texture.data = ( GLubyte* )malloc( 1024*1024*4 );
647 int temptexdetail=texdetail;
649 text.LoadFontTexture(":Data:Textures:Font.png");
651 texdetail=temptexdetail;
653 FadeLoadingScreen(10);
665 LOG("Initializing sound system...");
670 extern bool cmdline(const char *cmd);
671 unsigned char rc = 0;
672 output = OPENAL_OUTPUT_ALSA; // Try alsa first...
673 if (cmdline("forceoss")) // ...but let user override that.
674 output = OPENAL_OUTPUT_OSS;
675 else if (cmdline("nosound"))
676 output = OPENAL_OUTPUT_NOSOUND;
678 OPENAL_SetOutput(output);
679 if ((rc = OPENAL_Init(44100, 32, 0)) == false)
681 // if we tried ALSA and failed, fall back to OSS.
682 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) )
685 output = OPENAL_OUTPUT_OSS;
686 OPENAL_SetOutput(output);
687 rc = OPENAL_Init(44100, 32, 0);
694 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
695 OPENAL_SetOutput(output);
696 rc = OPENAL_Init(44100, 32, 0);
699 OPENAL_Init(44100, 32, 0);
702 OPENAL_SetSFXMasterVolume((int)(volume*255));
706 emit_stream_np(stream_menutheme);
708 LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1);
710 LoadTexture(":Data:Textures:MapCircle.png",&Mapcircletexture,0,1);
711 LoadTexture(":Data:Textures:MapBox.png",&Mapboxtexture,0,1);
712 LoadTexture(":Data:Textures:MapArrow.png",&Maparrowtexture,0,1);
714 temptexdetail=texdetail;
715 if(texdetail>2)texdetail=2;
716 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
717 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
718 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
719 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
720 LoadTexture(":Data:Textures:Eyelid.png",&Mainmenuitems[4],0,1);
721 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[5],0,0);
722 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[6],0,0);
724 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
725 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
726 texdetail=temptexdetail;
728 FadeLoadingScreen(95);
739 newscreenwidth=screenwidth;
740 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);