]> git.jsancho.org Git - lugaru.git/commitdiff
Simplify DoMipmaps
authorAlexander Monakov <amonakov@gmail.com>
Sat, 1 Jan 2011 21:43:13 +0000 (00:43 +0300)
committerAlexander Monakov <amonakov@gmail.com>
Sat, 1 Jan 2011 21:43:13 +0000 (00:43 +0300)
* * *
foldme

Source/GameTick.cpp
Source/Globals.cpp
Source/Person.cpp
Source/Person.h

index 38d379ecbe6da7f6b1c6cf86c51fe37f9bab95af..6deec4030fe73405b37c88a878b3a8e20896b5f6 100644 (file)
@@ -610,7 +610,7 @@ static void set_clothes(int pnum, Game *game, const char *args)
   if (!game->AddClothes(buf,0,1,&player[pnum].skeleton.skinText[pnum],&player[pnum].skeleton.skinsize))
     return;
 
-  player[pnum].DoMipmaps(5,0,0,player[pnum].skeleton.skinsize,player[pnum].skeleton.skinsize);
+  player[pnum].DoMipmaps();
   strcpy(player[pnum].clothes[player[pnum].numclothes],buf);
   player[pnum].clothestintr[player[pnum].numclothes]=tintr;
   player[pnum].clothestintg[player[pnum].numclothes]=tintg;
@@ -2060,7 +2060,7 @@ void      Game::Loadlevel(char *name){
                                        tintb=player[i].clothestintb[j];
                                        AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
                                }
-                               player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
+                               player[i].DoMipmaps();
                        }
 
                        player[i].currentanimation=bounceidleanim;
@@ -4426,7 +4426,7 @@ void      Game::Tick()
                                                                                tintb=player[closest].clothestintb[i];
                                                                                AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
                                                                        }
-                                                                       player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
+                                                                       player[closest].DoMipmaps();
                                                                }
 
                                                                detailtogglekeydown=1;
@@ -4884,7 +4884,7 @@ void      Game::Tick()
                                                                                AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
                                                                        }
                                                                        if(player[numplayers].numclothes){
-                                                                               player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
+                                                                               player[numplayers].DoMipmaps();
                                                                        }
 
                                                                        player[numplayers].power=player[0].power;
index 901ac1afe90f18d84fa9500969187bb144c6d6bf..a4fa92e65be18f850bcb020e03de494d82df8b8e 100644 (file)
@@ -126,7 +126,6 @@ short vRefNum = 0;
 long dirID = 0;
 int mainmenu = 0;
 int oldmainmenu = 0;
-GLubyte texturearray[512*512*3] = {0};
 int loadscreencolor = 0;
 int whichjointstartarray[26] = {0};
 int whichjointendarray[26] = {0};
index b60c350671527402c85e3075e9bc532f0949c9d0..3640a0b224d54a146a39d0e7f87b1bbd7bb809b0 100644 (file)
@@ -67,7 +67,6 @@ extern bool tiltweird;
 extern bool midweird;
 extern bool proportionweird;
 extern bool vertexweird[6];
-extern GLubyte texturearray[512*512*3];
 extern XYZ envsound[30];
 extern float envsoundvol[30];
 extern float envsoundlife[30];
@@ -475,8 +474,7 @@ void Person::DoBloodBig(float howmuch,int which){
                                                                }
                                                        }
                                                        glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
-                                                       if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
-                                                       else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
+                                                       DoMipmaps();
 
                                                        bleedxint=0;
                                                        bleedyint=0;
@@ -704,8 +702,7 @@ bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
                                                                }
                                                        }
                                                        glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
-                                                       if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
-                                                       else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
+                                                       DoMipmaps();
 
                                                        bleedy=(1+coordsy)*512;
                                                        bleedx=coordsx*512;
@@ -735,73 +732,6 @@ bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
 }
 
 
-void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
-       int i,j,k;
-       static float temp;
-       static int bytesPerPixel=3;
-       static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
-       static int newstartx,newstarty,newendx,newendy;
-       static int newnewstartx,newnewstarty,newnewendx,newnewendy;
-       static int which;
-       static float sizemult;
-       /*
-       for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
-       texture[i]=skeleton.skinText[i];
-       }
-       */
-       if((!osx||howmanylevels)){
-
-               if(startx<0)startx=0;
-               if(starty<0)starty=0;
-               if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
-               if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
-               if((endx>startx&&endy>starty)||howmanylevels){
-
-                       newstartx=startx;
-                       newstarty=starty;
-                       newendx=endx;
-                       newendy=endy;
-
-                       for(i=startx;i<endx;i++){
-                               for(j=starty;j<endy;j++){
-                                       texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
-                                       texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
-                                       texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
-                               }
-                       }
-
-                       glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
-
-                       if(!howmanylevels){
-                               if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
-                               glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
-                               if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
-                       }
-
-                       newsize=skeleton.skinsize;
-
-                       if(howmanylevels)
-                               gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
-               }
-               /*for(j=1;j<=howmanylevels;j++){
-               if(j==1)texpointer=&skeleton.skinText[0];
-               else texpointer=&texture[0];
-
-               totalsize=int( newsize*newsize*bytesPerPixel);
-               rowsize=int( newsize*bytesPerPixel );
-               bigstep=bytesPerPixel*newsize*2;
-               smallstep=bytesPerPixel*2;
-
-               which=0;
-
-
-
-               glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
-               newsize/=2;
-               }*/
-       }
-}
-
 
 void Person::Reverse(){
        if(victim->aitype==playercontrolled||hostiletime>1)
@@ -3915,7 +3845,7 @@ void      Person::DoStuff(){
                bleeding-=multiplier*.3;
                if(bloodtoggle==2){
                        glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
-                       if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
+                       if(bleeding<=0&&(detail!=2||osx))DoMipmaps();
                }
        }
 
@@ -4042,7 +3972,7 @@ void      Person::DoStuff(){
                }
                if(!osx&&detail>1){
                        glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
-                       DoMipmaps(0,startx,endx,starty,endy);
+                       DoMipmaps();
                }
 
                if(!skeleton.free){
index 88826338cf724c738fa103b1a8f3112e6508be2f..b831b28448914a1184ded9576b5e56af8d0488cd 100644 (file)
@@ -411,7 +411,16 @@ struct Person
                void Reverse();
                void DoDamage(float howmuch);
                void DoHead();
-               void DoMipmaps(int howmanylevels, float startx, float endx, float starty, float endy);
+               void DoMipmaps()
+               {
+                 glBindTexture(GL_TEXTURE_2D, skeleton.drawmodel.textureptr);
+                 gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB,
+                                   skeleton.skinsize,
+                                   skeleton.skinsize,
+                                   GL_RGB, GL_UNSIGNED_BYTE,
+                                   &skeleton.skinText[0]);
+               }
+
                int SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
                int DrawSkeleton();
                void Puff(int whichlabel);