Пример #1
0
void Line::SetLines(const std::vector<XMVECTOR> &l)
{


	if (l.size() == lines.size())
	{
		for (int i = 0; i < lines.size(); i++)
			lines[i] = { { to2(l[i]) }, { 1.0, 1.0, 1.0, 1.0 } };

		// updating vertex buffer
		auto dc = dx->deviceContext;

		D3D11_MAPPED_SUBRESOURCE ms;
		ZeroMemory(&ms, sizeof(ms));

		Debug::if_failed(
			dc->Map(vertexBuffer, 0, D3D11_MAP_WRITE, 0, &ms),
			"error mapping subresource");

		memcpy(ms.pData, lines.data(), lines.size()*sizeof(ColVertex));

		dc->Unmap(vertexBuffer, 0);
	}
	else
	{
		ostringstream o;
		o << "invalid lines count in SetLines argument\n" <<
			"argument vector: " << l.size() << "\nlines vector: " << lines.size();
		Debug::message(o.str());
	}
}
Пример #2
0
// Decode a text string according to ETSI EN 300 468 Annex A
QString dvb_decode_text(const unsigned char *src, uint raw_length,
                        const unsigned char *encoding_override,
                        uint encoding_override_length)
{
    if (!raw_length)
        return "";

    if (src[0] == 0x1f)
        return freesat_huffman_to_string(src, raw_length);

    /* UCS-2 aka ISO/IEC 10646-1 Basic Multilingual Plane */
    if (src[0] == 0x11)
    {
        size_t length = (raw_length - 1) / 2;
        QChar *to = new QChar[length];
        for (size_t i=0; i<length; i++)
            to[i] = (src[1 + i*2] << 8) + src[1 + i*2 + 1];
        QString to2(to, length);
        delete [] to;
        return to2;
    }

    if (((0x11 < src[0]) && (src[0] < 0x15)) ||
        ((0x15 < src[0]) && (src[0] < 0x1f)))
    {
        // TODO: Handle multi-byte encodings
        LOG(VB_SIPARSER, LOG_ERR,
            "dvb_decode_text: Multi-byte coded text is not yet supported.");
        return "";
    }

    // if a override encoding is specified and the default ISO 6937 encoding
    // would be used copy the override encoding in front of the text
    unsigned char *dst =
        new unsigned char[raw_length + encoding_override_length];

    uint length = 0;
    if (encoding_override && src[0] >= 0x20) {
        memcpy(dst, encoding_override, encoding_override_length);
        length = encoding_override_length;
    }

    // Strip formatting characters
    for (uint i = 0; i < raw_length; i++)
    {
        if ((src[i] < 0x80) || (src[i] > 0x9F))
            dst[length++] = src[i];
        // replace CR/LF with a space
        else if (src[i] == 0x8A)
            dst[length++] = 0x20;
    }

    // Exit on empty string, sans formatting.

    QString sStr = (!length) ? "" : decode_text(dst, length);

    delete [] dst;

    return sStr;
}