summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/render/graphics.cpp2
-rw-r--r--src/render/graphics.h5
-rw-r--r--src/render/mobileopenglgraphics.cpp26
-rw-r--r--src/render/normalopenglgraphics.cpp32
-rw-r--r--src/render/nullopenglgraphics.cpp8
-rw-r--r--src/render/openglgraphicsdef.hpp2
-rw-r--r--src/render/openglgraphicsdefadvanced.hpp4
-rw-r--r--src/render/safeopenglgraphics.cpp4
-rw-r--r--src/test/testmain.cpp3
9 files changed, 66 insertions, 20 deletions
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index baceeacc1..44307add7 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -293,7 +293,7 @@ bool Graphics::setOpenGLMode()
(gotDoubleBuffer ? "with" : "without"));
graphicsManager.initOpenGL();
- initArrays();
+ initArrays(graphicsManager.getMaxVertices());
graphicsManager.updateTextureFormat();
updateMemoryInfo();
diff --git a/src/render/graphics.h b/src/render/graphics.h
index 58e08888a..90029717e 100644
--- a/src/render/graphics.h
+++ b/src/render/graphics.h
@@ -295,7 +295,7 @@ class Graphics
const std::string &getName() const A_WARN_UNUSED
{ return mName; }
- virtual void initArrays()
+ virtual void initArrays(const int vertCount A_UNUSED)
{ }
virtual void setColor(const Color &color)
@@ -447,6 +447,9 @@ class Graphics
virtual void clearScreen() const
{ }
+ virtual void deleteArrays()
+ { }
+
int mWidth;
int mHeight;
int mActualWidth;
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index 8150c4f66..34e5c334c 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -99,15 +99,12 @@ MobileOpenGLGraphics::MobileOpenGLGraphics():
MobileOpenGLGraphics::~MobileOpenGLGraphics()
{
- delete [] mFloatTexArray;
- delete [] mShortVertArray;
- delete [] mFloatTexArrayCached;
- delete [] mShortVertArrayCached;
+ deleteArraysInternal();
}
-void MobileOpenGLGraphics::initArrays()
+void MobileOpenGLGraphics::initArrays(const int vertCount)
{
- mMaxVertices = graphicsManager.getMaxVertices();
+ mMaxVertices = vertCount;
if (mMaxVertices < 500)
mMaxVertices = 500;
else if (mMaxVertices > 1024)
@@ -126,6 +123,23 @@ void MobileOpenGLGraphics::initArrays()
mShortVertArrayCached = new GLshort[sz];
}
+void MobileOpenGLGraphics::deleteArrays()
+{
+ deleteArraysInternal();
+}
+
+void MobileOpenGLGraphics::deleteArraysInternal()
+{
+ delete [] mFloatTexArray;
+ mFloatTexArray = nullptr;
+ delete [] mShortVertArray;
+ mShortVertArray = nullptr;
+ delete [] mFloatTexArrayCached;
+ mFloatTexArrayCached = nullptr;
+ delete [] mShortVertArrayCached;
+ mShortVertArrayCached = nullptr;
+}
+
bool MobileOpenGLGraphics::setVideoMode(const int w, const int h,
const int scale,
const int bpp,
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index 75064a435..c7b01c4d2 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -115,17 +115,12 @@ NormalOpenGLGraphics::NormalOpenGLGraphics():
NormalOpenGLGraphics::~NormalOpenGLGraphics()
{
- delete [] mFloatTexArray;
- delete [] mIntTexArray;
- delete [] mIntVertArray;
- delete [] mFloatTexArrayCached;
- delete [] mIntTexArrayCached;
- delete [] mIntVertArrayCached;
+ deleteArraysInternal();
}
-void NormalOpenGLGraphics::initArrays()
+void NormalOpenGLGraphics::initArrays(const int vertCount)
{
- mMaxVertices = graphicsManager.getMaxVertices();
+ mMaxVertices = vertCount;
if (mMaxVertices < 500)
mMaxVertices = 500;
else if (mMaxVertices > 1024)
@@ -148,6 +143,27 @@ void NormalOpenGLGraphics::initArrays()
mIntVertArrayCached = new GLint[sz];
}
+void NormalOpenGLGraphics::deleteArrays()
+{
+ deleteArraysInternal();
+}
+
+void NormalOpenGLGraphics::deleteArraysInternal()
+{
+ delete [] mFloatTexArray;
+ mFloatTexArray = nullptr;
+ delete [] mIntTexArray;
+ mIntTexArray = nullptr;
+ delete [] mIntVertArray;
+ mIntVertArray = nullptr;
+ delete [] mFloatTexArrayCached;
+ mFloatTexArrayCached = nullptr;
+ delete [] mIntTexArrayCached;
+ mIntTexArrayCached = nullptr;
+ delete [] mIntVertArrayCached;
+ mIntVertArrayCached = nullptr;
+}
+
bool NormalOpenGLGraphics::setVideoMode(const int w, const int h,
const int scale,
const int bpp,
diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp
index ca6fa1660..4498ed9c6 100644
--- a/src/render/nullopenglgraphics.cpp
+++ b/src/render/nullopenglgraphics.cpp
@@ -71,9 +71,9 @@ NullOpenGLGraphics::~NullOpenGLGraphics()
delete [] mIntVertArray;
}
-void NullOpenGLGraphics::initArrays()
+void NullOpenGLGraphics::initArrays(const int vertCount)
{
- mMaxVertices = graphicsManager.getMaxVertices();
+ mMaxVertices = vertCount;
if (mMaxVertices < 500)
mMaxVertices = 500;
else if (mMaxVertices > 1024)
@@ -90,6 +90,10 @@ void NullOpenGLGraphics::initArrays()
mIntVertArray = new GLint[sz];
}
+void NullOpenGLGraphics::deleteArrays()
+{
+}
+
bool NullOpenGLGraphics::setVideoMode(const int w, const int h,
const int scale,
const int bpp,
diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp
index 1df90e3ee..e99c4cc62 100644
--- a/src/render/openglgraphicsdef.hpp
+++ b/src/render/openglgraphicsdef.hpp
@@ -51,6 +51,8 @@ public:
void clearScreen() const override final;
+ void deleteArrays() override final;
+
static void bindTexture(const GLenum target, const GLuint texture);
static GLuint mLastImage;
diff --git a/src/render/openglgraphicsdefadvanced.hpp b/src/render/openglgraphicsdefadvanced.hpp
index 07c706af3..bb45035c3 100644
--- a/src/render/openglgraphicsdefadvanced.hpp
+++ b/src/render/openglgraphicsdefadvanced.hpp
@@ -23,7 +23,7 @@
public:
inline void drawVertexes(const NormalOpenGLGraphicsVertexes &ogl);
- void initArrays() override final;
+ void initArrays(const int vertCount) override final;
#ifdef DEBUG_DRAW_CALLS
unsigned int getDrawCalls() const
@@ -36,3 +36,5 @@ public:
protected:
void debugBindTexture(const Image *const image);
+
+ void deleteArraysInternal();
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index 236e09841..bc22b3c69 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -56,6 +56,10 @@ SafeOpenGLGraphics::~SafeOpenGLGraphics()
{
}
+void SafeOpenGLGraphics::deleteArrays()
+{
+}
+
bool SafeOpenGLGraphics::setVideoMode(const int w, const int h,
const int scale,
const int bpp,
diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp
index 53703dbc6..d21cd2dac 100644
--- a/src/test/testmain.cpp
+++ b/src/test/testmain.cpp
@@ -192,7 +192,8 @@ int TestMain::exec(const bool testAudio)
int batchSize = 256;
// if OpenGL mode is fast mode we can try detect max batch sizes
- if (openGLMode == RENDER_NORMAL_OPENGL)
+ if (openGLMode == RENDER_NORMAL_OPENGL
+ || openGLMode == RENDER_GLES_OPENGL)
{
if (!invokeFastOpenBatchTest("11"))
batchSize = readValue2(11);