GL: Correctly encode error strings

gluErrorString returns latin-1 encoded strings. Our code expects to
receive UTF-8 encoded strings everywhere, so make sure that the strings
are converted before passing them on.
issue1247
Nicolas Hake 2015-02-16 15:34:53 +01:00
parent 49997045f6
commit eed1c43b8a
3 changed files with 13 additions and 5 deletions

View File

@ -683,7 +683,16 @@ bool CStdGL::CheckGLError(const char *szAtOp)
{
GLenum err = glGetError();
if (!err) return true;
LogF("GL error with %s: %d - %s", szAtOp, err, gluErrorString(err));
#ifdef USE_WIN32_WINDOWS
StdStrBuf err_buf(gluErrorUnicodeStringEXT(err));
#else
// gluErrorString returns latin-1 strings. Our code expects UTF-8, so convert
StdStrBuf err_buf(gluErrorString(err));
err_buf.EnsureUnicode();
#endif
LogF("GL error with %s: %d - %s", szAtOp, err, err_buf.getData());
return false;
}

View File

@ -197,6 +197,7 @@ protected:
friend class C4StartupOptionsDlg;
friend class C4FullScreen;
friend class C4Window;
friend class C4ShaderCall;
};
// Global access pointer

View File

@ -2,6 +2,7 @@
#include "C4Include.h"
#include "C4Shader.h"
#include "C4Application.h"
#include "graphics/C4DrawGL.h"
struct C4ShaderPosName {
int Position; const char *Name;
@ -549,8 +550,5 @@ void C4ShaderCall::Finish()
fStarted = false;
// Got an error?
if(int err = glGetError())
{
LogF("GL error: %d - %s", err, gluErrorString(err));
}
pGL->CheckGLError("C4ShaderCall::Finish()");
}