Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Human readable values for GLbitfields #203

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions src/voglcommon/vogl_gl_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2250,7 +2250,6 @@ bool pretty_print_param_val(dynamic_string &str, const vogl_ctype_desc_t &ctype_
case VOGL_GLENUM:
{
const char *pName;

if (entrypoint_id != VOGL_ENTRYPOINT_INVALID)
pName = get_gl_enums().find_name(val_data, entrypoint_id, param_index);
else
Expand Down Expand Up @@ -2283,12 +2282,47 @@ bool pretty_print_param_val(dynamic_string &str, const vogl_ctype_desc_t &ctype_
}
case VOGL_GLHANDLEARB:
case VOGL_GLUINT:
case VOGL_GLBITFIELD:
{
str.format_append("%u", *reinterpret_cast<const uint32_t *>(&val_data));
handled = true;
break;
}
case VOGL_GLBITFIELD:
{
if (val_data==0)
{
str.format_append("0");
}else{
bool first = true;
for (int bit = 0; bit < sizeof(uint64_t)*8; bit++)
{
uint64_t mask = (((uint64_t)1) << bit);
uint64_t flag = mask & val_data;
if (flag)
{
if (!first)
str.format_append(" | ");
first=false;

const char *pName;
if (entrypoint_id != VOGL_ENTRYPOINT_INVALID)
pName = get_gl_enums().find_name(flag, entrypoint_id, param_index);
else
pName = get_gl_enums().find_name(flag);

if (pName)
{
VOGL_ASSERT(get_gl_enums().find_enum(pName) == flag);

str += pName;
}else
str.format_append("%" PRIi64, flag);
}
}
}
handled = true;
break;
}
case VOGL_GLCHAR:
{
uint32_t v = *reinterpret_cast<const uint8_t *>(&val_data);
Expand Down