X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameInitDispose.cpp;h=5d6f579302b30f4e2363124dc54bfa02626156c2;hb=e724a1c4bd1f94b55ac1331bedd32c51eebb08d9;hp=e7889a4d5cac70e830513c4193769a74488726e4;hpb=bd635bf9468562568574e88f543b4e635c845918;p=lugaru.git diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index e7889a4..5d6f579 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -22,25 +22,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Game.h" #include "openal_wrapper.h" #include "Animation.h" +#include "Texture.h" extern float screenwidth,screenheight; extern float viewdistance; extern XYZ viewer; extern XYZ lightlocation; -extern float lightambient[3],lightbrightness[3]; extern float fadestart; extern float texscale; extern float gravity; extern Light light; extern Skeleton testskeleton; extern int numsounds; -extern int channels[100]; extern Terrain terrain; //extern Sprites sprites; extern int kTextureSize; extern float texdetail; extern float realtexdetail; -extern float terraindetail; extern float volume; extern Objects objects; extern int detail; @@ -51,9 +49,6 @@ extern bool ismotionblur; extern bool trilinear; extern bool osx; extern bool musictoggle; -extern Weapons weapons; -extern Person player[maxplayers]; -extern int numplayers; extern int environment; extern bool ambientsound; extern float multiplier; @@ -64,9 +59,7 @@ extern TGAImageRec texture; extern short vRefNum; extern long dirID; extern int mainmenu; -extern int oldmainmenu; extern bool visibleloading; -extern int loadscreencolor; extern float flashamount,flashr,flashg,flashb; extern int flashdelay; extern int whichjointstartarray[26]; @@ -74,7 +67,6 @@ extern int whichjointendarray[26]; extern int difficulty; extern float tintr,tintg,tintb; extern float slomospeed; -extern char mapname[256]; extern bool gamestarted; extern int numdialogues; @@ -86,8 +78,8 @@ extern int dialogueboxsound[20][20]; extern char dialoguetext[20][20][128]; extern char dialoguename[20][20][64]; extern XYZ dialoguecamera[20][20]; -extern float dialoguecamerarotation[20][20]; -extern float dialoguecamerarotation2[20][20]; +extern float dialoguecamerayaw[20][20]; +extern float dialoguecamerapitch[20][20]; extern int indialogue; extern int whichdialogue; extern float dialoguetime; @@ -100,39 +92,23 @@ extern float accountcampaigntime[10]; extern int accountcampaignchoicesmade[10]; extern int accountcampaignchoices[10][5000]; -extern OPENAL_STREAM * strm[20]; - -extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); -extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); - void LOG(const std::string &fmt, ...) { // !!! FIXME: write me. } - -Game::TextureList Game::textures; - -void Game::Dispose() +void Dispose() { - int i,j; - LOGFUNC; - if(endgame==2){ - accountactive->endGame(); - endgame=0; + if(Game::endgame==2){ + Game::accountactive->endGame(); + Game::endgame=0; } - Account::saveFile(":Data:Users", accountactive); + Account::saveFile(":Data:Users", Game::accountactive); - TexIter it = textures.begin(); - for (; it != textures.end(); ++it) - { - if (glIsTexture(it->second)) - glDeleteTextures(1, &it->second); - } - textures.clear(); + //textures.clear(); LOG("Shutting down sound system..."); @@ -141,19 +117,12 @@ void Game::Dispose() // this is causing problems on Linux, but we'll force an _exit() a little // later in the shutdown process. --ryan. #if !PLATFORM_LINUX -#define streamcount 20 -#define samplecount 100 - for (i=0; i < samplecount; ++i) + for (int i=0; i < sounds_count; ++i) { OPENAL_Sample_Free(samp[i]); } - for (i=0; i < streamcount; ++i) - { - OPENAL_Stream_Close(strm[i]); - } - OPENAL_Close(); if (texture.data) { @@ -163,132 +132,35 @@ void Game::Dispose() #endif } - -void Game::LoadSounds() -{ - LOGFUNC; - - LOG(std::string("Loading sounds...")); - - OPENAL_3D_SetDopplerFactor(0); - - OPENAL_SetSFXMasterVolume((int)(volume*255)); - - if(visibleloading){LoadingScreen(); loadscreencolor=5;} - loadAllSounds(); +void Game::newGame(){ + text = new Text(); + skybox = new SkyBox(); } -void Game::LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha) -{ - GLuint type; - - LOGFUNC; - - LOG(std::string("Loading texture...") + fileName); - - // Fix filename so that is os appropreate - char * fixedFN = ConvertFileName(fileName); - - unsigned char fileNamep[256]; - CopyCStringToPascal(fixedFN, fileNamep); - //Load Image - upload_image( fileNamep ,hasalpha); - -// std::string fname(fileName); -// std::transform(fname.begin(), fname.end(), tolower); -// TexIter it = textures.find(fname); - - //Is it valid? - if(1==1) - //if(textures.end() == it) - { - //Alpha channel? - if ( texture.bpp == 24 ) - type = GL_RGB; - else - type = GL_RGBA; - - glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - - if(!*textureid) - glGenTextures( 1, textureid ); - glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); - - glBindTexture( GL_TEXTURE_2D, *textureid); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - if(trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); - if(!trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); - if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - - gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data ); - } +void Game::deleteGame(){ + if(skybox) delete skybox; + if(text) delete text; + terraintexture.destroy(); + terraintexture2.destroy(); + cursortexture.destroy(); + Maparrowtexture.destroy(); + Mapboxtexture.destroy(); + Mapcircletexture.destroy(); + hawktexture.destroy(); + loadscreentexture.destroy(); + + for(int i=0;i<10;i++) + Mainmenuitems[i].destroy(); + + glDeleteTextures(1,&screentexture); + glDeleteTextures(1,&screentexture2); + + Dispose(); } -void Game::LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize) -{ - GLuint type; - int i; - int bytesPerPixel; - - LOGFUNC; - LOG(std::string("Loading texture (S)...") + fileName); - //Load Image - unsigned char fileNamep[256]; - CopyCStringToPascal(ConvertFileName(fileName), fileNamep); - //Load Image - upload_image( fileNamep ,0); - //LoadTGA( fileName ); - -// std::string fname(fileName); -// std::transform(fname.begin(), fname.end(), tolower); -// TexIter it = textures.find(fname); - - //Is it valid? - if(1==1) - //if(textures.end() == it) - { - bytesPerPixel=texture.bpp/8; - - //Alpha channel? - if ( texture.bpp == 24 ) - type = GL_RGB; - else - type = GL_RGBA; - - glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - - if(!*textureid)glGenTextures( 1, textureid ); - glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); - - glBindTexture( GL_TEXTURE_2D, *textureid); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - if(trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); - if(!trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); - if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - - int tempnum=0; - for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){ - if((i+1)%4||type==GL_RGB){ - array[tempnum]=texture.data[i]; - tempnum++; - } - } - - *skinsize=texture.sizeX; - - gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, GL_RGB, GL_UNSIGNED_BYTE, array ); - -// textures.insert(std::make_pair(fname, *textureid)); - } -// else -// { -// *textureid = it->second; -// } -} - -void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize) +void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize) { int i; int bytesPerPixel; @@ -327,53 +199,6 @@ void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte } } -bool Game::AddClothes(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize) -{ - int i; - int bytesPerPixel; - - LOGFUNC; - - //upload_image( fileName ); - //LoadTGA( fileName ); - //Load Image - unsigned char fileNamep[256]; - CopyCStringToPascal(fileName,fileNamep); - //Load Image - bool opened; - opened=upload_image( fileNamep ,1); - - float alphanum; - //Is it valid? - if(opened){ - if(tintr>1)tintr=1; - if(tintg>1)tintg=1; - if(tintb>1)tintb=1; - - if(tintr<0)tintr=0; - if(tintg<0)tintg=0; - if(tintb<0)tintb=0; - - bytesPerPixel=texture.bpp/8; - - int tempnum=0; - alphanum=255; - for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){ - if(bytesPerPixel==3)alphanum=255; - else if((i+1)%4==0)alphanum=texture.data[i]; - //alphanum/=2; - if((i+1)%4||bytesPerPixel==3){ - if((i%4)==0)texture.data[i]*=tintr; - if((i%4)==1)texture.data[i]*=tintg; - if((i%4)==2)texture.data[i]*=tintb; - array[tempnum]=(float)array[tempnum]*(1-alphanum/255)+(float)texture.data[i]*(alphanum/255); - tempnum++; - } - } - } - else return 0; - return 1; -} //***************> ResizeGLScene() <******/ @@ -397,7 +222,7 @@ GLvoid Game::ReSizeGLScene(float fov, float pnear) void Game::LoadingScreen() { - static float loadprogress,minprogress,maxprogress; + static float loadprogress; static AbsoluteTime time = {0,0}; static AbsoluteTime frametime = {0,0}; AbsoluteTime currTime = UpTime (); @@ -414,7 +239,6 @@ void Game::LoadingScreen() if(multiplier>.05){ frametime = currTime; // reset for next time interval - float size=1; glLoadIdentity(); //Clear to black glClearColor(0,0,0,1); @@ -431,7 +255,7 @@ void Game::LoadingScreen() //Background glEnable(GL_TEXTURE_2D); - glBindTexture( GL_TEXTURE_2D, loadscreentexture); + loadscreentexture.bind(); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); glDisable(GL_DEPTH_TEST); // Disables Depth Testing @@ -450,14 +274,6 @@ void Game::LoadingScreen() 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); @@ -494,7 +310,7 @@ void Game::LoadingScreen() glDepthMask(1); glEnable(GL_TEXTURE_2D); - glBindTexture( GL_TEXTURE_2D, loadscreentexture); + loadscreentexture.bind(); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); glDisable(GL_DEPTH_TEST); // Disables Depth Testing @@ -514,13 +330,6 @@ void Game::LoadingScreen() 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); @@ -543,7 +352,7 @@ void Game::LoadingScreen() glDepthMask(1); glEnable(GL_TEXTURE_2D); - glBindTexture( GL_TEXTURE_2D, loadscreentexture); + loadscreentexture.bind(); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); glDisable(GL_DEPTH_TEST); // Disables Depth Testing @@ -584,15 +393,6 @@ void Game::LoadingScreen() 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; @@ -632,15 +432,13 @@ void Game::LoadingScreen() } swap_gl_buffers(); - loadscreencolor=0; } } -void Game::FadeLoadingScreen(float howmuch) +void FadeLoadingScreen(float howmuch) { - static float loadprogress,minprogress,maxprogress; + static float loadprogress; - float size=1; glLoadIdentity(); //Clear to black glClearColor(0,0,0,1); @@ -673,13 +471,6 @@ void Game::FadeLoadingScreen(float howmuch) 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); @@ -701,20 +492,12 @@ void Game::FadeLoadingScreen(float howmuch) 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; } +extern bool cmdline(const char *cmd); + void Game::InitGame() { #if PLATFORM_MACOSX @@ -739,10 +522,6 @@ void Game::InitGame() LOGFUNC; - autocam=0; - - int i,j; - numchallengelevels=14; accountactive=Account::loadFile(":Data:Users"); @@ -837,38 +616,27 @@ void Game::InitGame() int temptexdetail=texdetail; texdetail=1; - text.LoadFontTexture(":Data:Textures:Font.png"); - text.BuildFont(); + 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; - } - - memset(channels, 0xff, sizeof(channels)); - for (int it = 0; it < 20; ++it) - { - strm[it] = NULL; } LOG("Initializing sound system..."); - int output = -1; - #if PLATFORM_LINUX - extern bool cmdline(const char *cmd); + int output = -1; + unsigned char rc = 0; output = OPENAL_OUTPUT_ALSA; // Try alsa first... if (cmdline("forceoss")) // ...but let user override that. @@ -901,78 +669,31 @@ void Game::InitGame() #endif OPENAL_SetSFXMasterVolume((int)(volume*255)); + loadAllSounds(); - strm[stream_music3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:music3.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=0;} - OPENAL_Stream_SetMode(strm[stream_music3], OPENAL_LOOP_NORMAL); - - if(musictoggle){ -// PlaySoundEx( stream_music3, strm[stream_music3], NULL, true); - PlayStreamEx(stream_music3, strm[stream_music3], 0, true); - OPENAL_SetPaused(channels[stream_music3], false); - OPENAL_SetVolume(channels[stream_music3], 256); - } - - FadeLoadingScreen(20); - - if(ambientsound){ - strm[stream_wind] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:wind.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Stream_SetMode(strm[stream_wind], OPENAL_LOOP_NORMAL); - - FadeLoadingScreen(30); - - strm[stream_desertambient] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:desertambient.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Stream_SetMode(strm[stream_desertambient], OPENAL_LOOP_NORMAL); - } - - FadeLoadingScreen(40); - - strm[stream_firesound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:fire.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Stream_SetMode(strm[stream_firesound], OPENAL_LOOP_NORMAL); - - FadeLoadingScreen(50); - - //if(musictoggle){ - strm[stream_music1grass] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:music1grass.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=1;} - OPENAL_Stream_SetMode(strm[stream_music1grass], OPENAL_LOOP_NORMAL); - - strm[stream_music1snow] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:music1snow.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=2;} - OPENAL_Stream_SetMode(strm[stream_music1snow], OPENAL_LOOP_NORMAL); - - FadeLoadingScreen(60); - - strm[stream_music1desert] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:music1desert.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=3;} - OPENAL_Stream_SetMode(strm[stream_music1desert], OPENAL_LOOP_NORMAL); - - FadeLoadingScreen(80); - strm[stream_music2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:music2.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=4;} - OPENAL_Stream_SetMode(strm[stream_music2], OPENAL_LOOP_NORMAL); - - //} - - - FadeLoadingScreen(90); - + if(musictoggle) + emit_stream_np(stream_menutheme); - LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1); + cursortexture.load(":Data:Textures:Cursor.png",0,1); - LoadTexture(":Data:Textures:MapCircle.png",&Mapcircletexture,0,1); - LoadTexture(":Data:Textures:MapBox.png",&Mapboxtexture,0,1); - LoadTexture(":Data:Textures:MapArrow.png",&Maparrowtexture,0,1); + Mapcircletexture.load(":Data:Textures:MapCircle.png",0,1); + Mapboxtexture.load(":Data:Textures:MapBox.png",0,1); + Maparrowtexture.load(":Data:Textures:MapArrow.png",0,1); temptexdetail=texdetail; if(texdetail>2)texdetail=2; - LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0); - LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0); - LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0); - LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0); - LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); - LoadTexture(":Data:Textures:Eyelid.png",&Mainmenuitems[4],0,1); + Mainmenuitems[0].load(":Data:Textures:Lugaru.png",0,0); + Mainmenuitems[1].load(":Data:Textures:Newgame.png",0,0); + Mainmenuitems[2].load(":Data:Textures:Options.png",0,0); + Mainmenuitems[3].load(":Data:Textures:Quit.png",0,0); + Mainmenuitems[4].load(":Data:Textures:Eyelid.png",0,1); + Mainmenuitems[5].load(":Data:Textures:Resume.png",0,0); + Mainmenuitems[6].load(":Data:Textures:Endgame.png",0,0); + //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1); + //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that texdetail=temptexdetail; - loaddistrib=0; - anim=0; - FadeLoadingScreen(95); @@ -981,55 +702,57 @@ void Game::InitGame() stillloading=0; firstload=0; - oldmainmenu=0; newdetail=detail; newscreenwidth=screenwidth; newscreenheight=screenheight; + + LoadMenu(); } +void Game::LoadScreenTexture() { + glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); + + if(!Game::screentexture) + glGenTextures( 1, &Game::screentexture ); + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); + + + glEnable(GL_TEXTURE_2D); + glBindTexture( GL_TEXTURE_2D, Game::screentexture); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0); +} + +//TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h void Game::LoadStuff() { static float temptexdetail; static float viewdistdetail; - static int i,j,texsize; + static int i,j; float megascale =1; LOGFUNC; - visibleloading=1; - - /*musicvolume[3]=512; - PlaySoundEx( music4, samp[music4], NULL, true); - OPENAL_SetPaused(channels[music4], false); - OPENAL_SetVolume(channels[music4], 512); - */ loadtime=0; stillloading=1; - //texture.data = ( GLubyte* )malloc( 1024*1024*4 ); - for(i=0;iLoadFontTexture(":Data:Textures:Font.png"); + text->BuildFont(); texdetail=temptexdetail; numsounds=71; @@ -1037,148 +760,94 @@ void Game::LoadStuff() viewdistdetail=2; viewdistance=50*megascale*viewdistdetail; - brightness=100; - - - if(detail==2){ texdetail=1; - terraindetail=1; } if(detail==1){ texdetail=2; - terraindetail=1; } if(detail==0){ texdetail=4; - terraindetail=1; - //terraindetail=2; } realtexdetail=texdetail; - /*texdetail/=4; - if(texdetail<1)texdetail=1; - realtexdetail=texdetail*4; - */ numplayers=1; - - /*LoadTexture(":Data:Textures:snow.png",&terraintexture,1); - - LoadTexture(":Data:Textures:rock.png",&terraintexture2,1); - - LoadTexture(":Data:Textures:detail.png",&terraintexture3,1); - */ - - LOG("Loading weapon data..."); - LoadTexture(":Data:Textures:knife.png",&weapons.knifetextureptr,0,1); - LoadTexture(":Data:Textures:bloodknife.png",&weapons.bloodknifetextureptr,0,1); - LoadTexture(":Data:Textures:lightbloodknife.png",&weapons.lightbloodknifetextureptr,0,1); - LoadTexture(":Data:Textures:sword.jpg",&weapons.swordtextureptr,1,0); - LoadTexture(":Data:Textures:Swordblood.jpg",&weapons.bloodswordtextureptr,1,0); - LoadTexture(":Data:Textures:Swordbloodlight.jpg",&weapons.lightbloodswordtextureptr,1,0); - LoadTexture(":Data:Textures:Staff.jpg",&weapons.stafftextureptr,1,0); - - weapons.throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1); - weapons.throwingknifemodel.Scale(.001,.001,.001); - //weapons.throwingknifemodel.Rotate(0,0,-90); - weapons.throwingknifemodel.Rotate(90,0,0); - weapons.throwingknifemodel.Rotate(0,90,0); - weapons.throwingknifemodel.flat=0; - weapons.throwingknifemodel.CalculateNormals(1); - //weapons.throwingknifemodel.ScaleNormals(-1,-1,-1); - - weapons.swordmodel.load((char *)":Data:Models:sword.solid",1); - weapons.swordmodel.Scale(.001,.001,.001); - //weapons.swordmodel.Rotate(0,0,-90); - weapons.swordmodel.Rotate(90,0,0); - weapons.swordmodel.Rotate(0,90,0); - weapons.swordmodel.Rotate(0,0,90); - weapons.swordmodel.flat=1; - weapons.swordmodel.CalculateNormals(1); - //weapons.swordmodel.ScaleNormals(-1,-1,-1); - - weapons.staffmodel.load((char *)":Data:Models:staff.solid",1); - weapons.staffmodel.Scale(.005,.005,.005); - //weapons.staffmodel.Rotate(0,0,-90); - weapons.staffmodel.Rotate(90,0,0); - weapons.staffmodel.Rotate(0,90,0); - weapons.staffmodel.Rotate(0,0,90); - weapons.staffmodel.flat=1; - weapons.staffmodel.CalculateNormals(1); - //weapons.staffmodel.ScaleNormals(-1,-1,-1); - - //temptexdetail=texdetail; - //if(texdetail>4)texdetail=4; - LoadTexture(":Data:Textures:shadow.png",&terrain.shadowtexture,0,1); - - LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture,0,1); - - LoadTexture(":Data:Textures:break.png",&terrain.breaktexture,0,1); - - LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture2,0,1); - - - LoadTexture(":Data:Textures:footprint.png",&terrain.footprinttexture,0,1); - - LoadTexture(":Data:Textures:bodyprint.png",&terrain.bodyprinttexture,0,1); - - /*LoadTexture(":Data:Textures:cloud.png",&Sprite::cloudtexture,1); - - LoadTexture(":Data:Textures:cloudimpact.png",&Sprite::cloudimpacttexture,1); - - LoadTexture(":Data:Textures:bloodparticle.png",&Sprite::bloodtexture,1); - - LoadTexture(":Data:Textures:snowflake.png",&Sprite::snowflaketexture,1); - - LoadTexture(":Data:Textures:flame.png",&Sprite::flametexture,1); - - LoadTexture(":Data:Textures:smoke.png",&Sprite::smoketexture,1); - //texdetail=temptexdetail; - LoadTexture(":Data:Textures:shine.png",&Sprite::shinetexture,1);*/ - - - - LoadTexture(":Data:Textures:hawk.png",&hawktexture,0,1); - - LoadTexture(":Data:Textures:logo.png",&logotexture,0,1); - - - //LoadTexture(":Data:Textures:box.jpg",&objects.boxtextureptr,1,0); - - - LoadTexture(":Data:Textures:cloud.png",&Sprite::cloudtexture,1,1); - LoadTexture(":Data:Textures:cloudimpact.png",&Sprite::cloudimpacttexture,1,1); - LoadTexture(":Data:Textures:bloodparticle.png",&Sprite::bloodtexture,1,1); - LoadTexture(":Data:Textures:snowflake.png",&Sprite::snowflaketexture,1,1); - LoadTexture(":Data:Textures:flame.png",&Sprite::flametexture,1,1); - LoadTexture(":Data:Textures:bloodflame.png",&Sprite::bloodflametexture,1,1); - LoadTexture(":Data:Textures:smoke.png",&Sprite::smoketexture,1,1); - LoadTexture(":Data:Textures:shine.png",&Sprite::shinetexture,1,0); - LoadTexture(":Data:Textures:splinter.png",&Sprite::splintertexture,1,1); - LoadTexture(":Data:Textures:leaf.png",&Sprite::leaftexture,1,1); - LoadTexture(":Data:Textures:tooth.png",&Sprite::toothtexture,1,1); - - rotation=0; - rotation2=0; + Weapon::knifetextureptr.load(":Data:Textures:knife.png",0,1); + Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png",0,1); + Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png",0,1); + Weapon::swordtextureptr.load(":Data:Textures:sword.jpg",1,0); + Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg",1,0); + Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg",1,0); + Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg",1,0); + + Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1); + Weapon::throwingknifemodel.Scale(.001,.001,.001); + //Weapon::throwingknifemodel.Rotate(0,0,-90); + Weapon::throwingknifemodel.Rotate(90,0,0); + Weapon::throwingknifemodel.Rotate(0,90,0); + Weapon::throwingknifemodel.flat=0; + Weapon::throwingknifemodel.CalculateNormals(1); + //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1); + + Weapon::swordmodel.load((char *)":Data:Models:sword.solid",1); + Weapon::swordmodel.Scale(.001,.001,.001); + //Weapon::swordmodel.Rotate(0,0,-90); + Weapon::swordmodel.Rotate(90,0,0); + Weapon::swordmodel.Rotate(0,90,0); + Weapon::swordmodel.Rotate(0,0,90); + Weapon::swordmodel.flat=1; + Weapon::swordmodel.CalculateNormals(1); + //Weapon::swordmodel.ScaleNormals(-1,-1,-1); + + Weapon::staffmodel.load((char *)":Data:Models:staff.solid",1); + Weapon::staffmodel.Scale(.005,.005,.005); + //Weapon::staffmodel.Rotate(0,0,-90); + Weapon::staffmodel.Rotate(90,0,0); + Weapon::staffmodel.Rotate(0,90,0); + Weapon::staffmodel.Rotate(0,0,90); + Weapon::staffmodel.flat=1; + Weapon::staffmodel.CalculateNormals(1); + //Weapon::staffmodel.ScaleNormals(-1,-1,-1); + + terrain.shadowtexture.load(":Data:Textures:shadow.png",0,1); + terrain.bloodtexture.load(":Data:Textures:blood.png",0,1); + terrain.breaktexture.load(":Data:Textures:break.png",0,1); + terrain.bloodtexture2.load(":Data:Textures:blood.png",0,1); + + + terrain.footprinttexture.load(":Data:Textures:footprint.png",0,1); + terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png",0,1); + hawktexture.load(":Data:Textures:hawk.png",0,1); + + + Sprite::cloudtexture.load(":Data:Textures:cloud.png",1,1); + Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png",1,1); + Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png",1,1); + Sprite::snowflaketexture.load(":Data:Textures:snowflake.png",1,1); + Sprite::flametexture.load(":Data:Textures:flame.png",1,1); + Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png",1,1); + Sprite::smoketexture.load(":Data:Textures:smoke.png",1,1); + Sprite::shinetexture.load(":Data:Textures:shine.png",1,0); + Sprite::splintertexture.load(":Data:Textures:splinter.png",1,1); + Sprite::leaftexture.load(":Data:Textures:leaf.png",1,1); + Sprite::toothtexture.load(":Data:Textures:tooth.png",1,1); + + yaw=0; + pitch=0; ReSizeGLScene(90,.01); viewer=0; - - if(detail)kTextureSize=1024; if(detail==1)kTextureSize=512; if(detail==0)kTextureSize=256; - - - //drawmode=motionblurmode; - + //Set up distant light light.color[0]=.95; light.color[1]=.95; @@ -1200,7 +869,7 @@ void Game::LoadStuff() gravity=-10; texscale=.2/megascale/viewdistdetail; - terrain.scale=3*megascale*terraindetail*viewdistdetail; + terrain.scale=3*megascale*viewdistdetail; viewer.x=terrain.size/2*terrain.scale; viewer.z=terrain.size/2*terrain.scale; @@ -1214,7 +883,6 @@ void Game::LoadStuff() hawkcoords.z=terrain.size/2*terrain.scale-5-7; hawkcoords.y=terrain.getHeight(hawkcoords.x,hawkcoords.z)+25; - eye.load((char *)":Data:Models:eye.solid",1); eye.Scale(.03,.03,.03); eye.CalculateNormals(0); @@ -1236,12 +904,6 @@ void Game::LoadStuff() mainmenu=0; firstload=0; - //if(targetlevel!=7) - Loadlevel(targetlevel); - - - rabbitcoords=player[0].coords; - rabbitcoords.y=terrain.getHeight(rabbitcoords.x,rabbitcoords.z); loadAllAnimations(); //Fix knife stab, too lazy to do it manually @@ -1254,7 +916,6 @@ void Game::LoadStuff() } } - loadscreencolor=4; LoadingScreen(); for(i=0;i