summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-07-17 18:16:49 +0300
committerAndrei Karas <akaras@inbox.ru>2011-07-17 20:08:12 +0300
commit6afba95ef62b22c303336adba6d891eeffe66c49 (patch)
tree2e395c216f22479064ad5cf2bda612d8ecb9f201 /src/map.cpp
parentb83bca17d42761c41f097ea315d01bb89105f618 (diff)
downloadplus-6afba95ef62b22c303336adba6d891eeffe66c49.tar.gz
plus-6afba95ef62b22c303336adba6d891eeffe66c49.tar.bz2
plus-6afba95ef62b22c303336adba6d891eeffe66c49.tar.xz
plus-6afba95ef62b22c303336adba6d891eeffe66c49.zip
Add basic tiles caching for opengl.
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp61
1 files changed, 35 insertions, 26 deletions
diff --git a/src/map.cpp b/src/map.cpp
index c5a7a8816..d5d74f4df 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -239,13 +239,9 @@ void MapLayer::updateOGL(Graphics *graphics, int startX, int startY,
int endX, int endY, int scrollX, int scrollY,
int debugFlags)
{
+ delete_all(mTempRows);
+ mTempRows.clear();
-}
-
-void MapLayer::drawOGL(Graphics *graphics, int startX, int startY,
- int endX, int endY, int scrollX, int scrollY,
- int debugFlags)
-{
startX -= mX;
startY -= mY;
endX -= mX;
@@ -267,42 +263,56 @@ void MapLayer::drawOGL(Graphics *graphics, int startX, int startY,
for (int y = startY; y < endY; y++)
{
- const int y32 = y * 32;
- const int yWidth = y * mWidth;
+ MapRowVertexes *row = new MapRowVertexes();
+ mTempRows.push_back(row);
- const int py0 = y32 + dy;
+ Image *lastImage = 0;
+ ImageVertexes *imgVert = 0;
+
+ const int yWidth = y * mWidth;
+ const int py0 = y * 32 + dy;
for (int x = startX; x < endX; x++)
{
- const int x32 = x * 32;
-
const int tilePtr = x + yWidth;
- int c = 0;
Image *img = mTiles[tilePtr];
if (img)
{
- const int px = x32 + dx;
+ const int px = x * 32 + dx;
const int py = py0 - img->mBounds.h;
if (flag || img->mBounds.h <= 32)
{
- int width = 0;
- // here need not draw over player position
- c = getTileDrawWidth(tilePtr, endX - x, width);
-
- if (!c)
- {
- graphics->drawImage(img, px, py);
- }
- else
+ if (lastImage != img)
{
- graphics->drawImagePattern(img, px, py,
- width, img->mBounds.h);
+ imgVert = new ImageVertexes();
+ imgVert->image = img;
+ row->images.push_back(imgVert);
+ lastImage = img;
}
+ graphics->calcTile(imgVert, px, py);
}
}
+ }
+ }
+}
- x += c;
+void MapLayer::drawOGL(Graphics *graphics, int startX, int startY,
+ int endX, int endY, int scrollX, int scrollY,
+ int debugFlags)
+{
+ MapRows::iterator rit = mTempRows.begin();
+ MapRows::iterator rit_end = mTempRows.end();
+ while (rit != rit_end)
+ {
+ MepRowImages *images = &(*rit)->images;
+ MepRowImages::iterator iit = images->begin();
+ MepRowImages::iterator iit_end = images->end();
+ while (iit != iit_end)
+ {
+ graphics->drawTile(*iit);
+ ++ iit;
}
+ ++ rit;
}
}
@@ -743,7 +753,6 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY)
mLastScrollX = scrollX;
mLastScrollY = scrollY;
updateFlag = 2;
-// updateMapLayer(this, endX, endY, debugFlags);
}
if (mDebugFlags == MAP_SPECIAL3 || mDebugFlags == MAP_BLACKWHITE)