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


C# Device.DrawPrimitives方法代码示例

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


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

示例1: Main

        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var form = new Form1();

            var panel = form.SplitContainer.Panel1;

            var device = new Device(new Direct3D(), 0, DeviceType.Hardware, panel.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters()
            {
                BackBufferWidth = panel.ClientSize.Width,
                BackBufferHeight = panel.ClientSize.Height

            });

            var vertices = new VertexBuffer(device, 3 * 20, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
            vertices.Lock(0, 0, LockFlags.None).WriteRange(new[] {
                new Vertex() { Color = Color.Red.ToArgb(), Position = new Vector4(400.0f, 100.0f, 0.5f, 1.0f) },
                new Vertex() { Color = Color.Blue.ToArgb(), Position = new Vector4(650.0f, 500.0f, 0.5f, 1.0f) },
                new Vertex() { Color = Color.Green.ToArgb(), Position = new Vector4(150.0f, 500.0f, 0.5f, 1.0f) }
            });
            vertices.Unlock();

            var vertices2 = new VertexBuffer(device, 3 * 20, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
            vertices2.Lock(0, 0, LockFlags.None).WriteRange(new[] {
                new Vertex() { Color = Color.Red.ToArgb(), Position = new Vector4(300.0f, 100.0f, 0.5f, 1.0f) },
                new Vertex() { Color = Color.Blue.ToArgb(), Position = new Vector4(550.0f, 500.0f, 0.5f, 1.0f) },
                new Vertex() { Color = Color.Green.ToArgb(), Position = new Vector4(050.0f, 500.0f, 0.5f, 1.0f) }
            });
            vertices2.Unlock();

            var vertexElems = new[] {
                new VertexElement(0, 0, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.PositionTransformed, 0),
                new VertexElement(0, 16, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0),
                VertexElement.VertexDeclarationEnd
            };

            var vertexDecl = new VertexDeclaration(device, vertexElems);

            MessagePump.Run(form, () =>
            {
                device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
                device.BeginScene();

                device.SetStreamSource(0, vertices, 0, 20);
                device.VertexDeclaration = vertexDecl;
                device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);

                device.SetStreamSource(0, vertices2, 0, 20);
                device.VertexDeclaration = vertexDecl;
                device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);

                device.EndScene();
                device.Present();
            });

            foreach (var item in ObjectTable.Objects)
                item.Dispose();
        }
开发者ID:duk3luk3,项目名称:KSPEdit,代码行数:60,代码来源:Program.cs

示例2: Poke

        public void Poke( DateTime timestamp, Device world )
        {
            var vb = new VertexBuffer( typeof( CustomVertex.PositionColored ), 6, world, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default );

            var vertices = new CustomVertex.PositionColored[6];

            int i = 0;
            vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
            vertices[i++].Position = new Vector3( 100, 200, 1 );

            vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
            vertices[i++].Position = new Vector3( 0, 100, 1 );

            vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
            vertices[i++].Position = new Vector3( 200, 100, 1 );

            vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
            vertices[i++].Position = new Vector3( 200, 300, 1 );

            vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
            vertices[i++].Position = new Vector3( 0, 300, 1 );

            vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
            vertices[i++].Position = new Vector3( 0, 100, 1 );

            vb.SetData( vertices, 0, LockFlags.None );
            world.SetStreamSource( 1, vb, 0 );
            world.DrawPrimitives( PrimitiveType.TriangleFan, 0, 6 );
        }
开发者ID:Zazcallabah,项目名称:jsdemos,代码行数:29,代码来源:PortedActor.cs

示例3: RenderAxis

 public void RenderAxis(Device d3dDevice)
 {
     d3dDevice.RenderState.Lighting = false;
     d3dDevice.SetStreamSource(0, m_CoordinateAxis, 0);
     d3dDevice.VertexFormat = CustomVertex.PositionColored.Format;
     d3dDevice.DrawPrimitives(PrimitiveType.LineList, 0, 3);
     d3dDevice.RenderState.Lighting = true;
 }
开发者ID:NHNNEXT,项目名称:2014-01-HUDIGAME-skyLab,代码行数:8,代码来源:CoordinateAxis.cs

示例4: draw

        public void draw(Vector3 cameraRotation, Device device)
        {
            device.SetTexture(0, particleTexture);

            device.TextureState[0].AlphaOperation = TextureOperation.Modulate;
            device.TextureState[0].AlphaArgument0 = TextureArgument.Current;
            device.TextureState[0].AlphaArgument1 = TextureArgument.Diffuse;
            device.TextureState[0].AlphaArgument2 = TextureArgument.TextureColor;

            device.TextureState[0].ColorArgument0 = TextureArgument.Current;
            device.TextureState[0].ColorArgument1 = TextureArgument.Diffuse;
            device.TextureState[0].ColorArgument2 = TextureArgument.TextureColor;
            device.TextureState[0].ColorOperation = TextureOperation.Modulate;

            Material material = device.Material;
            Color diffuse = material.Diffuse;
            material.Diffuse = fade;
            material.Emissive = Color.White;
            device.Material = material;

            foreach (ParticleData particle in particleList)
            {
                device.Transform.World =
                    Matrix.RotationYawPitchRoll(cameraRotation.X, cameraRotation.Y, cameraRotation.Z) *
                    Matrix.Translation(particle.location);

                VertexBuffer buffer = new VertexBuffer(typeof(CustomVertex.PositionNormalTextured), 4, device, 0, CustomVertex.PositionNormalTextured.Format, Pool.Default);
                CustomVertex.PositionNormalTextured[] vertices = (CustomVertex.PositionNormalTextured[])buffer.Lock(0, 0);

                float particleRadius = particle.size / 2;

                vertices[0] = new CustomVertex.PositionNormalTextured(new Vector3(-particleRadius, -particleRadius, 0f), new Vector3(0, 1, 0), 0, 1); // bottom right
                vertices[1] = new CustomVertex.PositionNormalTextured(new Vector3(-particleRadius, particleRadius, 0f), new Vector3(0, 1, 0), 0, 0); // top right
                vertices[2] = new CustomVertex.PositionNormalTextured(new Vector3(particleRadius, -particleRadius, 0f), new Vector3(0, 1, 0), 1, 1); // bottom left
                vertices[3] = new CustomVertex.PositionNormalTextured(new Vector3(particleRadius, particleRadius, 0), new Vector3(0, 1, 0), 1, 0); // top left

                buffer.Unlock();

                device.VertexFormat = CustomVertex.PositionNormalTextured.Format;
                device.SetStreamSource(0, buffer, 0);
                device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            }
        }
开发者ID:newgrounds,项目名称:Clear-Skies,代码行数:43,代码来源:ExpolsionParticleEmitter.cs

示例5: RenderHorizontalLines

 private static void RenderHorizontalLines(Device dev, VertexBuffer vertex, int count)       
 {
     dev.SetStreamSource(0, vertex, 0, 20);
     dev.DrawPrimitives(PrimitiveType.LineList, 0, count);
 }
开发者ID:GoranRadivojevic,项目名称:CW-expert,代码行数:5,代码来源:Display.cs

示例6: render

        public void render(ref Device device, ref Microsoft.DirectX.Direct3D.Font directxFont)
        {
            // Render the module names and outlines
            if( moduleManager != null )
                moduleManager.render(ref device, ref directxFont);

            // Render the functions
            if (vertexBufferFunctions != null)
            {
                device.SetStreamSource(0, vertexBufferFunctions, 0);
                device.VertexFormat = CustomVertex.TransformedColored.Format;
                device.DrawPrimitives(PrimitiveType.PointList, 0, vertexFunctionsCount);
            }

            // Render the function links
            if (vertexBufferLinks != null && vertexLinksCount > 0)
            {
                device.SetStreamSource(0, vertexBufferLinks, 0);
                device.VertexFormat = CustomVertex.TransformedColored.Format;
                device.DrawPrimitives(PrimitiveType.LineList, 0, vertexLinksCount/2);
            }
        }
开发者ID:obarhleam,项目名称:FunctionHacker,代码行数:22,代码来源:oVisLookup.cs

示例7: DrawBox

        /*
        private void DrawBox(float yaw, float pitch, float roll, float x, float y, float z)
        {
            angle += 0.01f;

            device.Transform.World = Matrix.RotationYawPitchRoll(yaw, pitch, roll) * Matrix.Translation(x, y, z);
            device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, verts.Length, 0, indices.Length / 3);
        }
        */

        /// <summary>
        /// render 3D objects
        /// </summary>
        /// <param name="d3d"></param>
        /// <param name="dx"></param>
        private void render3D(Device dx)
        {
            if ((initialised_3D) && (selected_display == MonoSLAM.DISPLAY_AUGMENTED_REALITY))
            {
                if ((test.enable_mapping) && (!test.calibrating))
                {
                    // Set the position of the camera
                    Vector3D camera_position = null;
                    SceneLibrary.Quaternion camera_orientation = null;
                    test.getCameraPositionOrientation(ref camera_position, ref camera_orientation);

                    dx.Transform.View = QuaternionToMatrixLookAt(camera_position, camera_orientation);

                    /*
                    Microsoft.DirectX.Quaternion q_orientation =
                        new Microsoft.DirectX.Quaternion((float)camera_orientation.GetX(),
                                     (float)camera_orientation.GetY(),
                                     (float)camera_orientation.GetZ(),
                                     (float)camera_orientation.GetR());
                    Matrix _matrixRotation = Matrix.RotationQuaternion(q_orientation);
                    float yaw = 0, pitch = 0, roll = 0;
                    camera_orientation.GetZYXEuler(ref pitch, ref yaw, ref roll);

                    dx.Transform.View = QuaternionToMatrixLookAt(camera_position, camera_orientation) *
                        Matrix.RotationYawPitchRoll(0,0,(float)(roll));
                    */


                    //dx.Material = InitMaterial(Color.White);

                    dx.Clear(ClearFlags.ZBuffer, Color.FromArgb(255, 0, 0, 0), 1.0f, 0);
                    //dx.Clear(ClearFlags.Target | ClearFlags.ZBuffer,Color.FromArgb(255, 0, 0, 0), 1.0f, 0);
                    //dx.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Transparent, 1.0f, 0);

                    if (background_image == null)
                        background_image = new D3D_background(dx, background_bitmap);
                    else
                        background_image.update(dx, background_bitmap);

                    background_image.Draw();


                    /*
                    dx.BeginScene();

                    dx.Transform.World = Matrix.Identity;
                    ScaleMatrices(dx, 1000, 0.1f, 0.1f);

                    dx.VertexFormat = Vertex.FVF_Flags;
                    dx.SetStreamSource(0, lineVertexBuffer, 0);

                    //dx.SetTexture(0, texture);

                    dx.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                    dx.DrawPrimitives(PrimitiveType.TriangleStrip, 4, 2);

                    dx.EndScene();

                    // this try/catch prevents an error if the scene is being rendered 
                    // whilst the window is being closed
                    try
                    {
                        dx.Present();
                    }
                    catch
                    {
                    }


                    dx.BeginScene();

                    dx.Transform.World = Matrix.Identity;
                    ScaleMatrices(dx, 0.1f, 1000, 0.1f);

                    dx.VertexFormat = Vertex.FVF_Flags;
                    dx.SetStreamSource(0, lineVertexBuffer, 0);

                    //dx.SetTexture(0, texture);

                    dx.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                    dx.DrawPrimitives(PrimitiveType.TriangleStrip, 4, 2);

                    dx.EndScene();

                    // this try/catch prevents an error if the scene is being rendered 
//.........这里部分代码省略.........
开发者ID:iManbot,项目名称:monoslam,代码行数:101,代码来源:frmMain.cs

示例8: drawPostProcess

        /// <summary>
        /// Se toma todo lo dibujado antes, que se guardo en una textura, y se le aplica un shader para borronear la imagen
        /// </summary>
        private void drawPostProcess(Device d3dDevice, float elapsedTime)
        {
            //Arrancamos la escena
            d3dDevice.BeginScene();

            //Cargamos para renderizar el unico modelo que tenemos, un Quad que ocupa toda la pantalla, con la textura de todo lo dibujado antes
            d3dDevice.VertexFormat = CustomVertex.PositionTextured.Format;
            d3dDevice.SetStreamSource(0, screenQuadVB, 0);

            effect.Technique = "AlarmaTechnique";

            //Cargamos parametros en el shader de Post-Procesado
            effect.SetValue("render_target2D", renderTarget2D);
            effect.SetValue("textura_alarma", alarmTexture.D3dTexture);
            effect.SetValue("alarmaScaleFactor", intVaivenAlarm.update());

            //Limiamos la pantalla y ejecutamos el render del shader
            d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            effect.Begin(FX.None);
            effect.BeginPass(0);
            d3dDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            effect.EndPass();
            effect.End();

            //Terminamos el renderizado de la escena
            d3dDevice.EndScene();
        }
开发者ID:nicolasazrak,项目名称:RenderMan,代码行数:30,代码来源:PostProcesadoManager.cs

示例9: RenderPhase2

        private static void RenderPhase2(Device dev)        // yt7pwr
        {
            try
            {
                int x, y;

                for (int i = 0, j = 0; i < phase_num_pts; i++, j += 8)	// fill point array
                {
                    x = (int)(current_display_data[i * 2] * panadapter_H * 0.5 * 500);
                    y = (int)(current_display_data[i * 2 + 1] * panadapter_H * 0.5 * 500);
                    Panadapter_verts[i].Color = data_line_color.ToArgb();
                    Panadapter_verts[i].Position.X = panadapter_W * 0.5f + x;
                    Panadapter_verts[i].Position.Y = panadapter_H * 0.5f + y;
                }

                Panadapter_vb.Lock(0, 0, LockFlags.None).WriteRange(Panadapter_verts, 0, phase_num_pts);
                Panadapter_vb.Unlock();

                dev.SetStreamSource(0, Panadapter_vb, 0, 20);
                dev.DrawPrimitives(PrimitiveType.LineStrip, 0, phase_num_pts - 1);
            }
            catch (Exception ex)
            {
                Debug.Write(ex.ToString());
            }
        }
开发者ID:Dfinitski,项目名称:genesisradio,代码行数:26,代码来源:display_DirectX.cs

示例10: Render

        /// <summary>
        /// Draw the polygon
        /// </summary>
        /// <param name="device">The device to draw on</param>
        public virtual void Render(Device device)
        {
            // Get the vertices we will draw
            List<Vector2> vertices = Vertices;

            // Ensure we have at least a triangle
            if (vertices.Count < 3)
                return;

            if (verticesV == null)
            {
                verticesV = new VertexBuffer(typeof(CustomVertex.PositionColored),    // Type
                   vertices.Count,      // How many
                   device, // What device
                   0,      // No special usage
                   CustomVertex.PositionColored.Format,
                   Pool.Managed);
            }

            GraphicsStream gs = verticesV.Lock(0, 0, 0);     // Lock the background vertex list
            int clr = color.ToArgb();

            foreach (Vector2 v in vertices)
            {
                gs.Write(new CustomVertex.PositionColored(v.X, v.Y, 0, clr));
            }

            verticesV.Unlock();

            device.SetStreamSource(0, verticesV, 0);
            device.VertexFormat = CustomVertex.PositionColored.Format;
            device.DrawPrimitives(PrimitiveType.TriangleFan, 0, vertices.Count - 2);
        }
开发者ID:KylerWilkins,项目名称:OldPro3,代码行数:37,代码来源:Polygon.cs

示例11: DrawScene

        public int DrawScene(Device d3dDev, Texture texture)
        {
            if (vertexBuffer == null)
            return E_FAIL;

              // get the difference in time
              int currentTime = GetTickCount();
              double difference = time - currentTime ;

              // figure out the rotation of the plane
              float x = (float) (-Math.Cos(difference / 2000.0));
              float y = (float) (Math.Cos(difference / 2000.0));
              float z = (float) (Math.Sin(difference / 2000.0));

              // update the two rotating vertices with the new position
              vertices[0].Position = new Vector3(x, y, z);
              vertices[3].Position = new Vector3(-x, -y, -z);

              // Adjust the color so the blue is always on the bottom.
              // As the corner approaches the bottom, get rid of all the other
              // colors besides blue
              int mask0 = (int) (255 * (( y + 1.0) / 2.0));
              int mask3 = (int) (255 * (( -y + 1.0 ) / 2.0));
              vertices[0].Color = unchecked((int) 0xff0000ff | (mask0 << 16) | (mask0 << 8));
              vertices[3].Color = unchecked((int) 0xff0000ff | (mask3 << 16) | (mask3 << 8));

              try
              {
            // write the new vertex information into the buffer
            vertexBuffer.SetData(vertices, 0, LockFlags.None);

            // clear the scene so we don't have any articats left
            d3dDev.Clear(ClearFlags.Target, 0x00ffffff, 1.0f, 0);

            d3dDev.BeginScene();
            d3dDev.SetTexture(0, texture);

            d3dDev.SetTextureStageState(0, TextureStageStates.AlphaOperation, (int)TextureOperation.Modulate);
            d3dDev.SetTextureStageState(0, TextureStageStates.AlphaArgument1, (int)TextureArgument.TextureColor);
            d3dDev.SetTextureStageState(0, TextureStageStates.AlphaArgument2, (int)TextureArgument.Diffuse);
            d3dDev.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);

            d3dDev.SetStreamSource(0, vertexBuffer, 0);
            d3dDev.VertexFormat = CustomVertex.PositionColoredTextured.Format;
            d3dDev.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            d3dDev.SetTexture(0, null);
            d3dDev.EndScene();
              }
              catch(DirectXException e)
              {
            return e.ErrorCode;
              }
              catch
              {
            return E_FAIL;
              }

              return 0;
        }
开发者ID:coolsula,项目名称:vidplaycorder,代码行数:59,代码来源:PlaneScene.cs

示例12: RenderScopeLine

        public static void RenderScopeLine(Device dev, int count, bool monitor)
        {
            try
            {
                Mode new_mode = MainForm.OpModeVFOA;

                if (Audio.channel == 6)
                    new_mode = MainForm.OpModeVFOB;

                switch (new_mode)
                {
                    case Mode.RTTY:
                        {
                            ////////////// mark ////////////////////

                            for (int i = 0; i < count * 2; i++)
                            {
                                ScopeLine_verts[i] = new Vertex();
                                ScopeLine_verts[i].Color = data_line_color.ToArgb();
                                ScopeLine_verts[i].Position = new Vector4(i / 2, panadapterX_scope_data_mark[i], 0.0f, 0.0f);
                                ScopeLine_verts[i + 1] = new Vertex();
                                ScopeLine_verts[i + 1].Color = data_line_color.ToArgb();
                                ScopeLine_verts[i + 1].Position = new Vector4(i / 2, panadapterX_scope_data_mark[i + 1], 0.0f, 0.0f);
                                i++;
                            }

                            if (monitor)
                            {
                                ScopeLine_vb_monitor.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
                                ScopeLine_vb_monitor.Unlock();
                                dev.SetStreamSource(0, ScopeLine_vb_monitor, 0, 20);
                                dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
                            }
                            else
                            {
                                ScopeLine_vb.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
                                ScopeLine_vb.Unlock();
                                dev.SetStreamSource(0, ScopeLine_vb, 0, 20);
                                dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
                            }

                            ////////////// space ///////////////////

                            for (int i = 0; i < count * 2; i++)
                            {
                                ScopeLine_verts[i] = new Vertex();
                                ScopeLine_verts[i].Color = data_line_color.ToArgb();
                                ScopeLine_verts[i].Position = new Vector4(i / 2, panadapterX_scope_data_space[i], 0.0f, 0.0f);
                                ScopeLine_verts[i + 1] = new Vertex();
                                ScopeLine_verts[i + 1].Color = data_line_color.ToArgb();
                                ScopeLine_verts[i + 1].Position = new Vector4(i / 2, panadapterX_scope_data_space[i + 1], 0.0f, 0.0f);
                                i++;
                            }

                            if (monitor)
                            {
                                ScopeLine_vb_monitor.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
                                ScopeLine_vb_monitor.Unlock();
                                dev.SetStreamSource(0, ScopeLine_vb_monitor, 0, 20);
                                dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
                            }
                            else
                            {
                                ScopeLine_vb.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
                                ScopeLine_vb.Unlock();
                                dev.SetStreamSource(0, ScopeLine_vb, 0, 20);
                                dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
                            }
                        }
                        break;

                    default:
                        {
                            for (int i = 0; i < count * 2; i++)
                            {
                                ScopeLine_verts[i] = new Vertex();
                                ScopeLine_verts[i].Color = data_line_color.ToArgb();// Color.Wheat.ToArgb();
                                ScopeLine_verts[i].Position = new Vector4(i / 2, panadapterX_scope_data[i], 0.0f, 0.0f);
                                ScopeLine_verts[i + 1] = new Vertex();
                                ScopeLine_verts[i + 1].Color = data_line_color.ToArgb(); // Color.Wheat.ToArgb();
                                ScopeLine_verts[i + 1].Position = new Vector4(i / 2, panadapterX_scope_data[i + 1], 0.0f, 0.0f);
                                i++;
                            }

                            if (monitor)
                            {
                                ScopeLine_vb_monitor.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
                                ScopeLine_vb_monitor.Unlock();
                                dev.SetStreamSource(0, ScopeLine_vb_monitor, 0, 20);
                                dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
                            }
                            else
                            {
                                ScopeLine_vb.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
                                ScopeLine_vb.Unlock();
                                dev.SetStreamSource(0, ScopeLine_vb, 0, 20);
                                dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
                            }
                        }
                        break;
//.........这里部分代码省略.........
开发者ID:GoranRadivojevic,项目名称:CW-expert,代码行数:101,代码来源:Display.cs

示例13: render

 public override void render(Device dx_device)
 {
     dx_device.SetStreamSource(0, m_VB, 0);
     dx_device.VertexFormat = m_VB.Description.VertexFormat;
     dx_device.DrawPrimitives(PrimitiveType.TriangleList, 0, m_nPrimitives);
 }
开发者ID:blmarket,项目名称:lib4bpp,代码行数:6,代码来源:Form1.cs

示例14: Render

        /// <summary>Renders the quads with this style.</summary>
        /// <param name="device">D3D Device</param>
        /// <param name="quads">Quads to render</param>
        public void Render(Device device, List<Quad> quads)
        {
            if (quads.Count == 0)
                return;
            // Add vertices to the buffer
            GraphicsStream gb =
                m_vb.Lock(0, 6 * quads.Count * CustomVertex.TransformedColoredTextured.StrideSize, LockFlags.Discard);

            Quad q;
            for (int i = 0; i < quads.Count;i++ )
            {
                q = (Quad)quads[i].Clone();
                q.X -= 0.5f;
                q.Y -= 0.5f;
                gb.Write(q.Vertices);
            }

            m_vb.Unlock();

            // Set render states
            device.SetRenderState(RenderStates.Lighting, false);
            device.SetRenderState(RenderStates.ZBufferWriteEnable, false);
            device.SetRenderState(RenderStates.ZEnable, false);
            device.SetRenderState(RenderStates.AlphaBlendEnable, true);
            device.SetRenderState(RenderStates.SourceBlend, (int)Blend.SourceAlpha);
            device.SetRenderState(RenderStates.DestinationBlend, (int)Blend.InvSourceAlpha);
            device.SetStreamSource(0, m_vb, 0, CustomVertex.TransformedColoredTextured.StrideSize);
            device.SetTexture(0, m_texture);
            device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
            device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2 * quads.Count);
        }
开发者ID:kensniper,项目名称:castle-butcher,代码行数:34,代码来源:GuiStyle.cs

示例15: Render

        public void Render(Device device)
        {
            if (Geometry.Clr != -1)
            {
                device.RenderState.Lighting = true;
                Microsoft.DirectX.Direct3D.Material mt = new Microsoft.DirectX.Direct3D.Material();
                mt.AmbientColor = ColorValue.FromArgb(Geometry.Clr);
                mt.DiffuseColor = ColorValue.FromArgb(Geometry.Clr);
                device.RenderState.DiffuseMaterialSource = ColorSource.Material;
                device.Material = mt;
                device.RenderState.AmbientColor = Geometry.Clr;
            }

            device.VertexFormat = vFormat;
            device.SetStreamSource(0, vBuffer, 0);
            if (matIBuffers != null)
            {
                for (int mat = 0; mat < MaterialIndices.Length; mat++)
                {
                    Microsoft.DirectX.Direct3D.Material oMat = device.Material;
                    if (MaterialIndices[mat].Material.Texture == null)
                    {
                        Microsoft.DirectX.Direct3D.Material material = new Microsoft.DirectX.Direct3D.Material();
                        material.AmbientColor = ColorValue.FromColor(System.Drawing.Color.FromArgb(MaterialIndices[mat].Material.Ambient.A,
                                                                                    MaterialIndices[mat].Material.Ambient.R,
                                                                                    MaterialIndices[mat].Material.Ambient.G,
                                                                                    MaterialIndices[mat].Material.Ambient.B));
                        material.DiffuseColor = ColorValue.FromColor(System.Drawing.Color.FromArgb(MaterialIndices[mat].Material.Diffuse.A,
                                                                                    MaterialIndices[mat].Material.Diffuse.R,
                                                                                    MaterialIndices[mat].Material.Diffuse.G,
                                                                                    MaterialIndices[mat].Material.Diffuse.B));
                        device.Material = material;
                    }
                    else
                        device.SetTexture(0, MaterialIndices[mat].Material.Texture);

                    device.Indices = matIBuffers[mat];
                    device.DrawIndexedPrimitives(Geometry.PrimType, 0, 0, Geometry.Vertices.Length, 0, MaterialIndices[mat].PrimCount);

                    device.Material = oMat;
                }
            }
            else if (iBuffer != null)
            {
                device.Indices = iBuffer;
                device.DrawIndexedPrimitives(Geometry.PrimType, 0, 0, Geometry.Vertices.Length, 0, numPrimitives);
            }
            else
            {
                device.Indices = null;
                device.DrawPrimitives(Geometry.PrimType, 0, numPrimitives);
            }
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:53,代码来源:ABModel3D.cs


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