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


C# Direct3D11.InputLayout类代码示例

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


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

示例1: 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

示例2: Initialize

        public void Initialize(Device Device)
        {
            _shaderSolution=ROD_core.ShaderBinding.GetCompatibleShader(this);
            layout = new InputLayout(Device, _shaderSolution.shaders_bytecode[Shaders.VertexShader], mesh._vertexStream.vertexDefinition.GetInputElements());

            mesh.Load(Device);
            material.LoadTextures(Device);
            sampler = new SamplerState(Device, new SamplerStateDescription()
            {
                Filter = Filter.MinMagMipLinear,
                AddressU = TextureAddressMode.Wrap,
                AddressV = TextureAddressMode.Wrap,
                AddressW = TextureAddressMode.Wrap,
                BorderColor = new SharpDX.Color4(0,0,0,1),
                ComparisonFunction = Comparison.Never,
                MaximumAnisotropy = 16,
                MipLodBias = 0,
                MinimumLod = -float.MaxValue,
                MaximumLod = float.MaxValue
            });

            List<Shaders> actual_shaders = (from sh in _shaderSolution.shaders_bytecode select sh.Key).ToList<Shaders>();
            foreach (Shaders sh in actual_shaders)
            {
                ShaderReflection _shaderReflection = new ShaderReflection(_shaderSolution.shaders_bytecode[sh]);
                int buffers_count = _shaderReflection.Description.ConstantBuffers;
                SharpDX.Direct3D11.Buffer[] _buffers = new SharpDX.Direct3D11.Buffer[buffers_count];
                for (int i = 0; i < buffers_count; i++)
                {
                    ConstantBuffer cb_buffer = _shaderReflection.GetConstantBuffer(i);
                    _buffers[i] = new SharpDX.Direct3D11.Buffer(Device, cb_buffer.Description.Size, ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
                }
                _shaderSolution.shaders_buffers[sh] = _buffers;
            }
        }
开发者ID:sinushawa,项目名称:ROD,代码行数:35,代码来源:Model.cs

示例3: InitializeAll

 public static void InitializeAll(Device device) {
     EffectPassDescription? passDesc;
     var e1 = EffectManager11.Instance.GetEffect<BasicEffect11>();
     passDesc = e1?.Light1Tech?.GetPassByIndex(0)?.Description;
     try {
         if (passDesc?.Signature != null) {
             _posNorm = new InputLayout(device, passDesc.Value.Signature, InputLayoutDescriptions.PosNorm);
         }
     } catch (SharpDXException ex) {
         Debug.Print(ex.Message);
     }
     try {
         if (passDesc?.Signature != null) {
             _posNormTex = new InputLayout(device, passDesc.Value.Signature, InputLayoutDescriptions.PosNormTex);
         }
     } catch (SharpDXException ex) {
         Debug.Print(ex.Message);
     }
     var e2 = EffectManager11.Instance.GetEffect<SkyboxEffect11>();
     passDesc = e2?.SkyTech?.GetPassByIndex(0)?.Description;
     if (passDesc?.Signature != null) {
         _pos = new InputLayout(device, passDesc.Value.Signature, InputLayoutDescriptions.Pos);
     }
     var e3 = EffectManager11.Instance.GetEffect<NormalMapEffect11>();
     passDesc = e3?.Light1Tech?.GetPassByIndex(0)?.Description;
     if (passDesc?.Signature != null) {
         _posNormTexTan = new InputLayout(device, passDesc.Value.Signature, InputLayoutDescriptions.PosNormTexTan);
     }
     var e4 = EffectManager11.Instance.GetEffect<FireParticleEffect11>();
     passDesc = e4?.StreamOutTech?.GetPassByIndex(0)?.Description;
     if (passDesc?.Signature != null) {
         _particle = new InputLayout(device, passDesc.Value.Signature, InputLayoutDescriptions.Particle);
     }
 }
开发者ID:Hozuki,项目名称:Noire,代码行数:34,代码来源:InputLayouts.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: InitEffects

        protected override void InitEffects()
        {
            var custom = renderTechniquesManager.RenderTechniques["RenderCustom"];
            var lines = renderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Lines];
            var points = renderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Points];
            var text = renderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.BillboardText];
            var blinn = renderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn];

            RegisterEffect(Properties.Resources._custom, new[] { custom, lines, points, text, blinn});

            var customInputLayout = new InputLayout(device, GetEffect(custom).GetTechniqueByName("RenderCustom").GetPassByIndex(0).Description.Signature, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),
                new InputElement("COLOR",    0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32_Float,       InputElement.AppendAligned, 0),
                new InputElement("NORMAL",   0, Format.R32G32B32_Float,    InputElement.AppendAligned, 0),
                new InputElement("TANGENT",  0, Format.R32G32B32_Float,    InputElement.AppendAligned, 0),
                new InputElement("BINORMAL", 0, Format.R32G32B32_Float,    InputElement.AppendAligned, 0),
                new InputElement("COLOR",    1, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),

                //INSTANCING: die 4 texcoords sind die matrix, die mit jedem buffer reinwandern
                new InputElement("TEXCOORD", 1, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
                new InputElement("TEXCOORD", 2, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
                new InputElement("TEXCOORD", 3, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
                new InputElement("TEXCOORD", 4, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
            });

            RegisterLayout(new[] { custom, lines, points, text, blinn}, customInputLayout);

            var linesInputLayout = new InputLayout(device, GetEffect(lines).GetTechniqueByName(DefaultRenderTechniqueNames.Lines).GetPassByIndex(0).Description.Signature, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),
                new InputElement("COLOR",    0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),
                new InputElement("COLOR",    1, Format.R32G32B32A32_Float,    InputElement.AppendAligned, 0),

                //INSTANCING: die 4 texcoords sind die matrix, die mit jedem buffer reinwandern
                new InputElement("TEXCOORD", 1, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
                new InputElement("TEXCOORD", 2, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
                new InputElement("TEXCOORD", 3, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
                new InputElement("TEXCOORD", 4, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1),
            });
            RegisterLayout(new[]{lines},linesInputLayout);

            var pointsInputLayout = new InputLayout(device, GetEffect(points).GetTechniqueByName(DefaultRenderTechniqueNames.Points).GetPassByIndex(0).Description.Signature, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),
                new InputElement("COLOR",    0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0),
                new InputElement("COLOR",    1, Format.R32G32B32A32_Float,    InputElement.AppendAligned, 0),
            });
            RegisterLayout(new[] { points }, pointsInputLayout);

            var textInputLayout = new InputLayout(device, GetEffect(text).GetTechniqueByName(DefaultRenderTechniqueNames.BillboardText).GetPassByIndex(0).Description.Signature, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float,  InputElement.AppendAligned, 0),
                new InputElement("COLOR",    0, Format.R32G32B32A32_Float,  InputElement.AppendAligned, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32B32A32_Float,  InputElement.AppendAligned, 0),
            });
            RegisterLayout(new[] { text }, textInputLayout);
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:59,代码来源:CustomEffectsManager.cs

示例6: RenderTechnique

 public RenderTechnique(string name, Effect effect, InputLayout layout)
 {
     this.Name = name;
     this.Device = effect.Device;
     this.Effect = effect;
     this.EffectTechnique = effect.GetTechniqueByName(this.Name);
     this.InputLayout = layout;
 }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:8,代码来源:RenderTechnique.cs

示例7: ProjectiveTexturingShader

        public ProjectiveTexturingShader(Device device)
        {
            var shaderByteCode = new ShaderBytecode(File.ReadAllBytes("Content/DepthAndProjectiveTextureVS.cso"));
            vertexShader = new VertexShader(device, shaderByteCode);
            geometryShader = new GeometryShader(device, new ShaderBytecode(File.ReadAllBytes("Content/DepthAndColorGS.cso")));
            pixelShader = new PixelShader(device, new ShaderBytecode(File.ReadAllBytes("Content/DepthAndColorPS.cso")));

            // depth stencil state
            var depthStencilStateDesc = new DepthStencilStateDescription()
            {
                IsDepthEnabled = true,
                DepthWriteMask = DepthWriteMask.All,
                DepthComparison = Comparison.LessEqual,
                IsStencilEnabled = false,
            };
            depthStencilState = new DepthStencilState(device, depthStencilStateDesc);

            // rasterizer states
            var rasterizerStateDesc = new RasterizerStateDescription()
            {
                CullMode = CullMode.None,
                FillMode = FillMode.Solid,
                IsDepthClipEnabled = true,
                IsFrontCounterClockwise = true,
                IsMultisampleEnabled = true,
            };
            rasterizerState = new RasterizerState(device, rasterizerStateDesc);

            // constant buffer
            var constantBufferDesc = new BufferDescription()
            {
                Usage = ResourceUsage.Dynamic,
                BindFlags = BindFlags.ConstantBuffer,
                SizeInBytes = Constants.size,
                CpuAccessFlags = CpuAccessFlags.Write,
                StructureByteStride = 0,
                OptionFlags = 0,
            };
            constantBuffer = new SharpDX.Direct3D11.Buffer(device, constantBufferDesc);

            // user view sampler state
            var colorSamplerStateDesc = new SamplerStateDescription()
            {
                Filter = Filter.MinMagMipLinear,
                AddressU = TextureAddressMode.Border,
                AddressV = TextureAddressMode.Border,
                AddressW = TextureAddressMode.Border,
                //BorderColor = new SharpDX.Color4(0.5f, 0.5f, 0.5f, 1.0f),
                BorderColor = new SharpDX.Color4(0, 0, 0, 1.0f),
            };
            colorSamplerState = new SamplerState(device, colorSamplerStateDesc);

            vertexInputLayout = new InputLayout(device, shaderByteCode.Data, new[]
            {
                new InputElement("SV_POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
            });

        }
开发者ID:Dallemanden,项目名称:RoomAliveToolkit,代码行数:58,代码来源:ProjectiveTexturingShader.cs

示例8: SetInputLayout

        internal void SetInputLayout(InputLayout il)
        {
            if (il == m_inputLayout)
                return;

            m_inputLayout = il;
            m_deviceContext.InputAssembler.InputLayout = il;
            m_statistics.SetInputLayout++;
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:9,代码来源:MyRenderContextState.cs

示例9: VanillaInputLayout

 public VanillaInputLayout(ShaderAsset shader)
 {
     InputLayout  = new InputLayout(shader.Device, shader.Signature, new[]
     {
         new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
         new InputElement("NORMAL", 0, Format.R32G32B32A32_Float, 16, 0),
         new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 32, 0),
         new InputElement("TEXCOORD", 0, Format.R32G32B32A32_Float, 48, 0),
     });
 }
开发者ID:JoltSoftwareDevelopment,项目名称:Jolt.MashRoom,代码行数:10,代码来源:VanillaInputLayout.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: RecordCommands

        internal unsafe void RecordCommands(MyRenderableProxy proxy, MyFoliageStream stream, int voxelMatId,
            VertexShader vertexShader, InputLayout inputLayout,
            int materialIndex, int indexCount, int startIndex, int baseVertex)
        {
            if (stream.m_stream == VertexBufferId.NULL) return;

            //var worldMatrix = proxy.WorldMatrix;
            //worldMatrix.Translation = Vector3D.Zero;
            //MyObjectData objectData = proxy.ObjectData;
            //objectData.LocalMatrix = Matrix.Identity;

            var worldMat = proxy.WorldMatrix;
            //worldMat.Translation -= MyRender11.Environment.CameraPosition;

            MyObjectDataCommon objectData = proxy.CommonObjectData;
            objectData.LocalMatrix = worldMat;

            MyMapping mapping = MyMapping.MapDiscard(RC, proxy.ObjectBuffer);
            mapping.WriteAndPosition(ref proxy.VoxelCommonObjectData);
            mapping.WriteAndPosition(ref objectData);
            mapping.Unmap();

            RC.AllShaderStages.SetConstantBuffer(MyCommon.OBJECT_SLOT, proxy.ObjectBuffer);

            BindProxyGeometry(proxy, RC);

            RC.VertexShader.Set(vertexShader);
            RC.SetInputLayout(inputLayout);

            int offset = -1;
            if (!stream.Append)
            {
                offset = 0;
                stream.Append = true;
            }

            RC.SetTarget(stream.m_stream.Buffer, offset);
            RC.AllShaderStages.SetConstantBuffer(MyCommon.FOLIAGE_SLOT, MyCommon.FoliageConstants);

            float densityFactor = MyVoxelMaterials1.Table[voxelMatId].FoliageDensity * MyRender11.Settings.GrassDensityFactor;

            float zero = 0;
            mapping = MyMapping.MapDiscard(RC, MyCommon.FoliageConstants);
            mapping.WriteAndPosition(ref densityFactor);
            mapping.WriteAndPosition(ref materialIndex);
            mapping.WriteAndPosition(ref voxelMatId);
            mapping.WriteAndPosition(ref zero);
            mapping.Unmap();

            RC.DrawIndexed(indexCount, startIndex, baseVertex);
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:51,代码来源:MyFoliageGeneratingPass.cs

示例12: Init

        public override Effect Init(EffectDescription description)
        {
            base.Init(description);

            var mode = _demo.SetupModel.Mode;

            _greetingsRenderTarget = _disposer.Add(new RenderTarget(
                device: _demo.Device,
                width: mode.Width,                    // TODO(mstrandh): Honor setupmodel?
                height: mode.Height,                   // TODO(mstrandh): Honor setupmodel?
                sampleCount: 1,                 // TODO(mstrandh): Honor setupmodel?
                sampleQuality: 0,               // TODO(mstrandh): Honor setupmodel?
                format: Format.R8G8B8A8_UNorm   // TODO(mstrandh): Honor setupmodel?
            ));

            CreateCylinderBuffers();
            var texture = _textures[0];
            _textureHeight = texture.Texture.Description.Height;

            _tubeVertexShader = _demo.ShaderManager["greetingsTube.vs.cso"];
            _tubePixelShader = _demo.ShaderManager["greetingsTube.ps.cso"];

            _tubeInputLayout = _disposer.Add(new InputLayout(_demo.Device, _tubeVertexShader.Signature, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32_Float, 12, 0),
            }));

            _greetingsTexture = _resourceViews[0];
            _renderedCylinderTexture = _greetingsRenderTarget.ShaderResourceView;

            // Create the depth buffer
            var depthBuffer = _disposer.Add(new Texture2D(_demo.Device, new Texture2DDescription
            {
                Format = Format.D32_Float_S8X24_UInt,
                ArraySize = 1,
                MipLevels = 1,
                Width = mode.Width,
                Height = mode.Height,
                SampleDescription = new SampleDescription { Count = 1, Quality = 0 },
                Usage = ResourceUsage.Default,
                BindFlags = BindFlags.DepthStencil,
                CpuAccessFlags = CpuAccessFlags.None,
                OptionFlags = ResourceOptionFlags.None
            }));

            // Create the depth buffer view
            _greetingsDepthView = _disposer.Add(new DepthStencilView(_demo.Device, depthBuffer));

            return this;
        }
开发者ID:JoltSoftwareDevelopment,项目名称:Jolt.MashRoom,代码行数:51,代码来源:GreetingsEffect.cs

示例13: InitializeEffect

        private void InitializeEffect()
        {
            var vsBytecode = ShaderBytecode.CompileFromFile(string.Format(@"Content\{0}", FileName), "VS_Main", "vs_5_0");
            var psBytecode = ShaderBytecode.CompileFromFile(string.Format(@"Content\{0}", FileName), "PS_Main", "ps_5_0");

            _pixelShader = new PixelShader(_myGame.GraphicsDevice, psBytecode);
            _vertexShader = new VertexShader(_myGame.GraphicsDevice, vsBytecode);

            _layout = new InputLayout(_myGame.GraphicsDevice, ShaderSignature.GetInputSignature(vsBytecode), new[]
                    {
                        new InputElement("POSITION", 0, Format.R32G32_Float, 0, 0),
                        new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 8, 0)
                    });
        }
开发者ID:Dani88,项目名称:SphereBed,代码行数:14,代码来源:Drawer.cs

示例14: CreateResources

        void CreateResources()
        {
            // If we have a shader signature, we can store the input layout directly
            if (EffectInputSignature != null)
            {
                InputLayout = GraphicsDevice.InputLayoutManager.GetInputLayout(EffectInputSignature, Layout);
            }

            nativeVertexBufferBindings = vertexBufferBindings.Select(x => new SharpDX.Direct3D11.VertexBufferBinding(x.Buffer.NativeBuffer, x.Stride, x.Offset)).ToArray();

            if (indexBufferBinding != null)
            {
                nativeIndexBuffer = indexBufferBinding.Buffer.NativeBuffer;
            }
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:15,代码来源:VertexArrayObject.Direct3D.cs

示例15: 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


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