コード例 #1
0
ファイル: CompressIndices.cpp プロジェクト: ArEnSc/magnum
void compressIndices(Mesh& mesh, Buffer& buffer, BufferUsage usage, const std::vector<UnsignedInt>& indices) {
    auto minmax = std::minmax_element(indices.begin(), indices.end());

    /** @todo Performance hint when range can be represented by smaller value? */

    std::size_t indexCount;
    Mesh::IndexType indexType;
    Containers::Array<char> data;
    std::tie(indexCount, indexType, data) = compressIndicesInternal(indices, *minmax.second);

    mesh.setIndexCount(indices.size())
        .setIndexBuffer(buffer, 0, indexType, *minmax.first, *minmax.second);
    buffer.setData(data, usage);
}
コード例 #2
0
ファイル: CompressIndices.cpp プロジェクト: respu/magnum
void compressIndices(Mesh* mesh, Buffer* buffer, Buffer::Usage usage, const std::vector<UnsignedInt>& indices) {
    auto minmax = std::minmax_element(indices.begin(), indices.end());

    /** @todo Performance hint when range can be represented by smaller value? */

    std::size_t indexCount;
    Mesh::IndexType indexType;
    char* data;
    std::tie(indexCount, indexType, data) = compressIndicesInternal(indices, *minmax.second);

    mesh->setIndexCount(indices.size())
        ->setIndexBuffer(buffer, 0, indexType, *minmax.first, *minmax.second);
    buffer->setData(indexCount*Mesh::indexSize(indexType), data, usage);

    delete[] data;
}
コード例 #3
0
ファイル: CompressIndices.cpp プロジェクト: respu/magnum
std::tuple<std::size_t, Mesh::IndexType, char*> compressIndices(const std::vector<UnsignedInt>& indices) {
    return compressIndicesInternal(indices, *std::max_element(indices.begin(), indices.end()));
}