Exemplo n.º 1
0
bool vogl_display_list::deserialize(const json_node &node, const vogl_blob_manager &blob_manager, const vogl_ctypes *pCtypes)
{
    VOGL_FUNC_TRACER

    clear();

    m_handle = node.value_as_uint32("handle");
    m_valid = node.value_as_bool("valid", true);
    m_generating = node.value_as_bool("generating");
    m_xfont = node.value_as_bool("xfont");

    if (m_xfont)
    {
        m_xfont_glyph = node.value_as_int("xfont_glyph");
        m_xfont_name = node.value_as_string("xfont_name");
    }

    const json_node *pPackets_array = node.find_child_array("packets");
    if (pPackets_array)
    {
        if (!pPackets_array->are_all_children_objects())
        {
            clear();
            return false;
        }

        vogl_trace_packet packet(pCtypes);

        m_packets.resize(pPackets_array->size());
        for (uint i = 0; i < pPackets_array->size(); i++)
        {
            if (!packet.json_deserialize(*pPackets_array->get_child(i), "<display_list>", &blob_manager))
            {
                clear();
                return false;
            }

            if (!packet.serialize(m_packets.get_packet_buf(i)))
            {
                clear();
                return false;
            }
        }
    }

    return true;
}
Exemplo n.º 2
0
bool vogl_renderbuffer_desc::deserialize(const json_node &node)
{
    VOGL_FUNC_TRACER

    clear();

    m_width = node.value_as_int("width");
    m_height = node.value_as_int("height");
    m_samples = node.value_as_int("samples");
    m_red_size = node.value_as_int("red_size");
    m_green_size = node.value_as_int("green_size");
    m_blue_size = node.value_as_int("blue_size");
    m_alpha_size = node.value_as_int("alpha_size");
    m_depth_size = node.value_as_int("depth_size");
    m_stencil_size = node.value_as_int("stencil_size");

    const char *pFmt = node.value_as_string_ptr("internal_format");
    if (!pFmt)
    {
        VOGL_ASSERT_ALWAYS;
        return false;
    }

    uint64_t enum_val = g_gl_enums.find_enum(pFmt);
    VOGL_ASSERT(enum_val != gl_enums::cUnknownEnum);
    if (enum_val == gl_enums::cUnknownEnum)
        return false;
    if (enum_val > cUINT32_MAX)
    {
        VOGL_ASSERT_ALWAYS;
        return false;
    }
    m_internal_format = static_cast<GLenum>(enum_val);

    return true;
}