#include "Game.h"
#include "openal_wrapper.h"
#include "Animation.h"
+#include "Texture.h"
extern float screenwidth,screenheight;
extern float viewdistance;
// !!! FIXME: write me.
}
-
void Game::Dispose()
{
LOGFUNC;
}
-void Game::LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha){
- textures.push_back(TextureInfo(fileName,textureid,mipmap,hasalpha));
- textures.back().load();
-}
-
-void Game::LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize){
- textures.push_back(TextureInfo(fileName,textureid,mipmap,array,skinsize));
- textures.back().load();
-}
-
-void Game::LoadTextureData(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::LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha) {
+ *textureid = Texture::Load(fileName,mipmap,hasalpha);
}
-void Game::LoadTextureSaveData(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize, bool reload)
-{
- 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;
- if(!reload)
- 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::LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize) {
+ *textureid = Texture::Load(fileName,mipmap,false,array,skinsize);
}
void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
LOG("Initializing sound system...");
- int output = -1;
-
#if PLATFORM_LINUX
+ int output = -1;
+
extern bool cmdline(const char *cmd);
unsigned char rc = 0;
output = OPENAL_OUTPUT_ALSA; // Try alsa first...
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);
+ LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[5],0,0);
+ LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[6],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;
FadeLoadingScreen(95);
}
-void Game::LoadScreenTexture(){
+void Game::LoadScreenTexture() {
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
if(!screentexture)
stillloading=1;
- //texture.data = ( GLubyte* )malloc( 1024*1024*4 );
-
for(i=0;i<maxplayers;i++)
{
if (glIsTexture(player[i].skeleton.drawmodel.textureptr))
player[i].skeleton.drawmodel.textureptr=0;;
}
- //temptexdetail=texdetail;
- //texdetail=1;
i=abs(Random()%4);
LoadTexture(":Data:Textures:fire.jpg",&loadscreentexture,1,0);
- //texdetail=temptexdetail;
temptexdetail=texdetail;
texdetail=1;
brightness=100;
-
-
if(detail==2){
texdetail=1;
}
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:knife.png",&Weapon::knifetextureptr,0,1);
+ LoadTexture(":Data:Textures:bloodknife.png",&Weapon::bloodknifetextureptr,0,1);
+ LoadTexture(":Data:Textures:lightbloodknife.png",&Weapon::lightbloodknifetextureptr,0,1);
+ LoadTexture(":Data:Textures:sword.jpg",&Weapon::swordtextureptr,1,0);
+ LoadTexture(":Data:Textures:Swordblood.jpg",&Weapon::bloodswordtextureptr,1,0);
+ LoadTexture(":Data:Textures:Swordbloodlight.jpg",&Weapon::lightbloodswordtextureptr,1,0);
+ LoadTexture(":Data:Textures:Staff.jpg",&Weapon::stafftextureptr,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);
+
LoadTexture(":Data:Textures:shadow.png",&terrain.shadowtexture,0,1);
LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture,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);
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;
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);
mainmenu=0;
firstload=0;
- //if(targetlevel!=7)
- Loadlevel(targetlevel);
-
rabbitcoords=player[0].coords;
rabbitcoords.y=terrain.getHeight(rabbitcoords.x,rabbitcoords.z);
LoadingScreen();
- //if(ismotionblur){
if(!screentexture){
LoadScreenTexture();
}