mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Makes GL error handling explicit in report
This commit is contained in:
parent
0168f45a65
commit
0a22bc66f7
1 changed files with 15 additions and 3 deletions
|
|
@ -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>
|
template<typename ParameterType, size_t parameterCount, bool doQueryCounterBits = false>
|
||||||
void ReportParameter(
|
void ReportParameter(
|
||||||
const Script::Request& rq, JS::HandleValue settings,
|
const Script::Request& rq, JS::HandleValue settings,
|
||||||
|
|
@ -240,14 +245,17 @@ void ReportParameter(
|
||||||
values[0] = errorString;
|
values[0] = errorString;
|
||||||
}
|
}
|
||||||
else
|
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];
|
char buffer[1024];
|
||||||
for (size_t index{0}; index < parameterCount; ++index)
|
for (size_t index{0}; index < parameterCount; ++index)
|
||||||
{
|
{
|
||||||
PS::StringBuilder stringBuilder{buffer};
|
PS::StringBuilder stringBuilder{{std::begin(buffer), std::end(buffer)}};
|
||||||
stringBuilder.Append(paremeterName);
|
stringBuilder.Append(paremeterName);
|
||||||
if constexpr (parameterCount > 1)
|
if constexpr (parameterCount > 1)
|
||||||
{
|
{
|
||||||
|
|
@ -449,6 +457,10 @@ void CDevice::Report(const Script::Request& rq, JS::HandleValue settings)
|
||||||
{
|
{
|
||||||
Script::SetProperty(rq, settings, "name", "gl");
|
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 INTEGER(NAME) ReportParameter<GLint, 1>(rq, settings, GL_##NAME, "GL_" #NAME)
|
||||||
#define INTEGER2(NAME) ReportParameter<GLint, 2>(rq, settings, GL_##NAME, "GL_" #NAME)
|
#define INTEGER2(NAME) ReportParameter<GLint, 2>(rq, settings, GL_##NAME, "GL_" #NAME)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue