当前位置: 首页>>代码示例>>C#>>正文


C# Direct3D11.InputElement类代码示例

本文整理汇总了C#中SharpDX.Direct3D11.InputElement的典型用法代码示例。如果您正苦于以下问题:C# InputElement类的具体用法?C# InputElement怎么用?C# InputElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InputElement类属于SharpDX.Direct3D11命名空间,在下文中一共展示了InputElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EffectSignatureLayout

 public EffectSignatureLayout(InputElement[] inputElements, byte[] signature)
 {
     InputElements = inputElements;
     ShaderSignature = signature;
     inputElementsHashCode = InputElements.Aggregate(InputElements.Length, (current, inputElement) => (current * 397) ^ inputElement.GetHashCode());
     inputElementsHashCode = (inputElementsHashCode * 397) ^ ShaderSignature.GetHashCode();
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:7,代码来源:EffectSignatureLayout.cs

示例2: GetInputLayout

 public static InputLayout GetInputLayout(Device device, CompilationResult vertexShaderByteCode)
 {
     var inputElements = new InputElement[]
     {
         new InputElement
         {
             SemanticName = "POSITION",
             SemanticIndex = 0,
             Format = Format.R32G32B32_Float,
             Slot = 0,
             AlignedByteOffset = 0,
             Classification = InputClassification.PerVertexData,
             InstanceDataStepRate = 0
         },
         new InputElement
         {
             SemanticName = "COLOR",
             SemanticIndex = 0,
             Format = Format.R32G32B32A32_Float,
             Slot = 0,
             AlignedByteOffset = LightShader.Vertex.AppendAlignedElement1,
             Classification = InputClassification.PerVertexData,
             InstanceDataStepRate = 0
         }
     };
     return new InputLayout(device, ShaderSignature.GetInputSignature(vertexShaderByteCode), inputElements);
 }
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:27,代码来源:VertexDefinition.cs

示例3: InitShaders

        public override void InitShaders(ref Device device)
        {
            ShaderBytecode vertexShaderByteCode =
                ShaderBytecode.CompileFromFile(@"Shader/basicShaders.hlsl", "VShader", "vs_4_0");

            ShaderBytecode pixelShaderByteCode =
                ShaderBytecode.CompileFromFile(@"Shader/basicShaders.hlsl", "PShader", "ps_4_0");

            _deviceContext = device.ImmediateContext;
            _deviceContext.VertexShader.Set(new VertexShader(device, vertexShaderByteCode));
            _deviceContext.PixelShader.Set(new PixelShader(device, pixelShaderByteCode));

            //----

            InputElement[] elements = new InputElement[]
            {
                new InputElement("POSITION", 0, SharpDX.DXGI.Format.R32G32B32A32_Float, 0, 0),
                new InputElement("COLOR"   , 0, SharpDX.DXGI.Format.R32G32B32A32_Float, 16, 0),
            };

            _deviceContext.InputAssembler.InputLayout = new InputLayout(device, ShaderSignature.GetInputSignature(vertexShaderByteCode), elements);

            Vertex[] vertices = new Vertex[]
            {
                new Vertex(0.0f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f),
                new Vertex(0.5f, -.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f),
                new Vertex(-.5f, -.5f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f),
            };

            BufferDescription description = new BufferDescription(32 * 3, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0);
            _vertexBuffer = Buffer.Create(device, vertices, description);
        }
开发者ID:HirokiKihibori,项目名称:CV-GameController,代码行数:32,代码来源:Renderers.cs

示例4: MeshFactory

        public MeshFactory(SharpDX11Graphics graphics)
        {
            this.device = graphics.Device;
            this.inputAssembler = device.ImmediateContext.InputAssembler;
            this.demo = graphics.Demo;

            instanceDataDesc = new BufferDescription()
            {
                Usage = ResourceUsage.Dynamic,
                BindFlags = BindFlags.VertexBuffer,
                CpuAccessFlags = CpuAccessFlags.Write,
                OptionFlags = ResourceOptionFlags.None,
            };

            InputElement[] elements = new InputElement[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0, InputClassification.PerVertexData, 0),
                new InputElement("NORMAL", 0, Format.R32G32B32_Float, 12, 0, InputClassification.PerVertexData, 0),
                new InputElement("WORLD", 0, Format.R32G32B32A32_Float, 0, 1, InputClassification.PerInstanceData, 1),
                new InputElement("WORLD", 1, Format.R32G32B32A32_Float, 16, 1, InputClassification.PerInstanceData, 1),
                new InputElement("WORLD", 2, Format.R32G32B32A32_Float, 32, 1, InputClassification.PerInstanceData, 1),
                new InputElement("WORLD", 3, Format.R32G32B32A32_Float, 48, 1, InputClassification.PerInstanceData, 1),
                new InputElement("COLOR", 0, Format.R8G8B8A8_UNorm, 64, 1, InputClassification.PerInstanceData, 1)
            };
            inputLayout = new InputLayout(device, graphics.GetEffectPass().Description.Signature, elements);

            groundColor = ColorToUint(Color.Green);
            activeColor = ColorToUint(Color.Orange);
            passiveColor = ColorToUint(Color.OrangeRed);
            softBodyColor = ColorToUint(Color.LightBlue);
        }
开发者ID:RainsSoft,项目名称:BulletSharpPInvoke,代码行数:31,代码来源:MeshFactory.cs

示例5: LoadEffect

 /// <summary>
 /// Получить эффект
 /// </summary>
 /// <param name="FileName"></param>
 /// <param name="inputElement"></param>
 /// <returns></returns>
 public static EffectContainer LoadEffect(string FileName, InputElement[] inputElement)
 {
     string Origin = FileName;
     if (Effects.ContainsKey(Origin) && Effects[Origin].IsAlive)
     {
         //Уже есть
         EffectContainer t = (EffectContainer)Effects[Origin].Target;
         return t;
     }
     else
     {
         //нужно загрузить
         if (File.Exists(FileName + ".fx"))
         {
             FileName += ".fx";
         }
         else if (File.Exists(FileName + ".ees"))
         {
             FileName += ".ees";
         }
         EffectContainer t = new EffectContainer(ModelViewer.Program.device, FileName, inputElement);
         t.Name = Origin;
         WeakReference wr = new WeakReference(t, false);
         Effects.Add(Origin, wr);
         return t;
         //TODO проверка на валидность загрузки
     }
 }
开发者ID:MagistrAVSH,项目名称:my-spacegame-engine,代码行数:34,代码来源:ContentManager.cs

示例6: PhysicsDebugDraw

        public PhysicsDebugDraw(DeviceManager manager)
        {
            device = manager.Direct3DDevice;
            inputAssembler = device.ImmediateContext.InputAssembler;
            lineArray = new PositionColored[0];

            using (var bc = HLSLCompiler.CompileFromFile(@"Shaders\PhysicsDebug.hlsl", "VSMain", "vs_5_0"))
            {
                vertexShader = new VertexShader(device, bc);

                InputElement[] elements = new InputElement[]
                {
                    new InputElement("SV_POSITION", 0, Format.R32G32B32_Float, 0, 0, InputClassification.PerVertexData, 0),
                    new InputElement("COLOR", 0, Format.R8G8B8A8_UNorm, 12, 0, InputClassification.PerVertexData, 0)
                };
                inputLayout = new InputLayout(device, bc, elements);
            }

            vertexBufferDesc = new BufferDescription()
            {
                Usage = ResourceUsage.Dynamic,
                BindFlags = BindFlags.VertexBuffer,
                CpuAccessFlags = CpuAccessFlags.Write
            };

            vertexBufferBinding = new VertexBufferBinding(null, PositionColored.Stride, 0);

            using (var bc = HLSLCompiler.CompileFromFile(@"Shaders\PhysicsDebug.hlsl", "PSMain", "ps_5_0"))
                pixelShader = new PixelShader(device, bc);
        }
开发者ID:QamarWaqar,项目名称:Direct3D-Rendering-Cookbook,代码行数:30,代码来源:PhysicsDebugDraw.cs

示例7: InputLayout

 /// <summary>
 ///   Initializes a new instance of the <see cref = "T:SharpDX.Direct3D11.InputLayout" /> object to describe the
 ///   input-buffer data for the input-assembler stage.
 /// </summary>
 /// <unmanaged>ID3D11Device::CreateInputLayout</unmanaged>
 /// <param name = "device">The device used to create the layout.</param>
 /// <param name = "elements">An array of input elements describing the layout of the input data.</param>
 /// <param name = "shaderBytecode">The compiled shader used to validate the input elements.</param>
 public InputLayout(Device device, byte[] shaderBytecode, InputElement[] elements)
     : base(IntPtr.Zero)
 {
     unsafe
     {
         fixed (void* pBuffer = shaderBytecode)
             device.CreateInputLayout(elements, elements.Length, (IntPtr)pBuffer, shaderBytecode.Length,  this);
     }
 }
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:17,代码来源:InputLayout.cs

示例8: VertexElement

        public VertexElement(string semantic, int index, int components, DataType dataType = DataType.Float, bool normalized = false, int slot = 0, bool instanceData = false)
        {
            mDescription = new InputElement
            {
                AlignedByteOffset = InputElement.AppendAligned,
                Classification = instanceData ? InputClassification.PerInstanceData : InputClassification.PerVertexData,
                InstanceDataStepRate = instanceData ? 1 : 0,
                SemanticIndex = index,
                SemanticName = semantic,
                Slot = slot
            };

            if(dataType == DataType.Byte)
            {
                switch(components)
                {
                    case 1:
                        mDescription.Format = normalized ? Format.R8_UNorm : Format.R8_UInt;
                        break;

                    case 2:
                        mDescription.Format = normalized ? Format.R8G8_UNorm : Format.R8G8_UInt;
                        break;

                    case 4:
                        mDescription.Format = normalized ? Format.R8G8B8A8_UNorm : Format.R8G8B8A8_UInt;
                        break;

                    default:
                        throw new ArgumentException("Invalid combination of data type and component count");
                }
            }
            else
            {
                switch(components)
                {
                    case 1:
                        mDescription.Format = Format.R32_Float;
                        break;

                    case 2:
                        mDescription.Format = Format.R32G32_Float;
                        break;

                    case 3:
                        mDescription.Format = Format.R32G32B32_Float;
                        break;

                    case 4:
                        mDescription.Format = Format.R32G32B32A32_Float;
                        break;

                    default:
                        throw new ArgumentException("Invalid combination of data type and component count");
                }
            }
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:57,代码来源:VertexElement.cs

示例9: VertexArrayLayout

        /// <summary>
        /// Initializes a new instance of the <see cref="VertexArrayLayout"/> class.
        /// </summary>
        /// <param name="inputElements">The input elements.</param>
        /// <exception cref="System.ArgumentNullException">inputElements</exception>
        public VertexArrayLayout(InputElement[] inputElements)
        {
            if (inputElements == null) throw new ArgumentNullException("inputElements");

            this.InputElements = inputElements;
            hashCode = inputElements.Length;
            for (int i = 0; i < inputElements.Length; i++)
            {
                hashCode = (hashCode * 397) ^ inputElements[i].GetHashCode();
            }
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:16,代码来源:VertexArrayLayout.Direct3D.cs

示例10: Style

        public Style(String vertexShaderFilename, String pixelShaderFilename, InputElement[] layoutElements, int floatsPerVertex, DeviceManager deviceManager)
        {
            var path = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;

            // Read pre-compiled shader byte code relative to current directory
            var vertexShaderByteCode = NativeFile.ReadAllBytes(path + "\\" + vertexShaderFilename);
            this.pixelShader = new PixelShader(deviceManager.DeviceDirect3D, NativeFile.ReadAllBytes(path + "\\" + pixelShaderFilename));
            this.vertexShader = new VertexShader(deviceManager.DeviceDirect3D, vertexShaderByteCode);

            // Specify the input layout for the new style
            this.layout = new InputLayout(deviceManager.DeviceDirect3D, vertexShaderByteCode, layoutElements);
            this.floatsPerVertex = floatsPerVertex;
        }
开发者ID:philyum,项目名称:TheAmazingFishy,代码行数:13,代码来源:Style.cs

示例11: ColorShader

        public ColorShader(Device device)
        {
            var vertexShaderByteCode = ShaderBytecode.CompileFromFile(VertexShaderFileName, "ColorVertexShader", "vs_4_0", ShaderFlags.None, EffectFlags.None);
            var pixelShaderByteCode = ShaderBytecode.CompileFromFile(PixelShaderFileName, "ColorPixelShader", "ps_4_0", ShaderFlags.None, EffectFlags.None);

            VertexShader = new VertexShader(device, vertexShaderByteCode);
            PixelShader = new PixelShader(device, pixelShaderByteCode);

            var inputElements = new InputElement[]
            {
                new InputElement
                {
                    SemanticName = "POSITION",
                    SemanticIndex = 0,
                    Format = Format.R32G32B32_Float,
                    Slot = 0,
                    AlignedByteOffset = 0,
                    Classification = InputClassification.PerVertexData,
                    InstanceDataStepRate = 0
                },
                new InputElement
                {
                    SemanticName = "COLOR",
                    SemanticIndex = 0,
                    Format = Format.R32G32B32A32_Float,
                    Slot = 0,
                    AlignedByteOffset = ColorShader.Vertex.AppendAlignedElement,
                    Classification = InputClassification.PerVertexData,
                    InstanceDataStepRate = 0
                }
            };
            Layout = new InputLayout(device, ShaderSignature.GetInputSignature(vertexShaderByteCode), inputElements);

            vertexShaderByteCode.Dispose();
            pixelShaderByteCode.Dispose();

            // Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
            var matrixBufferDesc = new BufferDescription
            {
                Usage = ResourceUsage.Dynamic, // Updated each frame
                SizeInBytes = Utilities.SizeOf<MatrixBuffer>(), // Contains three matrices
                BindFlags = BindFlags.ConstantBuffer,
                CpuAccessFlags = CpuAccessFlags.Write,
                OptionFlags = ResourceOptionFlags.None,
                StructureByteStride = 0
            };
            ConstantMatrixBuffer = new Buffer(device, matrixBufferDesc);
        }
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:48,代码来源:ColorShader.cs

示例12: GetLayout

        public static InputLayout GetLayout(GxContext context, InputElement[] elements, Mesh mesh, ShaderProgram program)
        {
            Dictionary<ShaderProgram, InputLayout> meshEntry;
            InputLayout layout;

            if (Layouts.TryGetValue(mesh, out meshEntry))
            {
                if (meshEntry.TryGetValue(program, out layout))
                    return layout;

                layout = new InputLayout(context.Device, program.VertexShaderCode.Data, elements);
                meshEntry.Add(program, layout);
                return layout;
            }

            bool hasInstance = false, hasVertex = false;

            for(var i = 0; i < elements.Length; ++i)
            {
                if (hasInstance && hasVertex)
                    break;

                if(elements[i].Classification == InputClassification.PerInstanceData && hasInstance == false)
                {
                    elements[i].AlignedByteOffset = 0;
                    hasInstance = true;
                    continue;
                }

                if(elements[i].Classification == InputClassification.PerVertexData && hasVertex == false)
                {
                    elements[i].AlignedByteOffset = 0;
                    hasVertex = true;
                }
            }

            layout = new InputLayout(context.Device, program.VertexShaderCode.Data, elements);
            meshEntry = new Dictionary<ShaderProgram, InputLayout>()
            {
                {program, layout}
            };

            Layouts.Add(mesh, meshEntry);
            return layout;
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:45,代码来源:InputLayoutCache.cs

示例13: Shader

        public Shader(Device device, string shaderFile, string vertexTarget, string pixelTraget, InputElement[] layouts)
        {
            var shaderString = ShaderBytecode.PreprocessFromFile(shaderFile);

            using (var bytecode = ShaderBytecode.Compile(shaderString, vertexTarget, "vs_4_0"))
            {
                layout = new InputLayout(device, ShaderSignature.GetInputSignature(bytecode), layouts);
                vertShader = new VertexShader(device, bytecode);
            }

            using (var bytecode = ShaderBytecode.Compile(shaderString, pixelTraget, "ps_4_0"))
            {
                pixShader = new PixelShader(device, bytecode);
            }

            OnCleanup += vertShader.Dispose;
            OnCleanup += pixShader.Dispose;
            OnCleanup += layout.Dispose;
        }
开发者ID:Earthmark,项目名称:Struct-of-Structs,代码行数:19,代码来源:Shader.cs

示例14: VertexArrayObject

        private VertexArrayObject(GraphicsDevice graphicsDevice, EffectInputSignature shaderSignature, IndexBufferBinding indexBufferBinding, VertexBufferBinding[] vertexBufferBindings)
            : base(graphicsDevice)
        {
            this.vertexBufferBindings = vertexBufferBindings;
            this.indexBufferBinding = indexBufferBinding;
            this.EffectInputSignature = shaderSignature;

            // Calculate Direct3D11 InputElement
            int inputElementCount = vertexBufferBindings.Sum(t => t.Declaration.VertexElements.Length);
            var inputElements = new InputElement[inputElementCount];

            int j = 0;
            for (int i = 0; i < vertexBufferBindings.Length; i++)
            {
                var declaration = vertexBufferBindings[i].Declaration;
                vertexBufferBindings[i].Buffer.AddReferenceInternal();
                foreach (var vertexElementWithOffset in declaration.EnumerateWithOffsets())
                {
                    var vertexElement = vertexElementWithOffset.VertexElement;
                    inputElements[j++] = new InputElement
                        {
                            Slot = i,
                            SemanticName = vertexElement.SemanticName,
                            SemanticIndex = vertexElement.SemanticIndex,
                            AlignedByteOffset = vertexElementWithOffset.Offset,
                            Format = (SharpDX.DXGI.Format)vertexElement.Format,
                        };
                }
            }

            Layout = VertexArrayLayout.GetOrCreateLayout(new VertexArrayLayout(inputElements));

            if (indexBufferBinding != null)
            {
                indexBufferBinding.Buffer.AddReferenceInternal();
                indexBufferOffset = indexBufferBinding.Offset;
                indexFormat = (indexBufferBinding.Is32Bit ? SharpDX.DXGI.Format.R32_UInt : SharpDX.DXGI.Format.R16_UInt);
            }

            CreateResources();
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:41,代码来源:VertexArrayObject.Direct3D.cs

示例15: PhysicsDebugDraw

        public PhysicsDebugDraw(SharpDX11Graphics graphics)
        {
            device = graphics.Device;
            inputAssembler = device.ImmediateContext.InputAssembler;

            InputElement[] elements = new InputElement[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0, InputClassification.PerVertexData, 0),
                new InputElement("COLOR", 0, Format.R8G8B8A8_UNorm, 12, 0, InputClassification.PerVertexData, 0)
            };
            inputLayout = new InputLayout(device, graphics.GetDebugDrawPass().Description.Signature, elements);

            vertexBufferDesc = new BufferDescription()
            {
                Usage = ResourceUsage.Dynamic,
                BindFlags = BindFlags.VertexBuffer,
                CpuAccessFlags = CpuAccessFlags.Write
            };

            vertexBufferBinding = new VertexBufferBinding(null, PositionColored.Stride, 0);
        }
开发者ID:rhynodegreat,项目名称:BulletSharp,代码行数:21,代码来源:PhysicsDebugDraw.cs


注:本文中的SharpDX.Direct3D11.InputElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。