Beispiel #1
0
bool D3DCodePath::loadGeometryShader(DataStream& stream)
{
    if ( stream.getDataSize() > 0 )
    {
        HRESULT hr = mDevice.getDevice().CreateGeometryShader(stream.getData(), stream.getDataSize(), NULL, &mpGeometryShader);
        if ( FAILED(hr) )
        {
            return false;
        }
    }
    return true;
}
Beispiel #2
0
bool D3DCodePath::createInputLayout(const DataStream& stream)
{
    const VertexLayout& layout = getVertexLayout();

    D3D11_INPUT_ELEMENT_DESC* pdescs = new D3D11_INPUT_ELEMENT_DESC[layout.getSize()];
    for ( int index = 0; index < layout.getSize(); ++index )
    {
        const VertexLayoutElement& element = layout[index];
        D3D11_INPUT_ELEMENT_DESC& desc = pdescs[index];

        memset(&desc, 0, sizeof(D3D11_INPUT_ELEMENT_DESC));
        desc.SemanticName = _strdup(element.semantic.toUtf8().c_str());
        switch ( element.size )
        {
        case 1:
            desc.Format = DXGI_FORMAT_R32_FLOAT;
            break;
        case 2:
            desc.Format = DXGI_FORMAT_R32G32_FLOAT;
            break;
        case 3:
            desc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
            break;
        case 4:
            desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
            break;
        default:
            return false;
        }

        desc.AlignedByteOffset = element.pos;
        desc.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
    }

    HRESULT hr = mDevice.getDevice().CreateInputLayout(pdescs, layout.getSize(), stream.getData(), stream.getDataSize(), &mpInputLayout);

    for ( int index = 0; index < layout.getSize(); ++index )
    {
        D3D11_INPUT_ELEMENT_DESC& desc = pdescs[index];
        delete[] desc.SemanticName;
    }
    delete[] pdescs;

    if ( FAILED(hr) )
    {
        return false;
    }

    return true;
}
Beispiel #3
0
bool D3DCodePath::loadVertexShader(DataStream& stream)
{
    HRESULT hr = mDevice.getDevice().CreateVertexShader(stream.getData(), stream.getDataSize(), NULL, &mpVertexShader);
    if ( FAILED(hr) )
    {
        return false;
    }

    if ( !createInputLayout(stream) )
    {
        return false;
    }

    return true;
}
void SceneSerializer::importSceneDOM(DataStream & stream, SceneNode* node) {
    Document doc;
    doc.Parse<0>(stream.getData());
    assert(doc.IsObject() && "Error: Invalid scene description file found. Please check the correctness of the syntax.\n");
    handleNode(doc, node);
}
Beispiel #5
0
void DataStream::write(const DataStream& that)
{
   writeInt(that.getDataSize());
   writeBytes(that.getData(), that.getDataSize());
}