int dialoguegonethrough[20];
namespace Game{
- GLuint terraintexture = 0;
- GLuint terraintexture2 = 0;
- GLuint terraintexture3 = 0;
+ Texture terraintexture;
+ Texture terraintexture2;
+ Texture loadscreentexture;
+ Texture Maparrowtexture;
+ Texture Mapboxtexture;
+ Texture Mapcircletexture;
+ Texture cursortexture;
GLuint screentexture = 0;
GLuint screentexture2 = 0;
- GLuint logotexture = 0;
- GLuint loadscreentexture = 0;
- GLuint Maparrowtexture = 0;
- GLuint Mapboxtexture = 0;
- GLuint Mapcircletexture = 0;
- GLuint cursortexture = 0;
- GLuint Mainmenuitems[10] = {};
+ Texture Mainmenuitems[10];
int selected = 0;
int keyselect = 0;
bool cameramode = 0;
bool firstload = 0;
- GLuint hawktexture = 0;
+ Texture hawktexture;
float hawkyaw = 0;
float hawkcalldelay = 0;
float leveltime = 0;
#include "Stereo.h"
#include "Account.h"
#include "Sounds.h"
+#include "Texture.h"
#define NB_CAMPAIGN_MENU_ITEM 7
namespace Game {
- extern GLuint terraintexture;
- extern GLuint terraintexture2;
- extern GLuint terraintexture3;
+ extern Texture terraintexture;
+ extern Texture terraintexture2;
+ extern Texture loadscreentexture;
+ extern Texture Maparrowtexture;
+ extern Texture Mapboxtexture;
+ extern Texture Mapcircletexture;
+ extern Texture cursortexture;
extern GLuint screentexture;
extern GLuint screentexture2;
- extern GLuint logotexture;
- extern GLuint loadscreentexture;
- extern GLuint Maparrowtexture;
- extern GLuint Mapboxtexture;
- extern GLuint Mapcircletexture;
- extern GLuint cursortexture;
- extern GLuint Mainmenuitems[10];
+ extern Texture Mainmenuitems[10];
extern int selected;
extern int keyselect;
extern Model hawk;
extern XYZ hawkcoords;
extern XYZ realhawkcoords;
- extern GLuint hawktexture;
+ extern Texture hawktexture;
extern float hawkyaw;
extern float hawkcalldelay;
void newGame();
void deleteGame();
- void LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha);
- void LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
void InitGame();
void LoadStuff();
+ void LoadScreenTexture();
void LoadingScreen();
int DrawGLScene(StereoSide side);
void LoadMenu();
glDisable(GL_BLEND);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glBindTexture( GL_TEXTURE_2D, terraintexture);
+ terraintexture.bind();
terrain.draw(0);
- glBindTexture( GL_TEXTURE_2D, terraintexture2);
+ terraintexture2.bind();
terrain.draw(1);
//glBindTexture( GL_TEXTURE_2D, terraintexture3);
//glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
if(objects.type[i]==treetrunktype){
distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
if(distcheck<mapviewdist){
- glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
+ Mapcircletexture.bind();
glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
glPushMatrix();
glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
if(objects.type[i]==boxtype){
distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
if(distcheck<mapviewdist){
- glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
+ Mapboxtexture.bind();
glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
glPushMatrix();
glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
}
}
if(editorenabled){
- glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
+ Mapcircletexture.bind();
for(i=0;i<numboundaries;i++){
glColor4f(0,0,0,opac/3);
glPushMatrix();
distcheck=findDistancefast(&player[0].coords,&player[i].coords);
if(distcheck<mapviewdist){
glPushMatrix();
- glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
+ Maparrowtexture.bind();
if(i==0)glColor4f(1,1,1,opac);
else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
glEnable(GL_TEXTURE_2D);
- glBindTexture( GL_TEXTURE_2D, Game::Mainmenuitems[4]);
+ Game::Mainmenuitems[4].bind();
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex3f(-1,-1,0);
glTranslatef(1,-1,0);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1,1,1,1);
- glBindTexture( GL_TEXTURE_2D, Game::cursortexture);
+ Game::cursortexture.bind();
glPushMatrix();
//glScalef(.25,.25,.25);
glBegin(GL_QUADS);
}
void Game::deleteGame(){
- if(skybox)
- delete skybox;
- if(text)
- delete text;
- glDeleteTextures( 10, &Mainmenuitems[0] );
- glDeleteTextures( 1, &cursortexture );
- glDeleteTextures( 1, &Maparrowtexture );
- glDeleteTextures( 1, &Mapboxtexture );
- glDeleteTextures( 1, &Mapcircletexture );
- glDeleteTextures( 1, &terraintexture );
- glDeleteTextures( 1, &terraintexture2 );
- glDeleteTextures( 1, &screentexture );
- glDeleteTextures( 1, &screentexture2 );
- glDeleteTextures( 1, &hawktexture );
- glDeleteTextures( 1, &logotexture );
- glDeleteTextures( 1, &loadscreentexture );
+ 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::LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha) {
- *textureid = Texture::Load(fileName,mipmap,hasalpha);
-}
-
-void Game::LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize) {
- *textureid = Texture::Load(fileName,mipmap,false,array,skinsize);
-}
-
void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
{
int i;
//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
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
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
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
}
-void LoadScreenTexture() {
+void Game::LoadScreenTexture() {
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
if(!Game::screentexture)
LOGFUNC;
- visibleloading=1;
-
loadtime=0;
stillloading=1;
for(i=0;i<maxplayers;i++)
- {
- glDeleteTextures(1, &player[i].skeleton.drawmodel.textureptr);
- player[i].skeleton.drawmodel.textureptr=0;;
- }
+ player[i].skeleton.drawmodel.textureptr.destroy();
i=abs(Random()%4);
- LoadTexture(":Data:Textures:fire.jpg",&loadscreentexture,1,0);
+ visibleloading=0; //don't use loadscreentexture yet
+ loadscreentexture.load(":Data:Textures:fire.jpg",1,0);
+ visibleloading=1;
temptexdetail=texdetail;
texdetail=1;
LOG("Loading weapon data...");
- 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::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::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: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);
+ 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);
- LoadTexture(":Data:Textures:hawk.png",&hawktexture,0,1);
- LoadTexture(":Data:Textures:logo.png",&logotexture,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);
- 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);
+ 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;
static void ch_cellar(const char *args)
{
- LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+ player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:Furdarko.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
}
static void ch_tint(const char *args)
static void set_noclothes(int pnum, const char *args)
{
player[pnum].numclothes = 0;
- LoadTextureSave(creatureskin[player[pnum].creature][player[pnum].whichskin],
- &player[pnum].skeleton.drawmodel.textureptr,1,
- &player[pnum].skeleton.skinText[0],&player[pnum].skeleton.skinsize);
+ player[pnum].skeleton.drawmodel.textureptr.load(
+ creatureskin[player[pnum].creature][player[pnum].whichskin],1,
+ &player[pnum].skeleton.skinText[0],&player[pnum].skeleton.skinsize);
}
static void ch_noclothes(const char *args)
":Data:Models:Body4.solid",":Data:Models:Body5.solid",
":Data:Models:Body6.solid",":Data:Models:Body7.solid",
":Data:Models:Bodylow.solid",":Data:Models:Belt.solid",1);
- LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,
- &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+ player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:fur3.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
player[0].creature=rabbittype;
player[0].scale=.2;
player[0].headless=0;
":Data:Models:Wolf4.solid",":Data:Models:Wolf5.solid",
":Data:Models:Wolf6.solid",":Data:Models:Wolf7.solid",
":Data:Models:Wolflow.solid",":Data:Models:Belt.solid",0);
- LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
- &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+ player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:Wolf.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
player[0].creature=wolftype;
player[0].damagetolerance=300;
set_proportion(0, "1 1 1 1");
static void ch_wolf(const char *args)
{
- LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
- &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+ player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:Wolf.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
}
static void ch_snowwolf(const char *args)
{
- LoadTextureSave(":Data:Textures:SnowWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
- &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+ player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:SnowWolf.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
}
static void ch_darkwolf(const char *args)
{
- LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
- &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+ player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:DarkWolf.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
}
static void ch_lizardwolf(const char *args)
{
- LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
- &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+ player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:Lizardwolf.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
}
static void ch_white(const char *args)
{
- LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,
- &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+ player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:fur.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
}
static void ch_brown(const char *args)
{
- LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,
- &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+ player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:fur3.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
}
static void ch_black(const char *args)
{
- LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,
- &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+ player[0].skeleton.drawmodel.textureptr.load(":Data:Textures:fur2.jpg",1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
}
static void ch_sizemin(const char *args)
}
player[0].numclothes=0;
- LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin],
- &player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],
- &player[0].skeleton.skinsize);
+ player[0].skeleton.drawmodel.textureptr.load(
+ creatureskin[player[0].creature][player[0].whichskin],1,
+ &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
editoractive=typeactive;
player[0].immobile=0;
if(ambientsound)
emit_stream_np(stream_wind);
- LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
- LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
- LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
- LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
+ objects.treetextureptr.load(":Data:Textures:snowtree.png",0,1);
+ objects.bushtextureptr.load(":Data:Textures:bushsnow.png",0,1);
+ objects.rocktextureptr.load(":Data:Textures:bouldersnow.jpg",1,0);
+ objects.boxtextureptr.load(":Data:Textures:snowbox.jpg",1,0);
footstepsound = footstepsn1;
footstepsound2 = footstepsn2;
footstepsound3 = footstepst1;
footstepsound4 = footstepst2;
- LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
-
- LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
+ terraintexture.load(":Data:Textures:snow.jpg",1,0);
+ terraintexture2.load(":Data:Textures:rock.jpg",1,0);
//LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
} else if(environment==desertenvironment){
windvector=0;
windvector.z=2;
- LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
- LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
- LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
- LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
+ objects.treetextureptr.load(":Data:Textures:deserttree.png",0,1);
+ objects.bushtextureptr.load(":Data:Textures:bushdesert.png",0,1);
+ objects.rocktextureptr.load(":Data:Textures:boulderdesert.jpg",1,0);
+ objects.boxtextureptr.load(":Data:Textures:desertbox.jpg",1,0);
if(ambientsound)
footstepsound3 = footstepsn1;
footstepsound4 = footstepsn2;
- LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
-
- LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
+ terraintexture.load(":Data:Textures:sand.jpg",1,0);
+ terraintexture2.load(":Data:Textures:sandslope.jpg",1,0);
//LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
} else if(environment==grassyenvironment){
windvector=0;
windvector.z=2;
- LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
- LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
- LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
- LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
+ objects.treetextureptr.load(":Data:Textures:tree.png",0,1);
+ objects.bushtextureptr.load(":Data:Textures:bush.png",0,1);
+ objects.rocktextureptr.load(":Data:Textures:boulder.jpg",1,0);
+ objects.boxtextureptr.load(":Data:Textures:grassbox.jpg",1,0);
if(ambientsound)
emit_stream_np(stream_wind, 100.);
footstepsound3 = footstepst1;
footstepsound4 = footstepst2;
- LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
-
- LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
+ terraintexture.load(":Data:Textures:grassdirt.jpg",1,0);
+ terraintexture2.load(":Data:Textures:mossrock.jpg",1,0);
//LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
ifstream test(ConvertFileName((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str()));
if(test.good()) {
- LoadTexture((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str(),&Mainmenuitems[7],0,0);
+ Mainmenuitems[7].load((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str(),0,0);
} else {
- LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
+ Mainmenuitems[7].load(":Data:Textures:World.png",0,0);
}
if(accountactive->getCampaignChoicesMade()==0) {
(char *)":Data:Models:Body7.solid",
(char *)":Data:Models:Bodylow.solid",
(char *)":Data:Models:Belt.solid",1);
- LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
+ player[i].skeleton.drawmodelclothes.textureptr.load(":Data:Textures:Belt.png",1,1);
}
if(player[i].creature==wolftype){
player[i].skeleton.Load(
//~ int texsize;
//~ texsize=512*512*3/texdetail/texdetail;
- LoadTextureSave(creatureskin[player[i].creature][player[i].whichskin],&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
+ player[i].skeleton.drawmodel.textureptr.load(creatureskin[player[i].creature][player[i].whichskin],1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
if(player[i].numclothes){
for(int j=0;j<player[i].numclothes;j++){
if(player[closest].whichskin>2&&player[closest].creature==wolftype)
player[closest].whichskin=0;
- LoadTextureSave(creatureskin[player[closest].creature][player[closest].whichskin],
- &player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+ player[closest].skeleton.drawmodel.textureptr.load(creatureskin[player[closest].creature][player[closest].whichskin],1,
+ &player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
}
if(player[closest].numclothes){
if(player[closest].creature==rabbittype){
player[closest].skeleton.id=closest;
player[closest].skeleton.Load((char *)":Data:Skeleton:Basic Figure Wolf",(char *)":Data:Skeleton:Basic Figure Wolf Low",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Wolf.solid",(char *)":Data:Models:Wolf2.solid",(char *)":Data:Models:Wolf3.solid",(char *)":Data:Models:Wolf4.solid",(char *)":Data:Models:Wolf5.solid",(char *)":Data:Models:Wolf6.solid",(char *)":Data:Models:Wolf7.solid",(char *)":Data:Models:Wolflow.solid",(char *)":Data:Models:Belt.solid",0);
- LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
+ player[closest].skeleton.drawmodel.textureptr.load(":Data:Textures:Wolf.jpg",1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
player[closest].whichskin=0;
player[closest].creature=wolftype;
{
player[closest].skeleton.id=closest;
player[closest].skeleton.Load((char *)":Data:Skeleton:Basic Figure",(char *)":Data:Skeleton:Basic Figurelow",(char *)":Data:Skeleton:Rabbitbelt",(char *)":Data:Models:Body.solid",(char *)":Data:Models:Body2.solid",(char *)":Data:Models:Body3.solid",(char *)":Data:Models:Body4.solid",(char *)":Data:Models:Body5.solid",(char *)":Data:Models:Body6.solid",(char *)":Data:Models:Body7.solid",(char *)":Data:Models:Bodylow.solid",(char *)":Data:Models:Belt.solid",1);
- LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
+ player[closest].skeleton.drawmodel.textureptr.load(":Data:Textures:Fur3.jpg",1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
player[closest].whichskin=0;
player[closest].creature=rabbittype;
int k=abs(Random()%2)+1;
if(k==0){
- LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
+ player[numplayers].skeleton.drawmodel.textureptr.load(":Data:Textures:Fur3.jpg",1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
player[numplayers].whichskin=0;
}
else if(k==1){
- LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
+ player[numplayers].skeleton.drawmodel.textureptr.load(":Data:Textures:Fur.jpg",1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
player[numplayers].whichskin=1;
}
else {
- LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
+ player[numplayers].skeleton.drawmodel.textureptr.load(":Data:Textures:Fur2.jpg",1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
player[numplayers].whichskin=2;
}
- LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
+ player[numplayers].skeleton.drawmodelclothes.textureptr.load(":Data:Textures:Belt.png",1,1);
player[numplayers].power=1;
player[numplayers].speedmult=1;
player[numplayers].currentanimation=bounceidleanim;
enum MenuItemType{NONE,LABEL,BUTTON,IMAGE,IMAGEBUTTON,MAPMARKER,MAPLINE,MAPLABEL} type;
int id;
string text;
- int texture;
+ Texture texture;
int x,y,w,h;
float r,g,b;
float effectfade;
float linestartsize;
float lineendsize;
- void init(MenuItemType _type, int _id, const string& _text, int _texture,
+ void init(MenuItemType _type, int _id, const string& _text, Texture _texture,
int _x, int _y, int _w, int _h, float _r, float _g, float _b,
float _linestartsize=1, float _lineendsize=1){
type=_type;
void Menu::addLabel(int id,const string& text,int x,int y,float r,float g,float b){
items.push_back(MenuItem());
- items.back().init(MenuItem::LABEL,id,text,0,x,y,-1,-1,r,g,b);
+ items.back().init(MenuItem::LABEL,id,text,Texture(),x,y,-1,-1,r,g,b);
}
void Menu::addButton(int id,const string& text,int x,int y,float r,float g,float b){
items.push_back(MenuItem());
- items.back().init(MenuItem::BUTTON,id,text,0,x,y,-1,-1,r,g,b);
+ items.back().init(MenuItem::BUTTON,id,text,Texture(),x,y,-1,-1,r,g,b);
}
-void Menu::addImage(int id,int texture,int x,int y,int w,int h,float r,float g,float b){
+void Menu::addImage(int id,Texture texture,int x,int y,int w,int h,float r,float g,float b){
items.push_back(MenuItem());
items.back().init(MenuItem::IMAGE,id,"",texture,x,y,w,h,r,g,b);
}
-void Menu::addButtonImage(int id,int texture,int x,int y,int w,int h,float r,float g,float b){
+void Menu::addButtonImage(int id,Texture texture,int x,int y,int w,int h,float r,float g,float b){
items.push_back(MenuItem());
items.back().init(MenuItem::IMAGEBUTTON,id,"",texture,x,y,w,h,r,g,b);
}
void Menu::addMapLine(int x, int y, int w, int h, float startsize, float endsize, float r,float g,float b){
items.push_back(MenuItem());
- items.back().init(MenuItem::MAPLINE,-1,"",0,x,y,w,h,r,g,b,startsize,endsize);
+ items.back().init(MenuItem::MAPLINE,-1,"",Texture(),x,y,w,h,r,g,b,startsize,endsize);
}
-void Menu::addMapMarker(int id,int texture,int x,int y,int w,int h,float r,float g,float b){
+void Menu::addMapMarker(int id,Texture texture,int x,int y,int w,int h,float r,float g,float b){
items.push_back(MenuItem());
items.back().init(MenuItem::MAPMARKER,id,"",texture,x,y,w,h,r,g,b);
}
void Menu::addMapLabel(int id,const string& text,int x,int y,float r,float g,float b){
items.push_back(MenuItem());
- items.back().init(MenuItem::MAPLABEL,id,text,0,x,y,-1,-1,r,g,b);
+ items.back().init(MenuItem::MAPLABEL,id,text,Texture(),x,y,-1,-1,r,g,b);
}
void Menu::setText(int id,const string& text){
}else{
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
}
- glBindTexture(GL_TEXTURE_2D,it->texture);
+ it->texture.bind();
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBegin(GL_QUADS);
void clearMenu();
void addLabel(int id,const string& text,int x,int y,float r=1,float g=0,float b=0);
void addButton(int id,const string& text,int x,int y,float r=1,float g=0,float b=0);
- void addImage(int id,int texture,int x,int y,int w,int h,float r=1,float g=1,float b=1);
- void addButtonImage(int id,int texture,int x,int y,int w,int h,float r=1,float g=1,float b=1);
+ void addImage(int id,Texture texture,int x,int y,int w,int h,float r=1,float g=1,float b=1);
+ void addButtonImage(int id,Texture texture,int x,int y,int w,int h,float r=1,float g=1,float b=1);
void addMapLine(int x, int y, int w, int h, float startsize, float endsize, float r,float g,float b);
- void addMapMarker(int id,int texture,int x,int y,int w,int h,float r,float g,float b);
+ void addMapMarker(int id,Texture texture,int x,int y,int w,int h,float r,float g,float b);
void addMapLabel(int id,const string& text,int x,int y,float r=1,float g=0,float b=0);
void setText(int id,const string& text);
void setText(int id,const string& text,int x,int y,int w,int h);
funpackf(tfile, "Bf Bf Bf", &Triangles[i].gy[0], &Triangles[i].gy[1], &Triangles[i].gy[2]);
}
- Texture.xsz=0;
+ modelTexture.xsz=0;
fclose(tfile);
}
- Texture.xsz=0;
+ modelTexture.xsz=0;
fclose(tfile);
void Model::drawimmediate()
{
- glBindTexture(GL_TEXTURE_2D,(unsigned long)textureptr);
+ textureptr.bind();
glBegin(GL_TRIANGLES);
for(int i=0;i<TriangleNum;i++){
/*if(Triangles[i].vertex[0]<vertexNum&&Triangles[i].vertex[1]<vertexNum&&Triangles[i].vertex[2]<vertexNum&&Triangles[i].vertex[0]>=0&&Triangles[i].vertex[1]>=0&&Triangles[i].vertex[2]>=0){
if(!color)glInterleavedArrays( GL_T2F_N3F_V3F,8*sizeof(GLfloat),&vArray[0]);
if(color)glInterleavedArrays( GL_T2F_C3F_V3F,8*sizeof(GLfloat),&vArray[0]);
- glBindTexture(GL_TEXTURE_2D,(unsigned long)textureptr);
+ textureptr.bind();
#if PLATFORM_MACOSX
glLockArraysEXT( 0, TriangleNum*3);
//drawimmediate();
}
+//TODO: phase out in favor of Texture
void Model::drawdifftex(GLuint texture)
{
glEnableClientState(GL_NORMAL_ARRAY);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+#ifndef WIN32
+ glLockArraysEXT( 0, TriangleNum*3);
+#endif
+ glDrawArrays(GL_TRIANGLES, 0, TriangleNum*3);
+#ifndef WIN32
+ glUnlockArraysEXT();
+#endif
+
+
+ if(!color)glDisableClientState(GL_NORMAL_ARRAY);
+ if(color)glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ //drawdiffteximmediate(texture);
+}
+
+void Model::drawdifftex(Texture texture)
+{
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ if(!color)glInterleavedArrays( GL_T2F_N3F_V3F,8*sizeof(GLfloat),&vArray[0]);
+ if(color)glInterleavedArrays( GL_T2F_C3F_V3F,8*sizeof(GLfloat),&vArray[0]);
+
+ texture.bind();
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+
+
#ifndef WIN32
glLockArraysEXT( 0, TriangleNum*3);
#endif
glEnd();
}
-void Model::drawdecals(GLuint shadowtexture,GLuint bloodtexture,GLuint bloodtexture2,GLuint breaktexture)
+void Model::drawdecals(Texture shadowtexture,Texture bloodtexture,Texture bloodtexture2,Texture breaktexture)
{
if(decals){
if(type!=decalstype)return;
if(decaltype[i]==blooddecalfast&&decalalivetime[i]<2)decalalivetime[i]=2;
if(decaltype[i]==shadowdecal&&decaltype[i]!=lasttype){
- glBindTexture( GL_TEXTURE_2D, shadowtexture);
+ shadowtexture.bind();
if(!blend){
blend=1;
glAlphaFunc(GL_GREATER, 0.0001);
}
}
if(decaltype[i]==breakdecal&&decaltype[i]!=lasttype){
- glBindTexture( GL_TEXTURE_2D, breaktexture);
+ breaktexture.bind();
if(!blend){
blend=1;
glAlphaFunc(GL_GREATER, 0.0001);
}
}
if((decaltype[i]==blooddecal||decaltype[i]==blooddecalslow)&&decaltype[i]!=lasttype){
- glBindTexture( GL_TEXTURE_2D, bloodtexture);
+ bloodtexture.bind();
if(blend){
blend=0;
glAlphaFunc(GL_GREATER, 0.15);
}
}
if((decaltype[i]==blooddecalfast)&&decaltype[i]!=lasttype){
- glBindTexture( GL_TEXTURE_2D, bloodtexture2);
+ bloodtexture2.bind();
if(blend){
blend=0;
glAlphaFunc(GL_GREATER, 0.15);
Model::~Model()
{
deallocate();
-
- glDeleteTextures( 1, &textureptr );
+ textureptr.destroy();
}
void Model::deallocate()
Triangles=0;
vArray=0;
- textureptr = 0;
- memset(&Texture, 0, sizeof(Texture));
+ memset(&modelTexture, 0, sizeof(modelTexture));
numpossible = 0;
color = 0;
#include "Terrain.h"
#include "binio.h"
#include "Quaternions.h"
+#include "Texture.h"
//
// Textures List
TexturedTriangle Triangles[max_textured_triangle];
GLfloat vArray[max_textured_triangle*24];*/
- GLuint textureptr;
- ModelTexture Texture;
+ Texture textureptr;
+ ModelTexture modelTexture;
int numpossible;
bool color;
void DeleteDecal(int which);
void MakeDecal(int atype, XYZ *where, float *size, float *opacity, float *rotation);
void MakeDecal(int atype, XYZ where, float size, float opacity, float rotation);
- void drawdecals(GLuint shadowtexture,GLuint bloodtexture,GLuint bloodtexture2,GLuint breaktexture);
+ void drawdecals(Texture shadowtexture,Texture bloodtexture,Texture bloodtexture2,Texture breaktexture);
int SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate);
int SphereCheckPossible(XYZ *p1,float radius, XYZ *move, float *rotate);
int LineCheck(XYZ *p1,XYZ *p2, XYZ *p, XYZ *move, float *rotate);
void CalculateNormals(bool facenormalise);
void draw();
void drawdifftex(GLuint texture);
+ void drawdifftex(Texture texture);
void drawimmediate();
void drawdiffteximmediate(GLuint texture);
void Rotate(float xang,float yang,float zang);
center = 0;
radius = 0;
numobjects = 0;
- boxtextureptr = 0;
- treetextureptr = 0;
- bushtextureptr = 0;
- rocktextureptr = 0;
memset(position, 0, sizeof(position));
memset(type, 0, sizeof(type));
Objects::~Objects()
{
- glDeleteTextures( 1, &boxtextureptr );
- glDeleteTextures( 1, &treetextureptr );
- glDeleteTextures( 1, &bushtextureptr );
- glDeleteTextures( 1, &rocktextureptr );
+ boxtextureptr.destroy();
+ treetextureptr.destroy();
+ bushtextureptr.destroy();
+ rocktextureptr.destroy();
};
#include "Models.h"
#include "Terrain.h"
#include "Sprite.h"
+#include "Texture.h"
#include <vector>
//
// Model Structures
float scale[max_objects];
float messedwith[max_objects];
float checked[max_objects];
- GLuint boxtextureptr;
- GLuint treetextureptr;
- GLuint bushtextureptr;
- GLuint rocktextureptr;
+ Texture boxtextureptr;
+ Texture treetextureptr;
+ Texture bushtextureptr;
+ Texture rocktextureptr;
float shadowed[max_objects];
float occluded[max_objects];
bool checkcollide(XYZ startpoint, XYZ endpoint,int which);
}
}
}
- glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
+ skeleton.drawmodel.textureptr.bind();
DoMipmaps();
bleedxint=0;
}
}
}
- glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
+ skeleton.drawmodel.textureptr.bind();
DoMipmaps();
bleedy=(1+coordsy)*512;
if(bleeding>0){
bleeding-=multiplier*.3;
if(bloodtoggle==2){
- glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
+ skeleton.drawmodel.textureptr.bind();
if(bleeding<=0&&(detail!=2||osx))DoMipmaps();
}
}
}
}
if(!osx&&detail>1){
- glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
+ skeleton.drawmodel.textureptr.bind();
DoMipmaps();
}
void DoHead();
void DoMipmaps()
{
- glBindTexture(GL_TEXTURE_2D, skeleton.drawmodel.textureptr);
+ skeleton.drawmodel.textureptr.bind();
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skeleton.skinsize, skeleton.skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0]);
}
SkyBox::load (const char *ffront, const char *fleft, const char *fback,
const char *fright, const char *fup, const char *fdown)
{
- Game::LoadTexture(ffront, &front, true, false);
- Game::LoadTexture(fleft, &left, true, false);
- Game::LoadTexture(fback, &back, true, false);
- Game::LoadTexture(fright, &right, true, false);
- Game::LoadTexture(fup, &up, true, false);
- Game::LoadTexture(fdown, &down, true, false);
+ front.load(ffront, true, false);
+ left.load(fleft, true, false);
+ back.load(fback, true, false);
+ right.load(fright, true, false);
+ up.load(fup, true, false);
+ down.load(fdown, true, false);
}
void SkyBox::draw()
glDisable(GL_LIGHTING);
if(skyboxtexture)glEnable(GL_TEXTURE_2D);
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
- glBindTexture(GL_TEXTURE_2D, front);
+ front.bind();
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glBegin(GL_QUADS);
glTexCoord2f(1, 1); glVertex3f( size, size, size);
glTexCoord2f(0, 1); glVertex3f(-size, size, size);
glEnd();
- glBindTexture(GL_TEXTURE_2D, back);
+ back.bind();
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glBegin(GL_QUADS);
glTexCoord2f(0, 1); glVertex3f( size, size, -size);
glTexCoord2f(0, 0); glVertex3f( size, -size, -size);
glEnd();
- glBindTexture(GL_TEXTURE_2D, up);
+ up.bind();
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glBegin(GL_QUADS);
glTexCoord2f(1, 0); glVertex3f( size, size, size);
glTexCoord2f(1, 1); glVertex3f( size, size, -size);
glEnd();
- glBindTexture(GL_TEXTURE_2D, down);
+ down.bind();
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glBegin(GL_QUADS);
glTexCoord2f(1, 1); glVertex3f( size, -size, size);
glTexCoord2f(0, 1); glVertex3f(-size, -size, size);
glEnd();
- glBindTexture(GL_TEXTURE_2D, right);
+ right.bind();
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glBegin(GL_QUADS);
glTexCoord2f(0, 1); glVertex3f( size, size, size);
glTexCoord2f(0, 0); glVertex3f( size, -size, size);
glEnd();
- glBindTexture(GL_TEXTURE_2D, left);
+ left.bind();
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glBegin(GL_QUADS);
SkyBox::~SkyBox()
{
- glDeleteTextures( 1, &front );
- glDeleteTextures( 1, &left );
- glDeleteTextures( 1, &back );
- glDeleteTextures( 1, &right );
- glDeleteTextures( 1, &up );
- glDeleteTextures( 1, &down );
+ front.destroy();
+ left.destroy();
+ back.destroy();
+ right.destroy();
+ up.destroy();
+ down.destroy();
};
#include "TGALoader.h"
#include "Quaternions.h"
#include "gamegl.h"
+#include "Texture.h"
class SkyBox{
public:
- GLuint front, left, back, right, up, down;
+ Texture front, left, back, right, up, down;
void load(const char *ffront, const char *fleft, const char *fback,
const char *fright, const char *fup, const char *fdown);
void draw();
- SkyBox(): front(0), left(0), back(0), right(0), up(0), down(0) {}
+ SkyBox() {}
~SkyBox();
};
extern XYZ windvector;
// init statics
-GLuint Sprite::cloudtexture = 0;
-GLuint Sprite::cloudimpacttexture = 0;
-GLuint Sprite::bloodtexture = 0;
-GLuint Sprite::flametexture = 0;
-GLuint Sprite::bloodflametexture = 0;
-GLuint Sprite::smoketexture = 0;
-GLuint Sprite::snowflaketexture = 0;
-GLuint Sprite::shinetexture = 0;
-GLuint Sprite::splintertexture = 0;
-GLuint Sprite::leaftexture = 0;
-GLuint Sprite::toothtexture = 0;
+Texture Sprite::cloudtexture;
+Texture Sprite::cloudimpacttexture;
+Texture Sprite::bloodtexture;
+Texture Sprite::flametexture;
+Texture Sprite::bloodflametexture;
+Texture Sprite::smoketexture;
+Texture Sprite::snowflaketexture;
+Texture Sprite::shinetexture;
+Texture Sprite::splintertexture;
+Texture Sprite::leaftexture;
+Texture Sprite::toothtexture;
float Sprite::checkdelay = 0;
if(lasttype!=sprites[i]->type) {
switch(sprites[i]->type) {
case cloudsprite:
- glBindTexture( GL_TEXTURE_2D, cloudtexture);
+ cloudtexture.bind();
if(!blend){
blend=1;
glAlphaFunc(GL_GREATER, 0.0001);
}
break;
case cloudimpactsprite:
- glBindTexture( GL_TEXTURE_2D, cloudimpacttexture);
+ cloudimpacttexture.bind();
if(!blend){
blend=1;
glAlphaFunc(GL_GREATER, 0.0001);
}
break;
case breathsprite:
- glBindTexture( GL_TEXTURE_2D, cloudimpacttexture);
+ cloudimpacttexture.bind();
if(!blend){
blend=1;
glAlphaFunc(GL_GREATER, 0.0001);
}
break;
case smoketype:
- glBindTexture( GL_TEXTURE_2D, smoketexture);
+ smoketexture.bind();
if(!blend){
blend=1;
glAlphaFunc(GL_GREATER, 0.0001);
}
break;
case bloodsprite:
- glBindTexture( GL_TEXTURE_2D, bloodtexture);
+ bloodtexture.bind();
if(!blend){
blend=1;
glAlphaFunc(GL_GREATER, 0.0001);
break;
case splintersprite :
if(lastspecial!=sprites[i]->special) {
- if(sprites[i]->special==0)glBindTexture( GL_TEXTURE_2D, splintertexture);
- if(sprites[i]->special==1)glBindTexture( GL_TEXTURE_2D, leaftexture);
- if(sprites[i]->special==2)glBindTexture( GL_TEXTURE_2D, snowflaketexture);
- if(sprites[i]->special==3)glBindTexture( GL_TEXTURE_2D, toothtexture);
+ if(sprites[i]->special==0)splintertexture.bind();
+ if(sprites[i]->special==1)leaftexture.bind();
+ if(sprites[i]->special==2)snowflaketexture.bind();
+ if(sprites[i]->special==3)toothtexture.bind();
if(!blend){
blend=1;
glAlphaFunc(GL_GREATER, 0.0001);
}
break;
case snowsprite:
- glBindTexture( GL_TEXTURE_2D, snowflaketexture);
+ snowflaketexture.bind();
if(!blend){
blend=1;
glAlphaFunc(GL_GREATER, 0.0001);
}
break;
case weaponshinesprite:
- glBindTexture( GL_TEXTURE_2D, shinetexture);
+ shinetexture.bind();
if(blend){
blend=0;
glAlphaFunc(GL_GREATER, 0.001);
break;
case flamesprite:
case weaponflamesprite:
- glBindTexture( GL_TEXTURE_2D, flametexture);
+ flametexture.bind();
if(blend||lasttype==bloodflamesprite){
blend=0;
glAlphaFunc(GL_GREATER, 0.3);
}
break;
case bloodflamesprite:
- glBindTexture( GL_TEXTURE_2D, bloodflametexture);
+ bloodflametexture.bind();
if(blend){
blend=0;
glAlphaFunc(GL_GREATER, 0.3);
void Sprite::clearTextures()
{
- glDeleteTextures( 1, &toothtexture );
- glDeleteTextures( 1, &cloudtexture );
- glDeleteTextures( 1, &cloudimpacttexture );
- glDeleteTextures( 1, &bloodtexture );
- glDeleteTextures( 1, &flametexture );
- glDeleteTextures( 1, &bloodflametexture );
- glDeleteTextures( 1, &smoketexture );
- glDeleteTextures( 1, &snowflaketexture );
- glDeleteTextures( 1, &shinetexture );
- glDeleteTextures( 1, &splintertexture );
- glDeleteTextures( 1, &leaftexture );
+ toothtexture.destroy();
+ cloudtexture.destroy();
+ cloudimpacttexture.destroy();
+ bloodtexture.destroy();
+ flametexture.destroy();
+ bloodflametexture.destroy();
+ smoketexture.destroy();
+ snowflaketexture.destroy();
+ shinetexture.destroy();
+ splintertexture.destroy();
+ leaftexture.destroy();
}
#include "Lights.h"
#include "Terrain.h"
#include "Objects.h"
+#include "Texture.h"
#include <vector>
}
static void clearTextures();
- static GLuint cloudtexture;
- static GLuint bloodtexture;
- static GLuint flametexture;
- static GLuint smoketexture;
+ static Texture cloudtexture;
+ static Texture bloodtexture;
+ static Texture flametexture;
+ static Texture smoketexture;
- static GLuint cloudimpacttexture;
- static GLuint snowflaketexture;
- static GLuint shinetexture;
- static GLuint bloodflametexture;
+ static Texture cloudimpacttexture;
+ static Texture snowflaketexture;
+ static Texture shinetexture;
+ static Texture bloodflametexture;
- static GLuint splintertexture;
+ static Texture splintertexture;
- static GLuint leaftexture;
- static GLuint toothtexture;
+ static Texture leaftexture;
+ static Texture toothtexture;
Sprite();
~Sprite();
for(i=0;i<numdecals;i++){
if(decaltype[i]==blooddecalfast&&decalalivetime[i]<2)decalalivetime[i]=2;
if((decaltype[i]==shadowdecal||decaltype[i]==shadowdecalpermanent)&&decaltype[i]!=lasttype){
- glBindTexture( GL_TEXTURE_2D, shadowtexture);
+ shadowtexture.bind();
if(!blend){
blend=1;
glAlphaFunc(GL_GREATER, 0.0001);
}
}
if(decaltype[i]==footprintdecal&&decaltype[i]!=lasttype){
- glBindTexture( GL_TEXTURE_2D, footprinttexture);
+ footprinttexture.bind();
if(!blend){
blend=1;
glAlphaFunc(GL_GREATER, 0.0001);
}
}
if(decaltype[i]==bodyprintdecal&&decaltype[i]!=lasttype){
- glBindTexture( GL_TEXTURE_2D, bodyprinttexture);
+ bodyprinttexture.bind();
if(!blend){
blend=1;
glAlphaFunc(GL_GREATER, 0.0001);
}
}
if((decaltype[i]==blooddecal||decaltype[i]==blooddecalslow)&&decaltype[i]!=lasttype){
- glBindTexture( GL_TEXTURE_2D, bloodtexture);
+ bloodtexture.bind();
if(blend){
blend=0;
glAlphaFunc(GL_GREATER, 0.15);
}
}
if((decaltype[i]==blooddecalfast)&&decaltype[i]!=lasttype){
- glBindTexture( GL_TEXTURE_2D, bloodtexture2);
+ bloodtexture2.bind();
if(blend){
blend=0;
glAlphaFunc(GL_GREATER, 0.15);
Terrain::Terrain()
{
- bloodtexture = 0;
- bloodtexture2 = 0;
- shadowtexture = 0;
- footprinttexture = 0;
- bodyprinttexture = 0;
- breaktexture = 0;
- terraintexture = 0;
size = 0;
memset(patchobjectnum, 0, sizeof(patchobjectnum));
}
Terrain::~Terrain()
{
- glDeleteTextures( 1, &terraintexture );
- glDeleteTextures( 1, &shadowtexture );
- glDeleteTextures( 1, &bodyprinttexture );
- glDeleteTextures( 1, &footprinttexture );
- glDeleteTextures( 1, &bloodtexture );
- glDeleteTextures( 1, &bloodtexture2 );
- glDeleteTextures( 1, &breaktexture );
+ terraintexture.destroy();
+ shadowtexture.destroy();
+ bodyprinttexture.destroy();
+ footprinttexture.destroy();
+ bloodtexture.destroy();
+ bloodtexture2.destroy();
+ breaktexture.destroy();
}
#include "TGALoader.h"
#include "Quaternions.h"
#include "Quaternions.h"
+#include "Texture.h"
#define max_terrain_size 256
#define curr_terrain_size size
class Terrain{
public:
- GLuint bloodtexture;
- GLuint bloodtexture2;
- GLuint shadowtexture;
- GLuint footprinttexture;
- GLuint bodyprinttexture;
- GLuint breaktexture;
- GLuint terraintexture;
+ Texture bloodtexture;
+ Texture bloodtexture2;
+ Texture shadowtexture;
+ Texture footprinttexture;
+ Texture bodyprinttexture;
+ Texture breaktexture;
+ Texture terraintexture;
short size;
int patchobjectnum[subdivision][subdivision];
LOG(std::string("Loading font texture...") + fileName);
- Game::LoadTexture(fileName, &FontTexture, false, false);
+ FontTexture.load(fileName, false, false);
/*
//Load Image
//LoadTGA( fileName );
// base=glGenLists(256); // Creating 256 Display Lists
base=glGenLists(512); // Creating 256 Display Lists
- glBindTexture(GL_TEXTURE_2D, FontTexture); // Select Our Font Texture
+ FontTexture.bind();
for (loop=0; loop<512; loop++) // Loop Through All 256 Lists
{
if (loop < 256)
set=1;
}
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
- glBindTexture(GL_TEXTURE_2D, FontTexture); // Select Our Font Texture
+ FontTexture.bind();
glDisable(GL_DEPTH_TEST); // Disables Depth Testing
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glPrint( x, y, string, set, size, width, height);
}
-Text::Text()
-{
+Text::Text() {
base = 0;
- FontTexture = 0;
}
-Text::~Text()
-{
- if (base)
- {
+Text::~Text() {
+ if (base) {
glDeleteLists(base, 512);
base = 0;
}
- glDeleteTextures( 1, &FontTexture );
+ FontTexture.destroy();
}
#include "Quaternions.h"
#include "gamegl.h"
#include "TGALoader.h"
+#include "Texture.h"
class Text{
public:
- GLuint FontTexture;
+ Texture FontTexture;
GLuint base;
void LoadFontTexture(const char *fileName);
using namespace std;
-map<string,Texture> Texture::textures;
-
extern TGAImageRec texture;
extern bool trilinear;
-Texture::~Texture() {
- free(array);
- glDeleteTextures(1,&id);
-}
-void Texture::load() {
- GLuint type;
+class TextureRes {
+private:
+ static vector<TextureRes*> list;
- LOGFUNC;
+ GLuint id;
+ string filename;
+ bool hasMipmap;
+ bool hasAlpha;
+ bool isSkin;
+ int skinsize;
+ GLubyte* data;
+ int datalen;
- LOG(std::string("Loading texture...") + fileName);
+ void load();
- unsigned char fileNamep[256];
- CopyCStringToPascal(ConvertFileName(fileName.c_str()), fileNamep);
- //Load Image
- upload_image( fileNamep ,hasalpha);
-
- //Alpha channel?
- if ( texture.bpp == 24 )
- type = GL_RGB;
- else
- type = GL_RGBA;
-
- glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
- if(!id)
- glGenTextures( 1, &id );
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
- glBindTexture( GL_TEXTURE_2D, id);
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
- if(mipmap)
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (trilinear?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR_MIPMAP_NEAREST) );
- else
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
- glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
+public:
+ TextureRes(const string& filename, bool hasMipmap, bool hasAlpha);
+ TextureRes(const string& filename, bool hasMipmap, GLubyte* array, int* skinsize);
+ ~TextureRes();
+ void bind();
+
+ static void reloadAll();
+};
+
+
+vector<TextureRes*> TextureRes::list;
+
+void TextureRes::load(){
+ //load image into 'texture' global var
+ unsigned char filenamep[256];
+ CopyCStringToPascal(ConvertFileName(filename.c_str()),filenamep);
+ upload_image(filenamep,hasAlpha);
skinsize=texture.sizeX;
+ GLuint type=GL_RGBA;
+ if(texture.bpp==24)
+ type=GL_RGB;
- if(isSkin) {
- int tempnum=0;
- int nb = (texture.sizeY*texture.sizeX*(texture.bpp/8));
- array = (GLubyte*)malloc(nb*sizeof(GLubyte));
- for(int i=0;i<nb;i++) {
- if((i+1)%4||type==GL_RGB) {
- array[tempnum]=texture.data[i];
- tempnum++;
- }
- }
- arraySize=tempnum;
-
- glTexImage2D( GL_TEXTURE_2D, 0, type, texture.sizeX, texture.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, array );
- } else {
- glTexImage2D( GL_TEXTURE_2D, 0, type, texture.sizeX, texture.sizeY, 0, type, GL_UNSIGNED_BYTE, texture.data );
+ glPixelStorei(GL_UNPACK_ALIGNMENT,1);
+
+ glDeleteTextures(1,&id);
+ glGenTextures(1,&id);
+ glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
+
+ glBindTexture(GL_TEXTURE_2D, id);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
+ if(hasMipmap){
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,(trilinear?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR_MIPMAP_NEAREST));
+ glTexParameteri(GL_TEXTURE_2D,GL_GENERATE_MIPMAP,GL_TRUE);
+ }else{
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
+ }
+
+ if(isSkin){
+ free(data);
+ const int nb=texture.sizeY*texture.sizeX*(texture.bpp/8);
+ data=(GLubyte*)malloc(nb*sizeof(GLubyte));
+ datalen=0;
+ for(int i=0;i<nb;i++)
+ if((i+1)%4||type==GL_RGB)
+ data[datalen++]=texture.data[i];
+ glTexImage2D(GL_TEXTURE_2D, 0, type, texture.sizeX, texture.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
+ }else{
+ glTexImage2D(GL_TEXTURE_2D, 0, type, texture.sizeX, texture.sizeY, 0, type, GL_UNSIGNED_BYTE, texture.data);
}
}
-GLuint Texture::Load(const string& fileName, bool mipmap, bool hasalpha) {
- map<string,Texture>::iterator it = textures.find(fileName);
- if(it==textures.end()) {
- textures.insert(make_pair(fileName,Texture(fileName,mipmap,hasalpha)));
- textures[fileName].load();
- return textures[fileName].getId();
- } else {
- return it->second.getId();
- }
+void TextureRes::bind(){
+ glBindTexture(GL_TEXTURE_2D,id);
}
-GLuint Texture::Load(const string& fileName, bool mipmap, bool hasalpha, GLubyte* array, int* skinsize) {
- map<string,Texture>::iterator it = textures.find(fileName);
- if(it==textures.end()) {
- textures.insert(make_pair(fileName,Texture(fileName,mipmap,hasalpha,true)));
- textures[fileName].load();
- *skinsize = textures[fileName].skinsize;
- for(int i=0;i<textures[fileName].arraySize;i++) {
- array[i] = textures[fileName].array[i];
- }
- return textures[fileName].getId();
- } else {
- *skinsize = it->second.skinsize;
- for(int i=0;i<it->second.arraySize;i++) {
- array[i] = it->second.array[i];
- }
- return it->second.getId();
- }
+TextureRes::TextureRes(const string& _filename, bool _hasMipmap, bool _hasAlpha):
+ id(0),filename(_filename),hasMipmap(_hasMipmap),hasAlpha(_hasAlpha),isSkin(false),
+ skinsize(0),data(NULL),datalen(0) {
+ load();
+ list.push_back(this);
+}
+
+TextureRes::TextureRes(const string& _filename, bool _hasMipmap, GLubyte* array, int* skinsizep):
+ id(0),filename(_filename),hasMipmap(_hasMipmap),hasAlpha(false),isSkin(true),
+ skinsize(0),data(NULL),datalen(0) {
+ load();
+ *skinsizep=skinsize;
+ for(int i=0;i<datalen;i++)
+ array[i]=data[i];
+ list.push_back(this);
+}
+
+TextureRes::~TextureRes(){
+ free(data);
+ glDeleteTextures(1,&id);
+ for(vector<TextureRes*>::iterator it=list.begin();it!=list.end();it++)
+ if(*it==this){
+ list.erase(it);
+ break;
+ }
+}
+
+void TextureRes::reloadAll(){
+ for(vector<TextureRes*>::iterator it=list.begin();it!=list.end();it++)
+ (*it)->load();
+}
+
+
+
+
+void Texture::load(const string& filename, bool hasMipmap, bool hasAlpha){
+ destroy();
+ tex=new TextureRes(filename,hasMipmap,hasAlpha);
+}
+
+void Texture::load(const string& filename, bool hasMipmap, GLubyte* array, int* skinsizep){
+ destroy();
+ tex=new TextureRes(filename,hasMipmap,array,skinsizep);
+}
+
+void Texture::destroy(){
+ if(tex){
+ delete tex;
+ tex=NULL;
+ }
+}
+
+void Texture::bind(){
+ if(tex)
+ tex->bind();
+ else
+ glBindTexture(GL_TEXTURE_2D,0);
+}
+
+void Texture::reloadAll(){
+ TextureRes::reloadAll();
}
#define _TEXTURE_H_
#include <map>
+#include <vector>
#include <string>
+using namespace std;
-//keeps track of which textures are loaded
-class Texture {
- private:
- static std::map<std::string,Texture> textures;
-
- bool isSkin;
- std::string fileName;
- GLuint id;
- bool mipmap;
- bool hasalpha;
- GLubyte* array;
- int arraySize;
- int skinsize;
+class TextureRes;
- void load();
+class Texture {
+private:
+ TextureRes* tex;
+public:
+ inline Texture(): tex(NULL) {}
+ void load(const string& filename, bool hasMipmap, bool hasAlpha);
+ void load(const string& filename, bool hasMipmap, GLubyte* array, int* skinsizep);
+ void destroy();
+ void bind();
- public:
- Texture():
- isSkin(false), skinsize(0), arraySize(0),
- fileName(""), id(0), mipmap(false), hasalpha(false), array(NULL) { }
- ~Texture();
- Texture (const std::string& _fileName, bool _mipmap, bool _hasalpha):
- isSkin(false), skinsize(0), arraySize(0), array(NULL),
- fileName(_fileName), id(0), mipmap(_mipmap), hasalpha(_hasalpha) { }
- Texture (const std::string& _fileName, bool _mipmap, bool _hasalpha, bool _isSkin):
- isSkin(_isSkin), skinsize(0), arraySize(0), array(NULL),
- fileName(_fileName), id(0), mipmap(_mipmap), hasalpha(_hasalpha) { }
- GLuint getId() const { return id; }
-
- static GLuint Load(const std::string& fileName, bool mipmap, bool hasalpha);
- static GLuint Load(const std::string& fileName, bool mipmap, bool hasalpha, GLubyte* array, int* skinsize);
+ static void reloadAll();
};
#endif
extern int numthrowkill;
Model Weapon::throwingknifemodel;
-GLuint Weapon::knifetextureptr = 0;
-GLuint Weapon::lightbloodknifetextureptr = 0;
-GLuint Weapon::bloodknifetextureptr = 0;
+Texture Weapon::knifetextureptr;
+Texture Weapon::lightbloodknifetextureptr;
+Texture Weapon::bloodknifetextureptr;
Model Weapon::swordmodel;
-GLuint Weapon::swordtextureptr = 0;
-GLuint Weapon::lightbloodswordtextureptr = 0;
-GLuint Weapon::bloodswordtextureptr = 0;
+Texture Weapon::swordtextureptr;
+Texture Weapon::lightbloodswordtextureptr;
+Texture Weapon::bloodswordtextureptr;
Model Weapon::staffmodel;
-GLuint Weapon::stafftextureptr = 0;
+Texture Weapon::stafftextureptr;
Weapon::Weapon(int t, int o) : owner(o) {
setType(t);
Weapons::~Weapons()
{
- glDeleteTextures( 1, &Weapon::stafftextureptr );
- glDeleteTextures( 1, &Weapon::knifetextureptr );
- glDeleteTextures( 1, &Weapon::lightbloodknifetextureptr );
- glDeleteTextures( 1, &Weapon::bloodknifetextureptr );
- glDeleteTextures( 1, &Weapon::swordtextureptr );
- glDeleteTextures( 1, &Weapon::lightbloodswordtextureptr );
- glDeleteTextures( 1, &Weapon::bloodswordtextureptr );
+ Weapon::stafftextureptr.destroy();
+ Weapon::knifetextureptr.destroy();
+ Weapon::lightbloodknifetextureptr.destroy();
+ Weapon::bloodknifetextureptr.destroy();
+ Weapon::swordtextureptr.destroy();
+ Weapon::lightbloodswordtextureptr.destroy();
+ Weapon::bloodswordtextureptr.destroy();
}
#include "Terrain.h"
#include "Sprite.h"
#include "Person.h"
+#include "Texture.h"
#include <cmath>
#define max_weapons 30
Weapon(int type, int owner);
static Model throwingknifemodel;
- static GLuint knifetextureptr;
- static GLuint lightbloodknifetextureptr;
- static GLuint bloodknifetextureptr;
+ static Texture knifetextureptr;
+ static Texture lightbloodknifetextureptr;
+ static Texture bloodknifetextureptr;
static Model swordmodel;
- static GLuint swordtextureptr;
- static GLuint lightbloodswordtextureptr;
- static GLuint bloodswordtextureptr;
+ static Texture swordtextureptr;
+ static Texture lightbloodswordtextureptr;
+ static Texture bloodswordtextureptr;
static Model staffmodel;
- static GLuint stafftextureptr;
+ static Texture stafftextureptr;
void Draw();
void DoStuff(int);