Drop usage of gluErrorString

There are only a couple of error values worth considering, so we can just
write out own function for it. Disable error checking in C4FoWRegion.cpp as
well, since we have the --debug-opengl flag now.

This should allow us to get rid of the GLU dependency soon.
shapetextures
Armin Burgmeier 2015-12-24 16:24:47 -08:00
parent 91ba235d29
commit 43e50f9320
3 changed files with 20 additions and 25 deletions

View File

@ -874,23 +874,28 @@ bool CStdGL::Error(const char *szMsg)
return r;
}
const char* CStdGL::GLErrorString(GLenum code)
{
switch (code)
{
case GL_NO_ERROR: return "No error";
case GL_INVALID_ENUM: return "An unacceptable value is specified for an enumerated argument";
case GL_INVALID_VALUE: return "A numeric argument is out of range";
case GL_INVALID_OPERATION: return "The specified operation is not allowed in the current state";
case GL_INVALID_FRAMEBUFFER_OPERATION: return "The framebuffer object is not complete";
case GL_OUT_OF_MEMORY: return "There is not enough memory left to execute the command";
case GL_STACK_UNDERFLOW: return "An attempt has been made to perform an operation that would cause an internal stack to underflow";
case GL_STACK_OVERFLOW: return "An attempt has been made to perform an operation that would cause an internal stack to overflow";
default: assert(false); return "";
}
}
bool CStdGL::CheckGLError(const char *szAtOp)
{
GLenum err = glGetError();
if (!err) return true;
#ifdef USE_WIN32_WINDOWS
StdStrBuf err_buf(gluErrorUnicodeStringEXT(err));
#else
// gluErrorString returns latin-1 strings. Our code expects UTF-8, so convert
// Also for some reason gluErrorString returns const GLubyte* instead of a more
// reasonable const char *, so cast it - C-style cast required here to match
// both unsigned and signed char
StdStrBuf err_buf((const char*)gluErrorString(err));
err_buf.EnsureUnicode();
#endif
LogF("GL error with %s: %d - %s", szAtOp, err, err_buf.getData());
LogF("GL error with %s: %d - %s", szAtOp, err, GLErrorString(err));
return false;
}

View File

@ -203,6 +203,7 @@ protected:
bool CreatePrimarySurfaces(unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor);
bool CheckGLError(const char *szAtOp);
const char* GLErrorString(GLenum code);
virtual bool Error(const char *szMsg);
friend class C4Surface;
@ -213,6 +214,7 @@ protected:
friend class C4FullScreen;
friend class C4Window;
friend class C4ShaderCall;
friend class C4FoWRegion;
};
// Global access pointer

View File

@ -16,16 +16,6 @@
#include "C4Include.h"
#include "C4FoWRegion.h"
#ifndef USE_CONSOLE
bool glCheck() {
if (int err = glGetError()) {
LogF("GL error %d: %s", err, gluErrorString(err));
return false;
}
return true;
}
#endif
C4FoWRegion::~C4FoWRegion()
{
Clear();
@ -83,8 +73,7 @@ bool C4FoWRegion::BindFramebuf()
GLenum status1 = glCheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER_EXT),
status2 = glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
if (status1 != GL_FRAMEBUFFER_COMPLETE_EXT ||
(pBackSurface && status2 != GL_FRAMEBUFFER_COMPLETE_EXT) ||
!glCheck())
(pBackSurface && status2 != GL_FRAMEBUFFER_COMPLETE_EXT))
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
return false;
@ -220,7 +209,6 @@ void C4FoWRegion::Render(const C4TargetFacet *pOnScreen)
glMatrixMode(GL_PROJECTION);
glPopMatrix();
pDraw->RestorePrimaryClipper();
glCheck();
OldRegion = Region;
#endif