Quote Originally Posted by hwnd View Post
Here is the way im doing atm:
Code:
 
var texTop, texbottom, texleft, texright:single;
w,h:Single;


  texTop:=0; // This shouldnt be 0 i think, must be calculated?
  texleft:=0; // This shouldnt be 0 i think, must be calculated?
  texbottom:=th /getnextpot(th);
  texright:=tw / getnextpot(tw);


  w:=tw/64;
  h:=th/64;





glBegin( GL_QUADS );
         // Top-left vertex (corner)
         glTexCoord2f( texLeft,    texTop ); glVertex3f( -w/2, -h/2, 0 );

         // Bottom-left vertex (corner)
         glTexCoord2f( texRight,    texTop); glVertex3f( w/2, -h/2, 0 );

         // Bottom-right vertex (corner)
         glTexCoord2f(  texRight, texBottom); glVertex3f( w/2, h/2, 0 );

         // Top-right vertex (corner)
         glTexCoord2f(texLeft, texBottom); glVertex3f( -w/2, h/2, 0 );

   glEnd();
If i modify either texTop and / or texLeft then i can move texture to center.
But then it looks pretty bad, like squeezed together a bit or something.
The problem of this code you had is that you have only been moving texTop and/or texLeft but not texBottom and/or texRight. So instead of moving texture you have actually been scaling it.
You should have changed your code like this:
Code:
 
  texTop:=0; // This shouldnt be 0 i think, must be calculated?
  texleft:=0; // This shouldnt be 0 i think, must be calculated?
  texbottom:=textTop + (th /getnextpot(th)); //Bottom edge is always position of top edge + height
  texright:=texLeft + (tw / getnextpot(tw)); //Right edge is always position of left edge + width