static void dumpAttrib(JSONWriter &json, const AttribDesc &desc, const GLbyte *data) { assert(desc); if (desc.numRows > 1) { json.beginArray(); } for (GLint row = 0; row < desc.numRows; ++row) { if (desc.numCols > 1) { json.beginArray(); } for (GLint col = 0; col < desc.numCols; ++col) { union { const GLbyte *rawvalue; const GLfloat *fvalue; const GLdouble *dvalue; const GLint *ivalue; const GLuint *uivalue; } u; u.rawvalue = data + row*desc.rowStride + col*desc.colStride; switch (desc.elemType) { case GL_FLOAT: json.writeFloat(*u.fvalue); break; case GL_DOUBLE: json.writeFloat(*u.dvalue); break; case GL_INT: json.writeInt(*u.ivalue); break; case GL_UNSIGNED_INT: json.writeInt(*u.uivalue); break; case GL_BOOL: json.writeBool(*u.uivalue); break; default: assert(0); json.writeNull(); break; } } if (desc.numCols > 1) { json.endArray(); } } if (desc.numRows > 1) { json.endArray(); } }
static inline void dumpStateObjectDesc(JSONWriter &json, Interface *pObj) { if (pObj) { typename ExtractDescType< decltype( &Interface::GetDesc ) >::type Desc; pObj->GetDesc(&Desc); dumpStateObject(json, Desc); } else { json.writeNull(); } }