From 9abb51fce0cca32ebe267c4797363d99520c2a0a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 25 Oct 2012 21:43:32 +0300 Subject: Add initial version of mobile OpenGL backend. --- src/graphicsvertexes.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/graphicsvertexes.cpp') diff --git a/src/graphicsvertexes.cpp b/src/graphicsvertexes.cpp index 407d5ef0c..aefe594fd 100644 --- a/src/graphicsvertexes.cpp +++ b/src/graphicsvertexes.cpp @@ -25,6 +25,7 @@ #include "debug.h" #ifdef USE_OPENGL +unsigned int vertexBufSize = 500; int GraphicsVertexes::mUseOpenGL = 0; #endif @@ -43,10 +44,12 @@ NormalOpenGLGraphicsVertexes::NormalOpenGLGraphicsVertexes() : ptr(0), mFloatTexArray(nullptr), mIntTexArray(nullptr), - mIntVertArray(nullptr) + mIntVertArray(nullptr), + mShortVertArray(nullptr) { mFloatTexPool.reserve(30); mIntVertPool.reserve(30); + mShortVertPool.reserve(30); mIntTexPool.reserve(30); mVp.reserve(30); } @@ -72,6 +75,13 @@ void NormalOpenGLGraphicsVertexes::clear() } mIntVertPool.clear(); + for (std::vector::iterator it = mShortVertPool.begin(); + it != mShortVertPool.end(); ++ it) + { + delete [] (*it); + } + mShortVertPool.clear(); + for (std::vector::iterator it = mIntTexPool.begin(); it != mIntTexPool.end(); ++ it) { @@ -86,6 +96,7 @@ void NormalOpenGLGraphicsVertexes::clear() delete []mFloatTexArray; delete []mIntTexArray; delete []mIntVertArray; + delete []mShortVertArray; } } @@ -108,6 +119,13 @@ GLint *NormalOpenGLGraphicsVertexes::switchIntVertArray() return mIntVertArray; } +GLshort *NormalOpenGLGraphicsVertexes::switchShortVertArray() +{ + mShortVertArray = new GLshort[vertexBufSize * 4 + 30]; + mShortVertPool.push_back(mShortVertArray); + return mShortVertArray; +} + GLint *NormalOpenGLGraphicsVertexes::switchIntTexArray() { mIntTexArray = new GLint[vertexBufSize * 4 + 30]; @@ -169,6 +187,20 @@ GLint *NormalOpenGLGraphicsVertexes::continueIntVertArray() return mIntVertArray; } +GLshort *NormalOpenGLGraphicsVertexes::continueShortVertArray() +{ + if (mShortVertPool.empty()) + { + mShortVertArray = new GLshort[vertexBufSize * 4 + 30]; + mShortVertPool.push_back(mShortVertArray); + } + else + { + mShortVertArray = mShortVertPool.back(); + } + return mShortVertArray; +} + GLint *NormalOpenGLGraphicsVertexes::continueIntTexArray() { if (mIntTexPool.empty()) -- cgit v1.2.3-70-g09d2