X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglprint.c;h=dff66f47f080156cf08b6958e9d68c66654ba560;hb=6a5b15f6382ca79e2b5f724585d29b73a40e8194;hp=e90c0e3d6eb6445ce88de453e88b615b6aba14c4;hpb=17fa41a4dfef75ce671bf71306929d1f5b91025a;p=gldbg.git diff --git a/source/glprint.c b/source/glprint.c index e90c0e3..dff66f4 100644 --- a/source/glprint.c +++ b/source/glprint.c @@ -14,6 +14,8 @@ Distributed under the GPL #include "glprint.h" #include "tmpalloc.h" +#define UNUSED __attribute__((unused)) + typedef struct sGlPrintData { char *buffer; @@ -117,10 +119,52 @@ static const char *print_array(const char *fmt, const void *data, unsigned elem_ return buffer; } +static const char *print_array_described(const char *(*describe)(GLenum, const char *), const char *categ, const void *data, unsigned elem_size, unsigned count) +{ + char *buffer; + unsigned buf_size; + char *ptr; + unsigned i; + + if(!data) + return NULL; + + count /= elem_size; + buf_size = count*50; + buffer = tmpalloc(buf_size); + ptr = buffer; + *ptr++ = '{'; + for(i=0; i0) + { + *ptr++ = ','; + *ptr++ = ' '; + } + memcpy(&element, (const char *)data+i*elem_size, elem_size); + len = snprintf(ptr, buf_size, "%s", describe(element, categ)); + ptr += len; + buf_size -= len; + } + *ptr++ = '}'; + *ptr = 0; + + return buffer; +} + static const char *print_data(const void *data, unsigned size) { if(!data) return "NULL"; + else if((unsigned long)data<0x100000) + { + char *buffer = tmpalloc(20); + snprintf(buffer, 20, "%p", data); + return buffer; + } else if(!size) return "/* data */"; else @@ -139,7 +183,7 @@ static void print_gldError(void *user_data, GLenum code) snprintf(gpd->buffer, gpd->bufsize, "ERROR: %s", describe_enum(code, "ErrorCode")); } -static void print_unhandled(void *user_data, unsigned short func) +static void print_unhandled(void *user_data, unsigned short func UNUSED) { GlPrintData *gpd = (GlPrintData *)user_data; gpd->buffer[0] = 0;