summaryrefslogtreecommitdiff
path: root/retrace/glstate.cpp
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2014-05-10 16:33:50 +0100
committerJosé Fonseca <jfonseca@vmware.com>2014-05-10 16:33:50 +0100
commit651251cf2ccfbd47df134e7d9d91a4c13f08d282 (patch)
tree8536e4302987b84057ba101beec4cf710b62017c /retrace/glstate.cpp
parent71b331ecf6703e1fa9c94fd1b6ad0e62fa3004dc (diff)
glretrace: Include texture object labels in surfaces tab.
Issue #251.
Diffstat (limited to 'retrace/glstate.cpp')
-rw-r--r--retrace/glstate.cpp72
1 files changed, 38 insertions, 34 deletions
diff --git a/retrace/glstate.cpp b/retrace/glstate.cpp
index 6e8f3153..2094483d 100644
--- a/retrace/glstate.cpp
+++ b/retrace/glstate.cpp
@@ -157,17 +157,20 @@ Context::restorePixelPackState(void) {
/**
- * Dump a GL_KHR_debug /GL_EXT_debug_label object label.
+ * Get a GL_KHR_debug/GL_EXT_debug_label object label.
+ *
+ * The returned string should be destroyed with free() when no longer
+ * necessary.
*/
-void
-dumpObjectLabel(JSONWriter &json, Context &context, GLenum identifier, GLuint name, const char *member)
+char *
+getObjectLabel(Context &context, GLenum identifier, GLuint name)
{
if (!name) {
- return;
+ return NULL;
}
+ GLsizei length = 0;
if (context.KHR_debug) {
- GLsizei length = 0;
/*
* XXX: According to
* http://www.khronos.org/registry/gles/extensions/KHR/debug.txt
@@ -187,46 +190,47 @@ dumpObjectLabel(JSONWriter &json, Context &context, GLenum identifier, GLuint na
} else {
glGetIntegerv(GL_MAX_LABEL_LENGTH, &length);
}
- if (!length) {
- return;
- }
+ }
+ if (context.EXT_debug_label) {
+ glGetObjectLabelEXT(identifier, name, 0, &length, NULL);
+ }
+ if (!length) {
+ return NULL;
+ }
- char *label = (char *)calloc(length + 1, 1);
- if (!label) {
- return;
- }
+ char *label = (char *)calloc(length + 1, 1);
+ if (!label) {
+ return NULL;
+ }
+ if (context.KHR_debug) {
glGetObjectLabel(identifier, name, length + 1, NULL, label);
-
- if (label[0] != '\0') {
- json.writeStringMember(member, label);
- }
-
- free(label);
- return;
}
-
if (context.EXT_debug_label) {
- GLsizei length = 0;
- glGetObjectLabelEXT(identifier, name, 0, &length, NULL);
- if (!length) {
- return;
- }
+ glGetObjectLabelEXT(identifier, name, length + 1, NULL, label);
+ }
- char *label = (char *)calloc(length + 1, 1);
- if (!label) {
- return;
- }
+ if (label[0] == '\0') {
+ free(label);
+ return NULL;
+ }
- glGetObjectLabelEXT(identifier, name, length + 1, NULL, label);
+ return label;
+}
- if (label[0] != '\0') {
- json.writeStringMember(member, label);
- }
- free(label);
+/**
+ * Dump a GL_KHR_debug/GL_EXT_debug_label object label.
+ */
+void
+dumpObjectLabel(JSONWriter &json, Context &context, GLenum identifier, GLuint name, const char *member) {
+ char *label = getObjectLabel(context, identifier, name);
+ if (!label) {
return;
}
+
+ json.writeStringMember(member, label);
+ free(label);
}