win32: only reload shader if filename changes

This commit is contained in:
OV2 2019-02-01 00:07:09 +01:00
parent 1dc7eec15d
commit 47dce09600
2 changed files with 22 additions and 8 deletions

View File

@ -40,6 +40,7 @@ COpenGL::COpenGL(void)
frameCount = 0;
cgShader = NULL;
glslShader = NULL;
*currentShaderFile = _T('\0');
}
COpenGL::~COpenGL(void)
@ -523,19 +524,31 @@ bool COpenGL::LoadShaderFunctions()
bool COpenGL::SetShaders(const TCHAR *file)
{
if (file && lstrcmp(file, currentShaderFile) == 0)
return true;
SetShadersCG(NULL);
SetShadersGLSL(NULL);
SetShadersGLSL_OLD(NULL);
shader_type = OGL_SHADER_NONE;
if (file != NULL && (
(lstrlen(file) > 3 && _tcsncicmp(&file[lstrlen(file) - 3], TEXT(".cg"), 3) == 0) ||
(lstrlen(file) > 4 && _tcsncicmp(&file[lstrlen(file) - 4], TEXT(".cgp"), 4) == 0))) {
return SetShadersCG(file);
} else if((lstrlen(file) > 7 && _tcsncicmp(&file[lstrlen(file) - 7], TEXT(".shader"), 7) == 0)) {
return SetShadersGLSL_OLD(file);
} else {
return SetShadersGLSL(file);
if (file) {
lstrcpy(currentShaderFile, file);
if ((lstrlen(file) > 3 && _tcsncicmp(&file[lstrlen(file) - 3], TEXT(".cg"), 3) == 0) ||
(lstrlen(file) > 4 && _tcsncicmp(&file[lstrlen(file) - 4], TEXT(".cgp"), 4) == 0)) {
return SetShadersCG(file);
}
else if ((lstrlen(file) > 7 && _tcsncicmp(&file[lstrlen(file) - 7], TEXT(".shader"), 7) == 0)) {
return SetShadersGLSL_OLD(file);
}
else {
return SetShadersGLSL(file);
}
}
*currentShaderFile = _T('\0');
return true;
}
void COpenGL::checkForCgError(const char *situation)

View File

@ -29,6 +29,7 @@ private:
GLfloat vertices[8];
GLfloat texcoords[8];
unsigned char * noPboBuffer;
TCHAR currentShaderFile[MAX_PATH];
int frameCount;