Exemplo n.º 1
0
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();
    }
}
Exemplo n.º 2
0
void
dumpEnum(JSONWriter &json, GLenum pname)
{
    const char *s = enumToString(pname);
    if (s) {
        json.writeString(s);
    } else {
        json.writeInt(pname);
    }
}
Exemplo n.º 3
0
void
dumpBoolean(JSONWriter &json, GLboolean value)
{
    switch (value) {
    case GL_FALSE:
        json.writeString("GL_FALSE");
        break;
    case GL_TRUE:
        json.writeString("GL_TRUE");
        break;
    default:
        json.writeInt(static_cast<GLint>(value));
        break;
    }
}