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


C# GraphicsDevice.SetVertexBuffer方法代码示例

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


在下文中一共展示了GraphicsDevice.SetVertexBuffer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例4: DrawTrees

        public void DrawTrees(GraphicsDevice device)
        {
            if (this.SceneryVertexCount == 0)
                return;

            device.SetVertexBuffer(m_sceneryVertexBuffer);
            device.Draw(PrimitiveType.PointList, this.SceneryVertexCount);
        }
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:8,代码来源:Chunk.cs

示例5: DrawTerrain

        public void DrawTerrain(GraphicsDevice device)
        {
            if (this.VertexCount == 0)
                return;

            device.SetVertexBuffer(m_vertexBuffer);
            device.Draw(PrimitiveType.PointList, this.VertexCount);
        }
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:8,代码来源:Chunk.cs

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

示例7: draw

            /// <summary>
            /// Called by Game1, draws the final image. This happens independent of
            /// a call to <see cref="Rasterizer.render"/>.
            /// If this method is called without calling <see cref="Rasterizer.render"/> prior to it,
            /// an empty screen appears.
            /// </summary>     
            public void draw(GraphicsDevice device)
            {
                _colorTexture.SetData<Color>(_colorBuffer[0]);
                _depthTexture.SetData<float>(_depthBuffer._elements[0]);

                _effect.CurrentTechnique = _effect.Techniques["Simplest"];
                _effect.Parameters["colorTexture"].SetValue(_colorTexture);
                _effect.Parameters["depthTexture"].SetValue(_depthTexture);
                _effect.Parameters["maxDim"].SetValue(_depthBuffer._maxDims[0]);

                foreach (EffectPass pass in _effect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    device.SetVertexBuffer(_vb);
                    device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
                }

                device.Textures[0] = null;
                device.Textures[1] = null;
            }
开发者ID:denniskb,项目名称:asvo,代码行数:26,代码来源:Rasterizer.cs

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

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

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

示例11: Draw

 public void Draw(GraphicsDevice graphicsDevice)
 {
     if (Visible && vertexBuffer != null)
     {
         graphicsDevice.SetVertexBuffer(vertexBuffer);
         graphicsDevice.Draw(PrimitiveType.PointList, vertexBuffer.ElementCount);
     }
 }
开发者ID:Wumpf,项目名称:mstbasedheightmapgen,代码行数:8,代码来源:PointSet.cs


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