#include <stdlib.h>
#ifndef VRUT_HPC
#include <GL/glew.h>
//#include "common.h"
#include "flexilog.h"
#include "glgetproc.h"

#ifndef NDEBUG
void __GLCHECKERROR(const wxString& placeID, const char *file, const int line)
{
	GLenum errCode = glGetError();
	while (errCode != GL_NO_ERROR)
	{
		static unsigned glErrCounter = 0;
		static GLenum lastGlErrCode;
		if (errCode == lastGlErrCode)
		{
			if (glErrCounter++ == 5)
				LOG(wxT("Stopping redundant OpenGL error logging"));
		}
		else
		{
			lastGlErrCode = errCode;
			glErrCounter = 0;
		}
		if (glErrCounter < 5)
		{
			const char* errStr = (const char*)gluErrorString(errCode);
			wxString code;
			code.Printf(wxT("0x%x"),errCode);
			LOGWARNING(wxString(placeID) + wxString::Format(" OpenGL error in file %s line %d: %s ", file, line, errStr) + "("+code+")");
		}
		errCode = glGetError();
	}
}
#endif
#else
#include "OGLconstants.h"
#endif
