From 932a7f3ca748f04448c72c5d31515bc3a8008144 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 17 Jul 2011 21:08:56 +0300 Subject: Optimisation in drawing map in opengl mode. --- src/map.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/map.cpp') diff --git a/src/map.cpp b/src/map.cpp index d5d74f4df..6fbf28718 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -271,6 +271,7 @@ void MapLayer::updateOGL(Graphics *graphics, int startX, int startY, const int yWidth = y * mWidth; const int py0 = y * 32 + dy; + std::map imgSet; for (int x = startX; x < endX; x++) { @@ -284,9 +285,17 @@ void MapLayer::updateOGL(Graphics *graphics, int startX, int startY, { if (lastImage != img) { - imgVert = new ImageVertexes(); - imgVert->image = img; - row->images.push_back(imgVert); + imgSet[lastImage] = imgVert; + if (imgSet.find(img) != imgSet.end()) + { + imgVert = imgSet[img]; + } + else + { + imgVert = new ImageVertexes(); + imgVert->image = img; + row->images.push_back(imgVert); + } lastImage = img; } graphics->calcTile(imgVert, px, py); -- cgit v1.2.3-60-g2f50