Beispiel #1
0
        public D3D.InputLayout CreateLayout(VertexDeclaration declaration)
        {
            int key = declaration.GetHashCode();

            D3D.InputLayout layout;
            if (!_layoutMap.TryGetValue(key, out layout))
            {
                try {
                    D3D.InputElement[] elements = new D3D.InputElement[declaration.ElementCount];
                    for (int i = 0; i < elements.Length; i++)
                    {
                        elements[i] = GenerateInputElement(declaration[i], 0, 0);
                    }
                    layout = new D3D.InputLayout(_device, _sig, elements);
                } catch (Exception e) {
                    throw new TeslaException("Error setting vertex declaration, it does not match the shader's input signature. Either there is an invalid element, or the declaration does not have enough elements.", e);
                }
                _layoutMap.Add(key, layout);
            }
            return(layout);
        }
Beispiel #2
0
 public InputLayoutKey(VertexDeclaration decl)
 {
     _key      = decl.GetHashCode();
     _elements = null;
 }