FIXED: Shader-related crashes when uninitializing OpenGL renderer
This commit is contained in:
parent
1ad8fe2c8f
commit
658bf188cc
|
@ -89,6 +89,7 @@ private:
|
||||||
GLFONT font;
|
GLFONT font;
|
||||||
int VertexShader,FragmentShader,textureLocation,ShaderProgram,g_location_grayScaleWeights;
|
int VertexShader,FragmentShader,textureLocation,ShaderProgram,g_location_grayScaleWeights;
|
||||||
char *VertexShaderSource,*FragmentShaderSource;
|
char *VertexShaderSource,*FragmentShaderSource;
|
||||||
|
bool shaderFuncInited;
|
||||||
|
|
||||||
void initializeMatrices( int w, int h );
|
void initializeMatrices( int w, int h );
|
||||||
bool initializeTexture( int w, int h );
|
bool initializeTexture( int w, int h );
|
||||||
|
@ -210,6 +211,8 @@ void OpenGLDisplay::SetGLSLShaderConstants()
|
||||||
|
|
||||||
}
|
}
|
||||||
void OpenGLDisplay::DeInitGLSLShader (void) {
|
void OpenGLDisplay::DeInitGLSLShader (void) {
|
||||||
|
if( !shaderFuncInited ) return;
|
||||||
|
|
||||||
if (VertexShader != 0){
|
if (VertexShader != 0){
|
||||||
glDeleteObjectARB(VertexShader);
|
glDeleteObjectARB(VertexShader);
|
||||||
}
|
}
|
||||||
|
@ -219,7 +222,7 @@ void OpenGLDisplay::DeInitGLSLShader (void) {
|
||||||
if (FragmentShader != 0){
|
if (FragmentShader != 0){
|
||||||
glDeleteObjectARB(ShaderProgram);
|
glDeleteObjectARB(ShaderProgram);
|
||||||
}
|
}
|
||||||
|
shaderFuncInited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenGLDisplay::OpenGLDisplay()
|
OpenGLDisplay::OpenGLDisplay()
|
||||||
|
@ -232,6 +235,7 @@ OpenGLDisplay::OpenGLDisplay()
|
||||||
size = 0.0f;
|
size = 0.0f;
|
||||||
failed = false;
|
failed = false;
|
||||||
filterData = NULL;
|
filterData = NULL;
|
||||||
|
shaderFuncInited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -268,7 +272,6 @@ void OpenGLDisplay::DisableOpenGL()
|
||||||
|
|
||||||
void OpenGLDisplay::cleanup()
|
void OpenGLDisplay::cleanup()
|
||||||
{
|
{
|
||||||
|
|
||||||
DeInitGLSLShader();
|
DeInitGLSLShader();
|
||||||
|
|
||||||
if(texture != 0) {
|
if(texture != 0) {
|
||||||
|
@ -318,6 +321,7 @@ bool OpenGLDisplay::initialize()
|
||||||
glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)wglGetProcAddress("glGetUniformLocationARB");
|
glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)wglGetProcAddress("glGetUniformLocationARB");
|
||||||
glUniform4fARB = (PFNGLUNIFORM4FARBPROC)wglGetProcAddress("glUniform4fARB");
|
glUniform4fARB = (PFNGLUNIFORM4FARBPROC)wglGetProcAddress("glUniform4fARB");
|
||||||
glUniform1iARB = (PFNGLUNIFORM1IARBPROC)wglGetProcAddress("glUniform1iARB");
|
glUniform1iARB = (PFNGLUNIFORM1IARBPROC)wglGetProcAddress("glUniform1iARB");
|
||||||
|
shaderFuncInited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeMatrices( theApp.surfaceSizeX, theApp.surfaceSizeY );
|
initializeMatrices( theApp.surfaceSizeX, theApp.surfaceSizeY );
|
||||||
|
@ -359,15 +363,11 @@ void OpenGLDisplay::clear()
|
||||||
void OpenGLDisplay::render()
|
void OpenGLDisplay::render()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
if (theApp.GLSLShaders){
|
if (theApp.GLSLShaders && shaderFuncInited){
|
||||||
InitGLSLShader();
|
InitGLSLShader();
|
||||||
glUseProgramObjectARB( ShaderProgram );
|
glUseProgramObjectARB( ShaderProgram );
|
||||||
SetGLSLShaderConstants();
|
SetGLSLShaderConstants();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
DeInitGLSLShader();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int pitch = theApp.filterWidth * (systemColorDepth>>3) + 4;
|
int pitch = theApp.filterWidth * (systemColorDepth>>3) + 4;
|
||||||
|
|
Loading…
Reference in New Issue