X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglprint.c;h=01883e8e4786271bbea68edb9ac2d82fad33de7f;hb=a832996c884a0e0acc9a38ba4dd258edb75ec7af;hp=6f645a7175bf6cd6daa746973267190f55dd7622;hpb=e7d4e2a75e75ff1a152912f0c19fb72ed63e81bc;p=gldbg.git diff --git a/source/glprint.c b/source/glprint.c index 6f645a7..01883e8 100644 --- a/source/glprint.c +++ b/source/glprint.c @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of gldbg -Copyright © 2009 Mikko Rasa, Mikkosoft Productions -Distributed under the GPL -*/ - #include #include #include @@ -119,6 +112,73 @@ 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_parameter(int pname, int param) +{ + char *buffer; + + // XXX Need to move the param names to flavor + switch(pname) + { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + return describe_enum(param, ""); + } + + buffer = tmpalloc(11); + snprintf(buffer, 11, "%i", param); + return buffer; +} + +static const char *print_internal_format(int fmt) +{ + char *buffer; + + if(fmt>4) + return describe_enum(fmt, "PixelFormat"); + + buffer = tmpalloc(2); + snprintf(buffer, 2, "%i", fmt); + return buffer; +} + static const char *print_data(const void *data, unsigned size) { if(!data)