use vertex buffers

This commit is contained in:
Eduardo Bart
2011-12-07 16:49:20 -02:00
parent cc7c334d73
commit 1a3dcb215e
18 changed files with 558 additions and 150 deletions

View File

@@ -52,7 +52,13 @@ void Image::loadFromOTML(const OTMLNodePtr& imageNode)
void Image::draw(const Rect& screenCoords)
{
if(m_texture) {
if(!m_texture)
return;
if(m_cachedScreenCoords != screenCoords) {
m_cachedScreenCoords = screenCoords;
m_coordsBuffer.clear();
if(m_fixedRatio) {
const Size& texSize = m_texture->getSize();
Size texCoordsSize = screenCoords.size();
@@ -63,12 +69,14 @@ void Image::draw(const Rect& screenCoords)
else if(texSize.width() > texCoordsSize.width())
texCoordsOffset.x = (texSize.width() - texCoordsSize.width())/2;
g_painter.drawTexturedRect(screenCoords, m_texture, Rect(texCoordsOffset, texCoordsSize));
m_coordsBuffer.addRect(screenCoords, Rect(texCoordsOffset, texCoordsSize));
} else {
if(m_repeated)
g_painter.drawRepeatedTexturedRect(screenCoords, m_texture, m_textureCoords);
m_coordsBuffer.addRepeatedRects(screenCoords, m_textureCoords);
else
g_painter.drawTexturedRect(screenCoords, m_texture, m_textureCoords);
m_coordsBuffer.addRect(screenCoords, m_textureCoords);
}
}
g_painter.drawTextureCoords(m_coordsBuffer, m_texture);
}