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


C# GraphicsDevice.SetVertexInputLayout方法代码示例

本文整理汇总了C#中GraphicsDevice.SetVertexInputLayout方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.SetVertexInputLayout方法的具体用法?C# GraphicsDevice.SetVertexInputLayout怎么用?C# GraphicsDevice.SetVertexInputLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicsDevice的用法示例。


在下文中一共展示了GraphicsDevice.SetVertexInputLayout方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

 public void Draw(GraphicsDevice device)
 {
     device.SetVertexBuffer(Vertices);
     device.SetIndexBuffer(Indices, true);
     device.SetVertexInputLayout(InputLayout);
     device.DrawIndexed(PrimitiveType.TriangleList, Indices.ElementCount);
 }
开发者ID:jameszhao00,项目名称:mersion,代码行数:7,代码来源:GfxMesh.cs

示例2: DrawScreenAlignedTriangle

        /// <summary>
        /// draws a screen aligned triangle
        /// </summary>
        public void DrawScreenAlignedTriangle(GraphicsDevice device)
        {
            if (!initalised)
                Init(device);

            device.SetRasterizerState(_noneCullingState);
            device.SetVertexBuffer(_screenTriangle);
            device.SetVertexInputLayout(_vertexInputLayout);
            device.Draw(PrimitiveType.TriangleList, 3);
        }
开发者ID:Jojendersie,项目名称:Voxelseeds,代码行数:13,代码来源:ScreenTriangleRenderer.cs

示例3: WarpSceneRenderer

		public WarpSceneRenderer(Scene scene, int width, int height)
		{
			_scene = scene;
			_width = width;
			_height = height;
			_aspectRatio = width / (float)height;

			_device = GraphicsDevice.New(DriverType.Warp, DeviceCreationFlags.None, FeatureLevel.Level_10_1);

			var serviceProvider = new ServiceProvider();
			serviceProvider.AddService<IGraphicsDeviceService>(new GraphicsDeviceService(_device));

			_contentManager = new ContentManager(serviceProvider);
			_contentManager.Resolvers.Add(new ContentResolver());

			var viewport = new Viewport(0, 0, _width, _height);
			_device.SetViewports(viewport);

			const MSAALevel msaaLevel = MSAALevel.None;
			_depthStencilTexture = DepthStencilBuffer.New(_device, _width, _height, msaaLevel, DepthFormat.Depth24Stencil8);
			_renderTexture = RenderTarget2D.New(_device, _width, _height, msaaLevel, PixelFormat.R8G8B8A8.UNorm);

			Options = new RenderOptions();

			_effect = new BasicEffect(_device);
			_effect.EnableDefaultLighting();

			_inputLayout = VertexInputLayout.New(0, typeof(VertexPositionNormalTexture));
			_device.SetVertexInputLayout(_inputLayout);

			_meshes = new List<WarpMesh>();
			foreach (Mesh mesh in _scene.Meshes)
			{
				if (!mesh.Positions.Any())
					continue;

				var warpMesh = new WarpMesh(_device, mesh);
				_meshes.Add(warpMesh);

				warpMesh.Initialize(_contentManager);
			}
		}
开发者ID:modulexcite,项目名称:dotwarp,代码行数:42,代码来源:WarpSceneRenderer.cs

示例4: Draw

        public void Draw(GraphicsDevice graphicsDevice, Camera camera, Texture skyCubemap)
        {
            // setup camera
            Matrix viewProjection = camera.ViewMatrix * camera.ProjectionMatrix;
            Matrix viewProjectionInverse = viewProjection; viewProjectionInverse.Invert();
            var cameraConstantBuffer = terrainShader.Effect.ConstantBuffers["Camera"];
            cameraConstantBuffer.Set(0, viewProjectionInverse);
            cameraConstantBuffer.Set(sizeof(float) * 4 * 4, camera.Position);
            cameraConstantBuffer.IsDirty = true;

            terrainShader.Effect.Parameters["Heightmap"].SetResource(heightmapTexture);
            terrainShader.Effect.Parameters["SkyCubemap"].SetResource(skyCubemap);
            terrainShader.Effect.Parameters["TerrainHeightmapSampler"].SetResource(linearBorderSamplerState);

            graphicsDevice.SetVertexInputLayout(null);
            graphicsDevice.SetVertexBuffer(0, (Buffer<Vector3>)null);

            // Render screen-space terrain, including sky!
            terrainShader.Effect.CurrentTechnique.Passes[0].Apply();
            graphicsDevice.Draw(PrimitiveType.PointList, 1);
        }
开发者ID:Wumpf,项目名称:mstbasedheightmapgen,代码行数:21,代码来源:TerrainRaymarcher.cs

示例5: Draw

        /// <summary>
        /// Draws this <see cref="ModelMeshPart"/>. See remarks for difference with XNA.
        /// </summary>
        /// <param name="graphicsDevice">The graphics device.</param>
        /// <remarks>
        /// Unlike XNA, a <see cref="ModelMeshPart"/> is not bound to a specific Effect. The effect must have been setup prior calling this method.
        /// This method is only responsible to setup the VertexBuffer, IndexBuffer and call the appropriate <see cref="GraphicsDevice.DrawIndexed"/> method on the <see cref="GraphicsDevice"/>.
        /// </remarks>
        public void Draw(GraphicsDevice graphicsDevice)
        {
            // Setup the Vertex Buffer
            var vertexBuffer = VertexBuffer.Resource.Buffer;
            var elementSize = vertexBuffer.ElementSize;
            graphicsDevice.SetVertexBuffer(0, vertexBuffer, elementSize, VertexBuffer.Start == 0 ? 0 : VertexBuffer.Start * elementSize);

            // Setup the Vertex Buffer Input layout
            graphicsDevice.SetVertexInputLayout(VertexBuffer.Resource.Layout);

            // Setup the index Buffer
            var indexBuffer = IndexBuffer.Resource;
            graphicsDevice.SetIndexBuffer(indexBuffer, indexBuffer.ElementSize == 4, IndexBuffer.Start == 0 ? 0 : IndexBuffer.Start * indexBuffer.ElementSize);

            // Finally Draw this mesh
            graphicsDevice.DrawIndexed(PrimitiveType.TriangleList, IndexBuffer.Count);
        }
开发者ID:numo16,项目名称:SharpDX,代码行数:25,代码来源:ModelMeshPart.cs

示例6: DrawGhost

        public void DrawGhost(Camera camera, GraphicsDevice graphicsDevice, VoxelType voxel, Int32 levelPositionCode)
        {
            _voxelEffect.Parameters["ViewProjection"].SetValue(camera.ViewMatrix * camera.ProjectionMatrix);
            _voxelEffect.Parameters["VoxelTexture"].SetResource(_voxelTypeRenderingData[GetRenderingDataIndex(voxel)].Texture);
            _voxelEffect.Parameters["Transparency"].SetValue(0.7f);
            _voxelEffect.Parameters["Ambient"].SetValue(2.0f);
            _voxelEffect.Parameters["ScalingFactor"].SetValue(TypeInformation.GetScalingFactor(voxel) * 0.5f);

            _singleInstanceBuffer.SetDynamicData(graphicsDevice, (ptr) => System.Runtime.InteropServices.Marshal.Copy(
                                                                 new Int32[] { levelPositionCode }, 0, ptr, 1));

            graphicsDevice.SetRasterizerState(_noneCullingState);
            graphicsDevice.SetDepthStencilState(_depthStencilStateState);
            graphicsDevice.SetBlendState(_blendStateTransparent);

            // Setup the vertices
            graphicsDevice.SetVertexBuffer(0, _cubeVertexBuffer);
            graphicsDevice.SetVertexBuffer(1, _singleInstanceBuffer);
            graphicsDevice.SetVertexInputLayout(_vertexInputLayout);

            _voxelEffect.CurrentTechnique.Passes[0].Apply();
            graphicsDevice.DrawInstanced(PrimitiveType.TriangleList, _cubeVertexBuffer.ElementCount, 1, 0, 0);
        }
开发者ID:Jojendersie,项目名称:Voxelseeds,代码行数:23,代码来源:VoxelRenderer.cs

示例7: Draw

        /// <summary>
        /// draw what else
        /// </summary>
        public void Draw(Camera camera, GraphicsDevice graphicsDevice)
        {
            _voxelEffect.Parameters["ViewProjection"].SetValue(camera.ViewMatrix * camera.ProjectionMatrix);
            _voxelEffect.Parameters["Ambient"].SetValue(0.3f);
            _voxelEffect.Parameters["CameraPosition"].SetValue(camera.Position);

            graphicsDevice.SetRasterizerState(_backfaceCullingState);
            graphicsDevice.SetDepthStencilState(_depthStencilStateState);
            graphicsDevice.SetBlendState(_blendStateOpaque);

            // Setup the vertices
            graphicsDevice.SetVertexBuffer(_cubeVertexBuffer, 0);
            graphicsDevice.SetVertexInputLayout(_vertexInputLayout);

            // render all instances
            for (int i = 0; i < _voxelTypeRenderingData.Length; ++i)
            {
                _voxelEffect.Parameters["ScalingFactor"].SetValue(TypeInformation.GetScalingFactor(_voxelTypeRenderingData[i].Voxel) * 0.5f);
                _voxelEffect.Parameters["VoxelTexture"].SetResource(_voxelTypeRenderingData[i].Texture);

                _voxelEffect.Parameters["SpecularModifier"].SetValue(TypeInformation.IsParasite( _voxelTypeRenderingData[i].Voxel ));

                _voxelEffect.CurrentTechnique.Passes[0].Apply();
                graphicsDevice.SetVertexBuffer(1, _voxelTypeRenderingData[i].InstanceBuffer);
                graphicsDevice.DrawInstanced(PrimitiveType.TriangleList, _cubeVertexBuffer.ElementCount, _voxelTypeRenderingData[i].InstanceDataRAM.Count, 0, 0);
            }

            graphicsDevice.SetVertexBuffer<int>(1, (Buffer<int>)null);
        }
开发者ID:Jojendersie,项目名称:Voxelseeds,代码行数:32,代码来源:VoxelRenderer.cs

示例8: DrawGeometry

            public void DrawGeometry(GraphicsDevice graphicsDevice)
            {
                graphicsDevice.SetVertexBuffer(0, patchVertexBuffer, 4, 0);
                graphicsDevice.SetVertexInputLayout(vertexInputLayout);

                for(int i = 0; i < patchInstanceBuffer.Length; ++i)
                {
                    if (currentInstanceData[i].Count == 0)
                        continue;

                    graphicsDevice.SetIndexBuffer(patchIndexBuffer[i], false, 0);
                    graphicsDevice.SetVertexBuffer(1, patchInstanceBuffer[i], sizeof(float) * 4, 0);
                    graphicsDevice.DrawIndexedInstanced(PrimitiveType.PatchList(3), patchIndexBuffer[i].ElementCount, currentInstanceData[i].Count, 0, 0, 0);
                }
            }
开发者ID:Wumpf,项目名称:mstbasedheightmapgen,代码行数:15,代码来源:TerrainRasterizer.cs


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