Beispiel #1
0
//----------------------------------------------------------------------------//
void Direct3D11GeometryBuffer::syncHardwareBuffer() const
{
    const size_t vertex_count = d_vertices.size();

    if (vertex_count > d_bufferSize)
    {
        cleanupVertexBuffer();
        allocateVertexBuffer(vertex_count);
    }

    if (vertex_count > 0)
    {
        void* buff;
		D3D11_MAPPED_SUBRESOURCE SubRes;
        if (FAILED(d_device.d_context->Map(d_vertexBuffer,0,D3D11_MAP_WRITE_DISCARD, 0, &SubRes)))
            CEGUI_THROW(RendererException("failed to map buffer."));
		buff=SubRes.pData;

        std::memcpy(buff, &d_vertices[0], sizeof(D3DVertex) * vertex_count);
        d_device.d_context->Unmap(d_vertexBuffer,0);
    }

    d_bufferSynched = true;
}
//----------------------------------------------------------------------------//
void Direct3D10GeometryBuffer::syncHardwareBuffer() const
{
    const size_t vertex_count = d_vertices.size();

    if (vertex_count > d_bufferSize)
    {
        cleanupVertexBuffer();
        allocateVertexBuffer(vertex_count);
    }

    if (vertex_count > 0)
    {
        void* buff;
        if (FAILED(d_vertexBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &buff)))
            throw RendererException(
                "Direct3D10GeometryBuffer::syncHardwareBuffer: "
                "failed to map buffer.");

        std::memcpy(buff, &d_vertices[0], sizeof(D3DVertex) * vertex_count);
        d_vertexBuffer->Unmap();
    }

    d_bufferSynched = true;
}