X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameInitDispose.cpp;h=5d6f579302b30f4e2363124dc54bfa02626156c2;hb=26debbd380c6922e5a0b60d99567c6374a4fef9a;hp=ba38ecbcadcc2ebb940ea895ac56b4a42ca114a3;hpb=c44a844d9305c4f1f7dd0479e4a3af3e90b96a1b;p=lugaru.git diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index ba38ecb..5d6f579 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -28,7 +28,6 @@ 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; @@ -60,7 +59,6 @@ extern TGAImageRec texture; extern short vRefNum; extern long dirID; extern int mainmenu; -extern int oldmainmenu; extern bool visibleloading; extern float flashamount,flashr,flashg,flashb; extern int flashdelay; @@ -80,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; @@ -99,16 +97,16 @@ void LOG(const std::string &fmt, ...) // !!! FIXME: write me. } -void Game::Dispose() +void Dispose() { 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); //textures.clear(); @@ -134,16 +132,35 @@ void Game::Dispose() #endif } - -void Game::LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha) { - *textureid = Texture::Load(fileName,mipmap,hasalpha); +void Game::newGame(){ + text = new Text(); + skybox = new SkyBox(); } -void Game::LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize) { - *textureid = Texture::Load(fileName,mipmap,false,array,skinsize); +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::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; @@ -182,53 +199,6 @@ void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte } } -bool Game::AddClothes(const char *fileName, GLubyte *array) -{ - 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() <******/ @@ -285,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 @@ -340,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 @@ -382,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 @@ -465,7 +435,7 @@ void Game::LoadingScreen() } } -void Game::FadeLoadingScreen(float howmuch) +void FadeLoadingScreen(float howmuch) { static float loadprogress; @@ -526,6 +496,8 @@ void Game::FadeLoadingScreen(float howmuch) } +extern bool cmdline(const char *cmd); + void Game::InitGame() { #if PLATFORM_MACOSX @@ -550,8 +522,6 @@ void Game::InitGame() LOGFUNC; - autocam=0; - numchallengelevels=14; accountactive=Account::loadFile(":Data:Users"); @@ -667,7 +637,6 @@ void Game::InitGame() #if PLATFORM_LINUX int output = -1; - extern bool cmdline(const char *cmd); unsigned char rc = 0; output = OPENAL_OUTPUT_ALSA; // Try alsa first... if (cmdline("forceoss")) // ...but let user override that. @@ -705,21 +674,21 @@ void Game::InitGame() 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:Eyelid.png",&Mainmenuitems[4],0,1); - LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[5],0,0); - LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[6],0,0); + 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 @@ -733,30 +702,32 @@ 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(!screentexture) - glGenTextures( 1, &screentexture ); + 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, screentexture); + 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; @@ -766,23 +737,17 @@ void Game::LoadStuff() LOGFUNC; - visibleloading=1; - loadtime=0; stillloading=1; for(i=0;i