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


C# GraphicsDevice.DrawIndexedPrimitives方法代码示例

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


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

示例1: RenderMesh

 public void RenderMesh(GraphicsDevice graphicsDevice)
 {
     graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0,
                                     meshPart.NumVertices,
                                     meshPart.StartIndex,
                                     meshPart.PrimitiveCount);
 }
开发者ID:justshiv,项目名称:LightSavers,代码行数:7,代码来源:MeshRenderer.cs

示例2: Render

        public void Render(GraphicsDevice device, Camera cam)
        {
            if (!Transform.renderer.enabled)
            {
                return;
            }

            device.SetVertexBuffer(VertexBuffer);
            device.Indices = IndexBuffer;

            Effect e = Material.shader.effect;
            Material.shader.ApplyPreRenderSettings(Material, UseVertexColor);
            Material.SetBlendState(device);

            IEffectMatrices ems = e as IEffectMatrices;
            if (ems != null)
            {
                ems.World = Transform.world;
                ems.View = cam.view;
                ems.Projection = cam.projectionMatrix;
            }
            foreach (EffectPass pass in e.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawIndexedPrimitives(
                    PrimitiveType.TriangleList,
                    0,
                    0,
                    VertexBuffer.VertexCount,
                    0,
                    IndexBuffer.IndexCount / 3
                );
            }
            RenderStats.AddDrawCall(batches, VertexBuffer.VertexCount, IndexBuffer.IndexCount / 3);
        }
开发者ID:iamjianxin,项目名称:FFWD,代码行数:35,代码来源:RenderItem.cs

示例3: Draw

        /// <summary>
        /// Render the terrain
        /// </summary>
        /// <param name="device"></param>
        /// <param name="world"></param>
        public override void Draw(GraphicsDevice device, WorldState world)
        {
            world._3D.ApplyCamera(Effect, this);
            //device.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
            //device.SamplerStates[0].AddressV = TextureAddressMode.Wrap;

            device.SetVertexBuffer(VertexBuffer);
            device.Indices = IndexBuffer;

            //device.RasterizerState.CullMode = CullMode.None;
            foreach (var pass in Effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, GeomLength, 0, NumPrimitives);
            }

            device.SetVertexBuffer(GrassVertexBuffer);
            //device.Indices = GrassIndexBuffer;

            foreach (var pass in Effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawPrimitives(PrimitiveType.LineList, 0, GrassPrimitives);
                //device.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, GrassPrimitives*2, 0, GrassPrimitives);
            };
        }
开发者ID:Daribon,项目名称:FreeSO,代码行数:31,代码来源:TerrainComponent.cs

示例4:

 void IMesh.Render(GraphicsDevice Device)
 {
     Device.SetVertexBuffer(verticies);
     Device.Indices = indicies;
     Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, verticies.VertexCount,
         0, System.Math.Min(primitiveCount, 65535));
 }
开发者ID:Blecki,项目名称:CCDC,代码行数:7,代码来源:CompiledModel.cs

示例5: Render

        /// <summary>
        /// Draws the primitive to the screen.
        /// </summary>
        /// <param Name="device">GPU to draw with.</param>
        public virtual void Render(GraphicsDevice device)
        {
            lock (VertexLock)
            {
            #if MONOGAME_BUILD
                device.SamplerStates[0].Filter = TextureFilter.Point;
                device.SamplerStates[1].Filter = TextureFilter.Point;
                device.SamplerStates[2].Filter = TextureFilter.Point;
                device.SamplerStates[3].Filter = TextureFilter.Point;
                device.SamplerStates[4].Filter = TextureFilter.Point;
            #endif
                if (VertexBuffer == null)
                {
                    return;
                }

                if (Vertices == null || VertexBuffer == null || Vertices.Length < 3 ||  VertexBuffer.IsDisposed || VertexBuffer.VertexCount < 3)
                {
                    return;
                }

                device.SetVertexBuffer(VertexBuffer);

                if (IndexBuffer != null)
                {
                    device.Indices = IndexBuffer;
                    device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, VertexBuffer.VertexCount, 0, IndexBuffer.IndexCount / 3);
                }
                else
                {
                    device.DrawPrimitives(PrimitiveType.TriangleList, 0, Vertices.Length/3);
                }
            }
        }
开发者ID:scorvi,项目名称:dwarfcorp,代码行数:38,代码来源:GeometricPrimitive.cs

示例6: draw

 public void draw(GraphicsDevice graphics)
 {
     foreach (EffectPass pass in _shader.CurrentTechnique.Passes)
     {
         pass.Apply();
         CGraphics.GPU.SetVertexBuffer(_vertexBuffer);
         graphics.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, vertices.Length, 0, 1);
     }
 }
开发者ID:MGZero,项目名称:King-of-Thieves,代码行数:9,代码来源:CRenderable.cs

示例7: Draw

        public void Draw(GraphicsDevice graphics, Matrix world, Matrix view, Matrix projection)
        {
            graphics.SetVertexBuffer(vertices);
            graphics.Indices = indices;

            skyEffect.Parameters["WVP"].SetValue(world * view * projection);
            skyEffect.CurrentTechnique.Passes[0].Apply();

            graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, number_of_vertices, 0, number_of_indices / 3);
        }
开发者ID:romain-lefevere,项目名称:cassebrique,代码行数:10,代码来源:SkyBox.cs

示例8: Draw

        internal void Draw(Texture2D[] textures, GraphicsDevice device, BasicEffect effect, EffectPass pass)
        {
            effect.World = displayObject.WorldTransform;
            effect.Texture = textures[displayObject.TextureIndex];
            device.SetVertexBuffer(vertexBuffer);
            device.Indices = indexBuffer;
            pass.Apply();

            device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, indices.Length / 3);
        }
开发者ID:Jamedjo,项目名称:BeatShiftLib,代码行数:10,代码来源:BruteDisplayObjectEntry.cs

示例9: Draw

        //Draw and Set Buffers
        public void Draw(GraphicsDevice GraphicsDevice)
        {
            //Set Vertex Buffer
            GraphicsDevice.SetVertexBuffer(vb);

            //Set Index Buffer
            GraphicsDevice.Indices = ib;

            //Draw Quad
            GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2);
        }
开发者ID:powercharger97,项目名称:AsterCorp,代码行数:12,代码来源:FullScreenQuad.cs

示例10: draw

        /// <summary>
        /// Draws the Sphere
        /// </summary>
        /// <param name="device">Graphics device</param>
        /// <param name="camera">What camera to draw on</param>
        public void draw(GraphicsDevice device, Camera.CameraMatrices camera)
        {
            for (int i = 0; i < numB; i++)
            {
                device.VertexDeclaration = vDecl;
                device.Vertices[0].SetSource(vBuffer, 0, vertexPos.SizeInBytes);
                device.Indices = iBuffer[i];

                device.DrawIndexedPrimitives(PrimitiveType.TriangleStrip, 0, 0, numV, 0, numI - 2);
            }
        }
开发者ID:nthfloor,项目名称:Nebulon12,代码行数:16,代码来源:Sphere.cs

示例11: DrawGeometry

 public void DrawGeometry(GraphicsDevice gd)
 {
     if (GPUMode){
         gd.VertexDeclaration = new VertexDeclaration(gd, MeshVertex.VertexElements);
         gd.Indices = GPUIndexBuffer;
         gd.Vertices[0].SetSource(GPUBlendVertexBuffer, 0, MeshVertex.SizeInBytes);
         gd.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, BlendVertexBuffer.Length, 0, NumPrimitives);
     }else{
         gd.VertexDeclaration = new VertexDeclaration(gd, MeshVertex.VertexElements);
         gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, BlendVertexBuffer, 0, BlendVertexBuffer.Length, IndexBuffer, 0, NumPrimitives);
     }
 }
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:12,代码来源:Mesh.cs

示例12: Draw

        //-----------------------------------------------------------------------
        public void Draw(GraphicsDevice device)
        {
            if (indices.Length == 0)
                return;

            if (isDirty)
                Warm(device);

            device.SetVertexBuffer(vertexbuffer);
            device.Indices = indexbuffer;
            device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, indices.Length / 3);
        }
开发者ID:zfedoran,项目名称:helium,代码行数:13,代码来源:mesh.cs

示例13: Draw

        /// <summary>
        /// This renders the grid as constructed.
        /// </summary>
        public void Draw()
        {
            IGraphicsDeviceService igs = (IGraphicsDeviceService)game.Services.GetService(typeof(IGraphicsDeviceService));
            graphicsDevice = igs.GraphicsDevice;

            int numVertices = (dimension + 1) * (dimension + 1);
            int numTriangles = 2 * dimension * dimension;

            graphicsDevice.VertexDeclaration = vertexDecl;
            graphicsDevice.Vertices[0].SetSource(vertexBuffer, 0, VertexPositionNormalTexture.SizeInBytes);
            graphicsDevice.Indices = indexBuffer;
            graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, numVertices, 0, numTriangles);
        }
开发者ID:zpconn,项目名称:TerrainExplorer,代码行数:16,代码来源:Grid.cs

示例14: drawPass

 //描画パスごとに呼び出す
 public void drawPass(GraphicsDevice inDevice)
 {
     inDevice.SetVertexBuffer(m_VertexBuffer);
     inDevice.Indices=m_IndexBuffer;
     inDevice.DrawIndexedPrimitives(
         PrimitiveType.TriangleList,
         0,
         0,
         m_Vertices.Length,
         0,
         m_Indices.Length / 3
     );
 }
开发者ID:novogrammer,项目名称:KinectSdkKyonyu,代码行数:14,代码来源:KyonyuMesh.cs

示例15: DrawSkybox

        public void DrawSkybox(Matrix viewMatrix, Matrix projectionMatrix, 
            Matrix camWorld, GraphicsDevice device)
        {
            device.SetVertexBuffer(vertices);
            device.Indices = indices;

            skyEffect.Parameters["WVP"].SetValue(camWorld * projectionMatrix * viewMatrix
                *Matrix.CreateScale(100));
            skyEffect.CurrentTechnique.Passes[0].Apply();

            device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0,
                number_of_vertices, 0, number_of_indices / 3);
        }
开发者ID:skakri09,项目名称:LabyrinthExplorer-XNA-3D-game,代码行数:13,代码来源:Skybox.cs


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