From bc201c7dd5ebef9c0db1142387715c7ad4d53b62 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 25 Aug 2012 17:03:39 +0300 Subject: [PATCH] Add a command to show current vertex array state --- flavors/gl/source/arraystate.cpp | 19 +++++++++++++++++++ flavors/gl/source/arraystate.h | 2 ++ flavors/gl/source/inspector.cpp | 24 ++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/flavors/gl/source/arraystate.cpp b/flavors/gl/source/arraystate.cpp index 82442d7..98d6ed4 100644 --- a/flavors/gl/source/arraystate.cpp +++ b/flavors/gl/source/arraystate.cpp @@ -1,5 +1,9 @@ #include "arraystate.h" #include "bufferstate.h" +#include "enums.h" +#include "strformat.h" + +using namespace std; ArrayState::ArrayState(): kind(0), @@ -25,3 +29,18 @@ void ArrayState::set(unsigned s, GLenum t, bool n, unsigned r, BufferState *b, l if(buffer) buffer->content.update(*this); } + +string ArrayState::describe() const +{ + if(enabled) + { + string descr = strformat("%d %s, stride %d", size, describe_enum(type, "DataType"), stride); + if(buffer) + descr += strformat(", buffer %d at %d", buffer->id, pointer); + else + descr += strformat(", at 0x%X", pointer); + return descr; + } + else + return "Disabled"; +} diff --git a/flavors/gl/source/arraystate.h b/flavors/gl/source/arraystate.h index a6654f3..c1bd018 100644 --- a/flavors/gl/source/arraystate.h +++ b/flavors/gl/source/arraystate.h @@ -1,6 +1,7 @@ #ifndef ARRAYSTATE_H_ #define ARRAYSTATE_H_ +#include #include "autoconstptr.h" #include "opengl.h" @@ -20,6 +21,7 @@ struct ArrayState ArrayState(); void set(unsigned, GLenum, bool, unsigned, BufferState *, long); + std::string describe() const; }; #endif diff --git a/flavors/gl/source/inspector.cpp b/flavors/gl/source/inspector.cpp index 122c2e4..de8031b 100644 --- a/flavors/gl/source/inspector.cpp +++ b/flavors/gl/source/inspector.cpp @@ -21,6 +21,8 @@ Inspector::Inspector(GlDbg &d): .set_help("Inspects general GL state", "state vertex\n" " Print current vertex attributes\n\n" + "state array\n" + " Show current vertex arrays\n\n" "state bind\n" " Show current bindings\n"); @@ -118,6 +120,28 @@ void Inspector::cmd_state(const string &args) const Vector3 &normal = glstate.get_normal(); printf(" Normal: [%05.3f, %05.3f, %05.3f]\n", normal.x, normal.y, normal.z); } + else if(args=="array") + { + printf("Current vertex arrays:\n"); + string descr = glstate.get_array(GL_VERTEX_ARRAY).describe(); + printf(" Vertex: %s\n", descr.c_str()); + descr = glstate.get_array(GL_NORMAL_ARRAY).describe(); + printf(" Normal: %s\n", descr.c_str()); + descr = glstate.get_array(GL_COLOR_ARRAY).describe(); + printf(" Color: %s\n", descr.c_str()); + unsigned count = glstate.get_max_texture_units(); + for(unsigned i=0; i=10 ? " " : " "), descr.c_str()); + } + } else if(args=="bind") { printf("Current bindings:\n"); -- 2.43.0