renaming some variables

This commit is contained in:
Andre Antunes 2011-04-04 21:39:57 -03:00
parent 70a8338804
commit a5d475aec1
1 changed files with 41 additions and 47 deletions

View File

@ -135,7 +135,7 @@ void Graphics::endRender()
} }
void Graphics::drawTexturedRect(const Rect& screenCoords, const Texture *texture, const Rect& texCoords) void Graphics::drawTexturedRect(const Rect& screenCoords, const Texture *texture, const Rect& textureCoords)
{ {
// rect correction for opengl // rect correction for opengl
int right = screenCoords.right() + 1; int right = screenCoords.right() + 1;
@ -143,30 +143,26 @@ void Graphics::drawTexturedRect(const Rect& screenCoords, const Texture *texture
int top = screenCoords.top(); int top = screenCoords.top();
int left = screenCoords.left(); int left = screenCoords.left();
float tright; float textureRight = 0.0f;
float tbottom; float textureBottom = 1.0f;
float ttop; float textureTop = 0.0f;
float tleft; float textureLeft = 1.0f;
if(!texCoords.isEmpty()) { if(!textureCoords.isEmpty()) {
const Size& textureSize = texture->getSize(); const Size& textureSize = texture->getSize();
tright = (float)(texCoords.right()+1)/textureSize.width();
tbottom = (float)(texCoords.bottom()+1)/textureSize.height(); textureRight = (float)(textureCoords.right() + 1) / textureSize.width();
ttop = (float)texCoords.top()/textureSize.height(); textureBottom = (float)(textureCoords.bottom() + 1) / textureSize.height();
tleft = (float)texCoords.left()/textureSize.width(); textureTop = (float)textureCoords.top() / textureSize.height();
} else { textureLeft = (float)textureCoords.left() / textureSize.width();
tright = 0.0f;
tbottom = 1.0f;
ttop = 0.0f;
tleft = 1.0f;
} }
glBindTexture(GL_TEXTURE_2D, texture->getTextureId()); glBindTexture(GL_TEXTURE_2D, texture->getTextureId());
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(tleft, ttop); glVertex2i(left, top); glTexCoord2f(textureLeft, textureTop); glVertex2i(left, top);
glTexCoord2f(tleft, tbottom); glVertex2i(left, bottom); glTexCoord2f(textureLeft, textureBottom); glVertex2i(left, bottom);
glTexCoord2f(tright, tbottom); glVertex2i(right, bottom); glTexCoord2f(textureRight, textureBottom); glVertex2i(right, bottom);
glTexCoord2f(tright, ttop); glVertex2i(right, top); glTexCoord2f(textureRight, textureTop); glVertex2i(right, top);
glEnd(); glEnd();
} }
@ -209,7 +205,6 @@ void Graphics::drawBoundingRect(const Rect& screenCoords, const Color& color, in
int left = screenCoords.left(); int left = screenCoords.left();
glBegin(GL_QUADS); glBegin(GL_QUADS);
// top line // top line
glVertex2i(left, top); glVertex2i(left, top);
glVertex2i(left, top + innerLineWidth); glVertex2i(left, top + innerLineWidth);
@ -233,7 +228,6 @@ void Graphics::drawBoundingRect(const Rect& screenCoords, const Color& color, in
glVertex2i(right , bottom - innerLineWidth); glVertex2i(right , bottom - innerLineWidth);
glVertex2i(right - innerLineWidth, bottom - innerLineWidth); glVertex2i(right - innerLineWidth, bottom - innerLineWidth);
glVertex2i(right - innerLineWidth, top + innerLineWidth); glVertex2i(right - innerLineWidth, top + innerLineWidth);
glEnd(); glEnd();
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);