Makes GL error handling explicit in report

This commit is contained in:
Vladislav Belov 2026-07-08 08:13:46 +02:00
parent 0168f45a65
commit 0a22bc66f7
No known key found for this signature in database
GPG key ID: 353545E45DB9CCB3

View file

@ -205,6 +205,11 @@ void GLAD_API_PTR OnDebugMessage(
}
}
void ResetGLError()
{
do {} while (glGetError() != GL_NO_ERROR);
}
template<typename ParameterType, size_t parameterCount, bool doQueryCounterBits = false>
void ReportParameter(
const Script::Request& rq, JS::HandleValue settings,
@ -240,14 +245,17 @@ void ReportParameter(
values[0] = errorString;
}
else
static_assert(false);
{
debug_warn("Unsupported type");
}
const bool errorHappened{ogl_SquelchError(GL_INVALID_ENUM)};
const bool errorHappened{glGetError() != GL_NO_ERROR};
ResetGLError();
char buffer[1024];
for (size_t index{0}; index < parameterCount; ++index)
{
PS::StringBuilder stringBuilder{buffer};
PS::StringBuilder stringBuilder{{std::begin(buffer), std::end(buffer)}};
stringBuilder.Append(paremeterName);
if constexpr (parameterCount > 1)
{
@ -449,6 +457,10 @@ void CDevice::Report(const Script::Request& rq, JS::HandleValue settings)
{
Script::SetProperty(rq, settings, "name", "gl");
// We need to reset all previous errors because we don't call glGetError
// by default.
ResetGLError();
#define INTEGER(NAME) ReportParameter<GLint, 1>(rq, settings, GL_##NAME, "GL_" #NAME)
#define INTEGER2(NAME) ReportParameter<GLint, 2>(rq, settings, GL_##NAME, "GL_" #NAME)