From 3efd59d79c8ba80300a64c08bed03a0d46f1f919 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Sun, 10 Apr 2011 19:12:42 +0100 Subject: [PATCH] Dump 3D textures correctly. Not really tested however. --- glstate.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/glstate.py b/glstate.py index afcfa82..7c17a35 100644 --- a/glstate.py +++ b/glstate.py @@ -3037,11 +3037,21 @@ class StateDumper: static inline void writeTextureImage(JSONWriter &json, GLenum target, GLint level) { - GLint width = 0, height = 0; + GLint width, height = 1, depth = 1; + + width = 0; glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width); - glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height); - if (!width || !height) { + if (target != GL_TEXTURE_1D) { + height = 0; + glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height); + if (target == GL_TEXTURE_3D) { + depth = 0; + glGetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth); + } + } + + if (width <= 0 || height <= 0 || depth <= 0) { json.writeNull(); } else { json.beginObject(); @@ -3051,20 +3061,20 @@ writeTextureImage(JSONWriter &json, GLenum target, GLint level) json.writeNumberMember("__width__", width); json.writeNumberMember("__height__", height); - json.writeNumberMember("__depth__", 1); + json.writeNumberMember("__depth__", depth); // Hardcoded for now, but we could chose types more adequate to the // texture internal format json.writeStringMember("__type__", "float"); json.writeNumberMember("__channels__", 4); - float *pixels = new float[width*height*4]; + float *pixels = new float[depth*width*height*4]; glGetTexImage(target, level, GL_RGBA, GL_FLOAT, pixels); json.writeStringMember("__encoding__", "base64"); json.beginMember("__data__"); - json.writeBase64(pixels, width * height * 4 * sizeof *pixels); + json.writeBase64(pixels, depth * width * height * 4 * sizeof *pixels); json.endMember(); // __data__ delete [] pixels; -- 2.45.2