X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FSprite.cpp;h=334a6f5f5c827d4b1f3005667bc79bfb4382d798;hb=26debbd380c6922e5a0b60d99567c6374a4fef9a;hp=0998e093bfc65eb35f85c1f6740cc9d334e9ac31;hpb=0b7253f3d99e4382008aff8b8e221e88ff40d3e9;p=lugaru.git diff --git a/Source/Sprite.cpp b/Source/Sprite.cpp index 0998e09..334a6f5 100644 --- a/Source/Sprite.cpp +++ b/Source/Sprite.cpp @@ -38,17 +38,17 @@ extern int bloodtoggle; 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; @@ -101,7 +101,7 @@ void Sprite::Draw() 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); @@ -109,7 +109,7 @@ void Sprite::Draw() } break; case cloudimpactsprite: - glBindTexture( GL_TEXTURE_2D, cloudimpacttexture); + cloudimpacttexture.bind(); if(!blend){ blend=1; glAlphaFunc(GL_GREATER, 0.0001); @@ -117,7 +117,7 @@ void Sprite::Draw() } break; case breathsprite: - glBindTexture( GL_TEXTURE_2D, cloudimpacttexture); + cloudimpacttexture.bind(); if(!blend){ blend=1; glAlphaFunc(GL_GREATER, 0.0001); @@ -125,7 +125,7 @@ void Sprite::Draw() } break; case smoketype: - glBindTexture( GL_TEXTURE_2D, smoketexture); + smoketexture.bind(); if(!blend){ blend=1; glAlphaFunc(GL_GREATER, 0.0001); @@ -133,7 +133,7 @@ void Sprite::Draw() } break; case bloodsprite: - glBindTexture( GL_TEXTURE_2D, bloodtexture); + bloodtexture.bind(); if(!blend){ blend=1; glAlphaFunc(GL_GREATER, 0.0001); @@ -142,10 +142,10 @@ void Sprite::Draw() 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); @@ -154,7 +154,7 @@ void Sprite::Draw() } break; case snowsprite: - glBindTexture( GL_TEXTURE_2D, snowflaketexture); + snowflaketexture.bind(); if(!blend){ blend=1; glAlphaFunc(GL_GREATER, 0.0001); @@ -162,7 +162,7 @@ void Sprite::Draw() } break; case weaponshinesprite: - glBindTexture( GL_TEXTURE_2D, shinetexture); + shinetexture.bind(); if(blend){ blend=0; glAlphaFunc(GL_GREATER, 0.001); @@ -171,7 +171,7 @@ void Sprite::Draw() break; case flamesprite: case weaponflamesprite: - glBindTexture( GL_TEXTURE_2D, flametexture); + flametexture.bind(); if(blend||lasttype==bloodflamesprite){ blend=0; glAlphaFunc(GL_GREATER, 0.3); @@ -179,7 +179,7 @@ void Sprite::Draw() } break; case bloodflamesprite: - glBindTexture( GL_TEXTURE_2D, bloodflametexture); + bloodflametexture.bind(); if(blend){ blend=0; glAlphaFunc(GL_GREATER, 0.3); @@ -310,11 +310,11 @@ void Sprite::Draw() if(!spritehit&&player[j].dead&&sprites[i]->alivetime>.1){ where=sprites[i]->oldposition; where-=player[j].coords; - if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].rotation,0); + if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].yaw,0); startpoint=where; where=sprites[i]->position; where-=player[j].coords; - if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].rotation,0); + if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].yaw,0); endpoint=where; movepoint=0; @@ -338,8 +338,8 @@ void Sprite::Draw() start=sprites[i]->oldposition; end=sprites[i]->position; if(!spritehit) - if(objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k])!=-1){ - if(detail==2||(detail==1&&abs(Random()%4)==0)||(detail==0&&abs(Random()%8)==0))objects.model[k].MakeDecal(blooddecalfast,DoRotation(colpoint-objects.position[k],0,-objects.rotation[k],0),sprites[i]->size*1.6/*+abs((float)(Random()%100))/2400*/,.5,Random()%360); + if(objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.yaw[k])!=-1){ + if(detail==2||(detail==1&&abs(Random()%4)==0)||(detail==0&&abs(Random()%8)==0))objects.model[k].MakeDecal(blooddecalfast,DoRotation(colpoint-objects.position[k],0,-objects.yaw[k],0),sprites[i]->size*1.6/*+abs((float)(Random()%100))/2400*/,.5,Random()%360); DeleteSprite(i); spritehit=1; } @@ -438,16 +438,16 @@ Sprite::Sprite() void Sprite::clearTextures() { - if (toothtexture) glDeleteTextures( 1, &toothtexture ); - if (cloudtexture) glDeleteTextures( 1, &cloudtexture ); - if (cloudimpacttexture) glDeleteTextures( 1, &cloudimpacttexture ); - if (bloodtexture) glDeleteTextures( 1, &bloodtexture ); - if (flametexture) glDeleteTextures( 1, &flametexture ); - if (bloodflametexture) glDeleteTextures( 1, &bloodflametexture ); - if (smoketexture) glDeleteTextures( 1, &smoketexture ); - if (snowflaketexture) glDeleteTextures( 1, &snowflaketexture ); - if (shinetexture) glDeleteTextures( 1, &shinetexture ); - if (splintertexture) glDeleteTextures( 1, &splintertexture ); - if (leaftexture) 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(); }