Skip to content

Commit

Permalink
Merge pull request #203 from openforeveryone/glClear-enum-display
Browse files Browse the repository at this point in the history
 Human readable values for GLbitfields
  • Loading branch information
Peter Lohrmann authored and Peter Lohrmann committed Apr 14, 2015
2 parents 810c2de + 7000a99 commit 4e10967
Showing 1 changed file with 36 additions and 2 deletions.
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

0 comments on commit 4e10967

Please sign in to comment.