renaming some variables
This commit is contained in:
parent
70a8338804
commit
a5d475aec1
|
@ -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
|
||||
int right = screenCoords.right() + 1;
|
||||
|
@ -143,30 +143,26 @@ void Graphics::drawTexturedRect(const Rect& screenCoords, const Texture *texture
|
|||
int top = screenCoords.top();
|
||||
int left = screenCoords.left();
|
||||
|
||||
float tright;
|
||||
float tbottom;
|
||||
float ttop;
|
||||
float tleft;
|
||||
float textureRight = 0.0f;
|
||||
float textureBottom = 1.0f;
|
||||
float textureTop = 0.0f;
|
||||
float textureLeft = 1.0f;
|
||||
|
||||
if(!texCoords.isEmpty()) {
|
||||
if(!textureCoords.isEmpty()) {
|
||||
const Size& textureSize = texture->getSize();
|
||||
tright = (float)(texCoords.right()+1)/textureSize.width();
|
||||
tbottom = (float)(texCoords.bottom()+1)/textureSize.height();
|
||||
ttop = (float)texCoords.top()/textureSize.height();
|
||||
tleft = (float)texCoords.left()/textureSize.width();
|
||||
} else {
|
||||
tright = 0.0f;
|
||||
tbottom = 1.0f;
|
||||
ttop = 0.0f;
|
||||
tleft = 1.0f;
|
||||
|
||||
textureRight = (float)(textureCoords.right() + 1) / textureSize.width();
|
||||
textureBottom = (float)(textureCoords.bottom() + 1) / textureSize.height();
|
||||
textureTop = (float)textureCoords.top() / textureSize.height();
|
||||
textureLeft = (float)textureCoords.left() / textureSize.width();
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texture->getTextureId());
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(tleft, ttop); glVertex2i(left, top);
|
||||
glTexCoord2f(tleft, tbottom); glVertex2i(left, bottom);
|
||||
glTexCoord2f(tright, tbottom); glVertex2i(right, bottom);
|
||||
glTexCoord2f(tright, ttop); glVertex2i(right, top);
|
||||
glTexCoord2f(textureLeft, textureTop); glVertex2i(left, top);
|
||||
glTexCoord2f(textureLeft, textureBottom); glVertex2i(left, bottom);
|
||||
glTexCoord2f(textureRight, textureBottom); glVertex2i(right, bottom);
|
||||
glTexCoord2f(textureRight, textureTop); glVertex2i(right, top);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
@ -209,7 +205,6 @@ void Graphics::drawBoundingRect(const Rect& screenCoords, const Color& color, in
|
|||
int left = screenCoords.left();
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
// top line
|
||||
glVertex2i(left, top);
|
||||
glVertex2i(left, top + innerLineWidth);
|
||||
|
@ -233,7 +228,6 @@ void Graphics::drawBoundingRect(const Rect& screenCoords, const Color& color, in
|
|||
glVertex2i(right , bottom - innerLineWidth);
|
||||
glVertex2i(right - innerLineWidth, bottom - innerLineWidth);
|
||||
glVertex2i(right - innerLineWidth, top + innerLineWidth);
|
||||
|
||||
glEnd();
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
|
Loading…
Reference in New Issue