From 6afba95ef62b22c303336adba6d891eeffe66c49 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 17 Jul 2011 18:16:49 +0300 Subject: Add basic tiles caching for opengl. --- src/graphicsvertexes.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) (limited to 'src/graphicsvertexes.cpp') diff --git a/src/graphicsvertexes.cpp b/src/graphicsvertexes.cpp index d905b8b64..b8e236310 100644 --- a/src/graphicsvertexes.cpp +++ b/src/graphicsvertexes.cpp @@ -110,6 +110,62 @@ void OpenGLGraphicsVertexes::switchVp(int n) { mVp.push_back(n); } + +int OpenGLGraphicsVertexes::continueVp() +{ + if (mVp.empty()) + { + return 0; + } + else + { + const int val = mVp.back(); + mVp.pop_back(); + return val; + } +} + +GLfloat *OpenGLGraphicsVertexes::continueFloatTexArray() +{ + if (mFloatTexPool.empty()) + { + mFloatTexArray = new GLfloat[vertexBufSize * 4 + 30]; + mFloatTexPool.push_back(mFloatTexArray); + } + else + { + mFloatTexArray = mFloatTexPool.back(); + } + return mFloatTexArray; +} + +GLint *OpenGLGraphicsVertexes::continueIntVertArray() +{ + if (mIntVertPool.empty()) + { + mIntVertArray = new GLint[vertexBufSize * 4 + 30]; + mIntVertPool.push_back(mIntVertArray); + } + else + { + mIntVertArray = mIntVertPool.back(); + } + return mIntVertArray; +} + +GLint *OpenGLGraphicsVertexes::continueIntTexArray() +{ + if (mIntTexPool.empty()) + { + mIntTexArray = new GLint[vertexBufSize * 4 + 30]; + mIntTexPool.push_back(mIntTexArray); + } + else + { + mIntTexArray = mIntTexPool.back(); + } + return mIntTexArray; +} #endif GraphicsVertexes::GraphicsVertexes() : @@ -171,7 +227,7 @@ ImageVertexes::~ImageVertexes() delete_all(sdl); sdl.clear(); #ifdef USE_OPENGL - delete_all(ogl); - ogl.clear(); + delete ogl; + ogl = 0; #endif } -- cgit v1.2.3-60-g2f50