summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-04-12 21:44:32 +0200
committerMichael Lutz <michi@icosahedron.de>2021-04-12 22:40:40 +0200
commit433602b072aaf6a2c07a9989e7989f2dd0bb8317 (patch)
tree7589171ad762105b4470fe6168c89f412e2455e3 /src
parent468b1c6c5d1949f4d8aad90dad0f3d8770973113 (diff)
downloadopenttd-433602b072aaf6a2c07a9989e7989f2dd0bb8317.tar.xz
Fix #9028: [OpenGL] Clear cursor cache on destroying the OpenGL backend.
Diffstat (limited to 'src')
-rw-r--r--src/video/opengl.cpp22
-rw-r--r--src/video/opengl.h2
2 files changed, 17 insertions, 7 deletions
diff --git a/src/video/opengl.cpp b/src/video/opengl.cpp
index c1c1afaae..bb509bcd7 100644
--- a/src/video/opengl.cpp
+++ b/src/video/opengl.cpp
@@ -510,7 +510,7 @@ OpenGLBackend::~OpenGLBackend()
_glDeleteBuffers(1, &this->anim_pbo);
}
if (_glDeleteTextures != nullptr) {
- ClearCursorCache();
+ this->InternalClearCursorCache();
OpenGLSprite::Destroy();
_glDeleteTextures(1, &this->vid_texture);
@@ -1082,12 +1082,7 @@ void OpenGLBackend::PopulateCursorCache()
this->clear_cursor_cache = false;
this->last_sprite_pal = (PaletteID)-1;
- Sprite *sp;
- while ((sp = this->cursor_cache.Pop()) != nullptr) {
- OpenGLSprite *sprite = (OpenGLSprite *)sp->data;
- sprite->~OpenGLSprite();
- free(sp);
- }
+ this->InternalClearCursorCache();
}
this->cursor_pos = _cursor.pos;
@@ -1113,6 +1108,19 @@ void OpenGLBackend::PopulateCursorCache()
/**
* Clear all cached cursor sprites.
*/
+void OpenGLBackend::InternalClearCursorCache()
+{
+ Sprite *sp;
+ while ((sp = this->cursor_cache.Pop()) != nullptr) {
+ OpenGLSprite *sprite = (OpenGLSprite *)sp->data;
+ sprite->~OpenGLSprite();
+ free(sp);
+ }
+}
+
+/**
+ * Queue a request for cursor cache clear.
+ */
void OpenGLBackend::ClearCursorCache()
{
/* If the game loop is threaded, this function might be called
diff --git a/src/video/opengl.h b/src/video/opengl.h
index 7e42b20be..b0318f988 100644
--- a/src/video/opengl.h
+++ b/src/video/opengl.h
@@ -77,6 +77,8 @@ private:
const char *Init();
bool InitShaders();
+ void InternalClearCursorCache();
+
void RenderOglSprite(OpenGLSprite *gl_sprite, PaletteID pal, int x, int y, ZoomLevel zoom);
public: