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


C# GraphicsDevice.DrawPrimitives方法代码示例

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


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

示例1: Render

        public static void Render(BoundingSphere sphere,
                                  GraphicsDevice graphicsDevice,
                                  Matrix view,
                                  Matrix projection,
                                  Color color,
                                  Guid id)
        {
            var subscription = Subscriptions[id];

            graphicsDevice.SetVertexBuffer(subscription.VertexBuffer);
            subscription.BasicEffect.World = Matrix.CreateScale(sphere.Radius)*
                                                   Matrix.CreateTranslation(sphere.Center);
            subscription.BasicEffect.View = view;
            subscription.BasicEffect.Projection = projection;
            subscription.BasicEffect.DiffuseColor = color.ToVector3();

            foreach (var pass in subscription.BasicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip, 0, SphereResolution);
                graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip,
                                              SphereResolution + 1,
                                              SphereResolution);
                graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip,
                                              (SphereResolution + 1)*2,
                                              SphereResolution);
            }
        }
开发者ID:naighes,项目名称:AsteroidChallenge,代码行数:28,代码来源:BoundingSphereRenderer.cs

示例2: Draw

        public void Draw(GraphicsDevice device, BasicEffect effect)
        {
            if (buf == null)
            {
                buf = new VertexBuffer(device, typeof(VertexPositionTexture), 4, BufferUsage.None);
                var vpt = new VertexPositionTexture[4]{
                    new VertexPositionTexture(new Vector3(0, 0, 0), new Vector2(0,0)),
                    new VertexPositionTexture(new Vector3(SIZE, 0, 0), new Vector2(1,0)),
                    new VertexPositionTexture(new Vector3(0, 0, SIZE), new Vector2(0,1)),
                    new VertexPositionTexture(new Vector3(SIZE, 0, SIZE), new Vector2(1,1))
                };

                buf.SetData(vpt);
            }

            device.SetVertexBuffer(buf);

            effect.TextureEnabled = true;
            effect.Texture = texture;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            }
        }
开发者ID:wistery-k,项目名称:Mjai3D,代码行数:26,代码来源:Taku.cs

示例3: RenderToDevice

        public override void RenderToDevice(GraphicsDevice device, BasicEffect basicEffet)
        {
            if (basicEffet.LightingEnabled)
            {

                // Build the cube, setting up the _vertices array
                if (isConstructed == false)
                    Construct();

                // Create the shape buffer and dispose of it to prevent out of memory
                using (VertexBuffer buffer = new VertexBuffer(
                    device,
                    VertexPositionNormalTexture.VertexDeclaration,
                    NUM_VERTICES,
                    BufferUsage.WriteOnly))
                {
                    // Load the buffer
                    buffer.SetData(_vertices);
                    // Send the vertex buffer to the device
                    device.SetVertexBuffer(buffer);
                    // Draw the primitives from the vertex buffer to the device as triangles
                    device.DrawPrimitives(PrimitiveType.TriangleList, 0, NUM_TRIANGLES);
                }
            }
        }
开发者ID:codec-abc,项目名称:3DIsoTetrisXNA,代码行数:25,代码来源:Cube.cs

示例4: 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)
        {
            device.VertexDeclaration = vDecl;
            device.Vertices[0].SetSource(vBuffer, 0, vertexPos.SizeInBytes);

            device.DrawPrimitives(PrimitiveType.TriangleList, 0, numV / 2);
        }
开发者ID:nthfloor,项目名称:Nebulon12,代码行数:12,代码来源:Cube.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 static void draw(GraphicsDevice device)
 {
     if (vBuffer == null)
     {
         vBuffer = CreateVertexBuffer(device);
     }
     device.SetVertexBuffer(vBuffer);
     device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
 }
开发者ID:TheSuperGoge,项目名称:UnDeadSchool,代码行数:9,代码来源:Billboard.cs

示例7: RenderWireframe

 /// <summary>
 /// Draws the primitive to the screen.
 /// </summary>
 /// <param name="device">GPU to draw with.</param>
 public virtual void RenderWireframe(GraphicsDevice device)
 {
     RasterizerState state = new RasterizerState();
     RasterizerState oldState = device.RasterizerState;
     state.FillMode = FillMode.WireFrame;
     device.RasterizerState = state;
     device.SetVertexBuffer(m_vertexBuffer);
     device.DrawPrimitives(PrimitiveType.TriangleList, 0, m_vertices.Length / 3);
     device.RasterizerState = oldState;
 }
开发者ID:careid,项目名称:myheartisinthework,代码行数:14,代码来源:GeometricPrimitive.cs

示例8: Render

        /// <summary>
        /// Draws the primitive to the screen.
        /// </summary>
        /// <param name="device">GPU to draw with.</param>
        public virtual void Render(GraphicsDevice device)
        {
            if (m_vertices == null || m_vertexBuffer == null || m_vertexBuffer.IsDisposed)
            {
                return;
            }

            device.SetVertexBuffer(m_vertexBuffer);
            device.DrawPrimitives(PrimitiveType.TriangleList, 0, m_vertices.Length / 3);
        }
开发者ID:careid,项目名称:myheartisinthework,代码行数:14,代码来源:GeometricPrimitive.cs

示例9: Draw

		/// <summary>
		/// Draws the vertice list on the given surface.
		/// </summary>
		/// <param name="device"></param>
		/// <param name="effect"></param>
		/// <param name="matrixView"></param>
		/// <param name="matrixProjection"></param>
		/// <param name="matrixWorld"></param>
		public void Draw(GraphicsDevice device, BasicEffect effect, Matrix matrixView, Matrix matrixProjection, Matrix matrixWorld) {
			effect.CurrentTechnique.Passes[0].Apply();

			effect.Projection = matrixProjection;
			effect.World = matrixWorld;
			effect.View = matrixView;

			//Device.VertexDeclaration = mVertexDeclaration;
			//Device.Vertices[0].SetSource(mVertexBuffer, 0, VertexPositionColorTexture.SizeInBytes);
			device.SetVertexBuffer(mVertexBuffer);
			device.DrawPrimitives(PrimitiveType.TriangleList, 0, mVerticesList.Count);
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:20,代码来源:DrawableRoRsmMesh.cs

示例10: Draw

        public void Draw(GraphicsDevice graphicsDevice, Effect effect,
            string colorMapParamName, string normalMapParamName,
            Texture2D ColorMap, Texture2D NormalMap)
        {
            graphicsDevice.SetVertexBuffer(vertexBuffer);

            effect.Parameters[colorMapParamName].SetValue(ColorMap);
            effect.Parameters[normalMapParamName].SetValue(NormalMap);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
            }
        }
开发者ID:skakri09,项目名称:LabyrinthExplorer-XNA-3D-game,代码行数:15,代码来源:NormalMappedCeiling.cs

示例11: RenderFloor

        public void RenderFloor(GraphicsDevice gd, Camera camera)
        {
            BuildFloor();

            effect.TextureEnabled = true;

            buffer = new VertexBuffer(gd,
                VertexPositionNormalTexture.SizeInBytes * verticies.Length,
                BufferUsage.WriteOnly);
            buffer.SetData(verticies);

            gd.Vertices[0].SetSource(buffer, 0,
                VertexPositionNormalTexture.SizeInBytes);
            gd.VertexDeclaration = new VertexDeclaration(
                gd, VertexPositionNormalTexture.VertexElements);
            gd.DrawPrimitives(PrimitiveType.TriangleList, 0, triangles);
        }
开发者ID:wbobeirne,项目名称:Voxel-Editor,代码行数:17,代码来源:Floor.cs

示例12: Draw

        public void Draw(GraphicsDevice graphicsDevice,Effect effect,
            string colorMapParamName,string normalMapParamName,
            Texture2D wallColorMap,Texture2D wallNormalMap,
            Texture2D floorColorMap,Texture2D floorNormalMap,
            Texture2D ceilingColorMap,Texture2D ceilingNormalMap)
        {
            // Draw the scene geometry.
            graphicsDevice.SetVertexBuffer(vertexBuffer);

            // Draw the walls.

            effect.Parameters[colorMapParamName].SetValue(wallColorMap);
            effect.Parameters[normalMapParamName].SetValue(wallNormalMap);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, wallsIndex, 8);
            }

            // Draw the ceiling.

            effect.Parameters[colorMapParamName].SetValue(ceilingColorMap);
            effect.Parameters[normalMapParamName].SetValue(ceilingNormalMap);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, ceilingIndex, 2);
            }

            // Draw the floor.

            effect.Parameters[colorMapParamName].SetValue(floorColorMap);
            effect.Parameters[normalMapParamName].SetValue(floorNormalMap);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, floorIndex, 2);
            }
        }
开发者ID:skakri09,项目名称:LabyrinthExplorer-XNA-3D-game,代码行数:42,代码来源:NormalMappedRoom.cs

示例13: Render

        public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
        {
            if (_verts == null)
            {
                CreateRenderElements(aDevice);
            }

            _effect.View = aCamera.View;
            _effect.Projection = aCamera.Projection;
            _effect.Begin();
            for (int i = 0; i < _effect.CurrentTechnique.Passes.Count; ++i)
            {
                _effect.CurrentTechnique.Passes[i].Begin();
                aDevice.VertexDeclaration = new VertexDeclaration(aDevice, VertexPositionColor.VertexElements);
                aDevice.Vertices[0].SetSource(_verts, 0, VertexPositionColor.SizeInBytes);
                aDevice.DrawPrimitives(PrimitiveType.LineList, 0, _primativeCount);
                _effect.CurrentTechnique.Passes[i].End();
            }
            _effect.End();
        }
开发者ID:darrentorpey,项目名称:define_yourself,代码行数:20,代码来源:GridActor.cs

示例14: Draw

        // Draws the triangle mesh.
        public void Draw(GraphicsDevice graphicsDevice, BasicEffect effect, Pose pose, Color color)
        {
            if (_vertexBuffer == null)
            return;

              // Select the vertex buffer.
              graphicsDevice.SetVertexBuffer(_vertexBuffer);

              // The parameter 'pose' defines the world matrix and can be implicitly converted to
              // a XNA Matrix.
              effect.World = pose;
              effect.DiffuseColor = color.ToVector3();

              // Draw the vertex buffer.
              foreach (EffectPass pass in effect.CurrentTechnique.Passes)
              {
            pass.Apply();
            graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, _numberOfTriangles);
              }
        }
开发者ID:HATtrick-games,项目名称:ICT309,代码行数:21,代码来源:DrawableShape.cs

示例15: Draw

        public void Draw(GameTime gameTime, GraphicsDevice device, Effect effect, Matrix worldViewProjectionMatrix, int resolutionWidth, int resolutionHeight)
        {
            effect.Parameters["xWorldViewProjection"].SetValue(worldViewProjectionMatrix);
            effect.Parameters["xWidth"].SetValue(resolutionWidth);
            effect.Parameters["xHeight"].SetValue(resolutionHeight);

            effect.Begin();
            foreach (SModelMesh mesh in _meshes)
            {
                effect.Parameters["xTexture"].SetValue(mesh.texture);
                foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                {
                    pass.Begin();
                    device.VertexDeclaration = _vertexDeclaration;
                    device.Vertices[0].SetSource(mesh.vertexBuffer, 0, _vertexSizeInBytes);
                    device.DrawPrimitives(PrimitiveType.TriangleList, 0, mesh.numPrimitives);
                    pass.End();
                }
            }
            effect.End();
        }
开发者ID:obyrnemj,项目名称:computational-geometry-3d-vision,代码行数:21,代码来源:CMD2Model.cs


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