mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-27 05:32:45 +00:00
OPENGL: Handle destruction gracefully when no context is setup.
This commit is contained in:
parent
fee1aa5502
commit
d029f16799
@ -111,7 +111,13 @@ extern Context g_context;
|
||||
|
||||
} // End of namespace OpenGL
|
||||
|
||||
#define GL_CALL(x) GL_WRAP_DEBUG(g_context.x, x)
|
||||
#define GL_ASSIGN(var, x) GL_WRAP_DEBUG(var = g_context.x, x)
|
||||
#define GL_CALL(x) GL_WRAP_DEBUG(g_context.x, x)
|
||||
#define GL_CALL_SAFE(func, params) \
|
||||
do { \
|
||||
if (g_context.func) { \
|
||||
GL_CALL(func params); \
|
||||
} \
|
||||
} while (0)
|
||||
#define GL_ASSIGN(var, x) GL_WRAP_DEBUG(var = g_context.x, x)
|
||||
|
||||
#endif
|
||||
|
@ -74,6 +74,15 @@ ShaderARB::ShaderARB(const Common::String &vertex, const Common::String &fragmen
|
||||
: Shader(vertex, fragment), _program(0), _projectionLocation(-1), _textureLocation(-1) {
|
||||
}
|
||||
|
||||
ShaderARB::~ShaderARB() {
|
||||
// According to extension specification glDeleteObjectARB silently ignores
|
||||
// 0. However, with nVidia drivers this can cause GL_INVALID_VALUE, thus
|
||||
// we do not call it with 0 as parameter to avoid warnings.
|
||||
if (_program) {
|
||||
GL_CALL_SAFE(glDeleteObjectARB, (_program));
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderARB::destroy() {
|
||||
// According to extension specification glDeleteObjectARB silently ignores
|
||||
// 0. However, with nVidia drivers this can cause GL_INVALID_VALUE, thus
|
||||
@ -200,6 +209,10 @@ ShaderGLES2::ShaderGLES2(const Common::String &vertex, const Common::String &fra
|
||||
: Shader(vertex, fragment), _program(0), _projectionLocation(-1), _textureLocation(-1) {
|
||||
}
|
||||
|
||||
ShaderGLES2::~ShaderGLES2() {
|
||||
GL_CALL_SAFE(glDeleteProgram, (_program));
|
||||
}
|
||||
|
||||
void ShaderGLES2::destroy() {
|
||||
GL_CALL(glDeleteProgram(_program));
|
||||
_program = 0;
|
||||
|
@ -88,7 +88,7 @@ protected:
|
||||
class ShaderARB : public Shader {
|
||||
public:
|
||||
ShaderARB(const Common::String &vertex, const Common::String &fragment);
|
||||
virtual ~ShaderARB() { destroy(); }
|
||||
virtual ~ShaderARB();
|
||||
|
||||
virtual void destroy();
|
||||
|
||||
@ -127,7 +127,7 @@ private:
|
||||
class ShaderGLES2 : public Shader {
|
||||
public:
|
||||
ShaderGLES2(const Common::String &vertex, const Common::String &fragment);
|
||||
virtual ~ShaderGLES2() { destroy(); }
|
||||
virtual ~ShaderGLES2();
|
||||
|
||||
virtual void destroy();
|
||||
|
||||
|
@ -54,7 +54,7 @@ Texture::Texture(GLenum glIntFormat, GLenum glFormat, GLenum glType, const Graph
|
||||
}
|
||||
|
||||
Texture::~Texture() {
|
||||
releaseInternalTexture();
|
||||
GL_CALL_SAFE(glDeleteTextures, (1, &_glTexture));
|
||||
_textureData.free();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user