]> git.tdb.fi Git - gldbg.git/commitdiff
Add a command to show current vertex array state
authorMikko Rasa <tdb@tdb.fi>
Sat, 25 Aug 2012 14:03:39 +0000 (17:03 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 25 Aug 2012 17:32:03 +0000 (20:32 +0300)
flavors/gl/source/arraystate.cpp
flavors/gl/source/arraystate.h
flavors/gl/source/inspector.cpp

index 82442d7f3a37e90afbcf0b44da75e76e0a75de97..98d6ed406376ebd0fa86fc7d1b293d308bbd74d7 100644 (file)
@@ -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";
+}
index a6654f37fb5aa46987f613b5cd541655be40ca5c..c1bd0189f34804f518ac964e1b1c440ce4370d21 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef ARRAYSTATE_H_
 #define ARRAYSTATE_H_
 
+#include <string>
 #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
index 122c2e45298f340ddfe935a2f5e29375dcde480c..de8031b2f22931d429c27ac1dbd45fd922050352 100644 (file)
@@ -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<count; ++i)
+               {
+                       descr = glstate.get_texture_coord_array(i).describe();
+                       printf("  TexCoord%d: %s\n", i, descr.c_str());
+               }
+               count = glstate.get_max_vertex_attribs();
+               for(unsigned i=0; i<count; ++i)
+               {
+                       descr = glstate.get_attrib_array(i).describe();
+                       printf("  Attrib%d:%s %s\n", i, (i>=10 ? " " : "  "), descr.c_str());
+               }
+       }
        else if(args=="bind")
        {
                printf("Current bindings:\n");