예제 #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();
    }
}
예제 #2
0
static inline void
dumpArbProgramUniforms(JSONWriter &json, GLenum target, const char *prefix)
{
    if (!glIsEnabled(target)) {
        return;
    }

    GLint program_parameters = 0;
    glGetProgramivARB(target, GL_PROGRAM_PARAMETERS_ARB, &program_parameters);
    if (!program_parameters) {
        return;
    }

    GLint max_program_local_parameters = 0;
    glGetProgramivARB(target, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &max_program_local_parameters);
    for (GLint index = 0; index < max_program_local_parameters; ++index) {
        GLdouble params[4] = {0, 0, 0, 0};
        glGetProgramLocalParameterdvARB(target, index, params);

        if (!params[0] && !params[1] && !params[2] && !params[3]) {
            continue;
        }

        char name[256];
        snprintf(name, sizeof name, "%sprogram.local[%i]", prefix, index);

        json.beginMember(name);
        json.beginArray();
        json.writeFloat(params[0]);
        json.writeFloat(params[1]);
        json.writeFloat(params[2]);
        json.writeFloat(params[3]);
        json.endArray();
        json.endMember();
    }

    GLint max_program_env_parameters = 0;
    glGetProgramivARB(target, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &max_program_env_parameters);
    for (GLint index = 0; index < max_program_env_parameters; ++index) {
        GLdouble params[4] = {0, 0, 0, 0};
        glGetProgramEnvParameterdvARB(target, index, params);

        if (!params[0] && !params[1] && !params[2] && !params[3]) {
            continue;
        }

        char name[256];
        snprintf(name, sizeof name, "%sprogram.env[%i]", prefix, index);

        json.beginMember(name);
        json.beginArray();
        json.writeFloat(params[0]);
        json.writeFloat(params[1]);
        json.writeFloat(params[2]);
        json.writeFloat(params[3]);
        json.endArray();
        json.endMember();
    }
}
예제 #3
0
static void
dumpBlendState(JSONWriter &json, ID3D11DeviceContext *pDeviceContext)
{
    com_ptr<ID3D11BlendState> pBlendState;
    FLOAT BlendFactor[4];
    UINT SampleMask;

    pDeviceContext->OMGetBlendState(&pBlendState, BlendFactor, &SampleMask);

    json.beginMember("BlendState");
    dumpStateObjectDesc(json, pBlendState);
    json.endMember(); // BlendState
    
    json.beginMember("BlendFactor");
    json.beginArray();
    json.writeFloat(BlendFactor[0]);
    json.writeFloat(BlendFactor[1]);
    json.writeFloat(BlendFactor[2]);
    json.writeFloat(BlendFactor[3]);
    json.endArray();
    json.endMember(); // BlendFactor

    json.writeIntMember("SampleMask", SampleMask);
}