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


C# Device.SetStreamSource方法代码示例

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


在下文中一共展示了Device.SetStreamSource方法的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: Render

        public new void Render(Effect effect, Device device, bool setMaterial)
        {
            int vbID = 0, ibID = 0, matID = 0;
            device.VertexDeclaration = vertexDecl;

            device.SetStreamSourceFrequency(0, nInstances, StreamSource.IndexedData);

            //if (lightcubearr.Count <= 63 * 6 * 3 && lightcubearr.Count > 0)
            //    Renderer.Instance.effect.SetValue<float>("ambientLight", lightcubearr.ToArray());
            //Renderer.Instance.effect.CommitChanges();

            // Set InstanceBuffer
            device.SetStreamSource(1, vb.VB, InstanceBufferOffset, D3DX.GetDeclarationVertexSize(VertexPropInstance.Elements, 1));
            device.SetStreamSourceFrequency(1,1,StreamSource.InstanceData);

            // Render Bodyparts
            foreach (BodyPart part in Parts)
            {
                foreach (Model model in part.Models)
                {
                    MDLMesh mesh = model.GetLODMesh(0);
                    mesh.Render(effect, device, ref vbID, ref ibID, ref matID);
                }
            }
        }
开发者ID:maesse,项目名称:CubeHags,代码行数:25,代码来源:InstanceItem.cs

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

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

示例5: Render

 public new void Render(Effect effect, Device device, bool setMaterial)
 {
     // Render children
     foreach (RenderChildren children in items)
     {
         device.SetStreamSource(0, children.vb.VB, 0, D3DX.GetFVFVertexSize(children.vb.VF));
         device.VertexDeclaration = children.vb.VD;
         device.Indices = children.ib.IB;
         children.Render(effect, device, true);
     }
 }
开发者ID:maesse,项目名称:CubeHags,代码行数:11,代码来源:SourceProp.cs

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

示例7: Render

        public override void Render(Device device)
        {
            if (verticesV == null)
            {
                verticesV = new VertexBuffer(typeof(CustomVertex.PositionColoredTextured),    // Type of vertex
                   verticesB.Count,      // How many
                   device, // What device
                   0,      // No special usage
                   CustomVertex.PositionColoredTextured.Format,
                   Pool.Managed);

                texture = TextureLoader.FromFile(device, "../../textures/earth.bmp");
            }

            GraphicsStream gs = verticesV.Lock(0, 0, 0);// Lock the background vertex list
            int clr = System.Drawing.Color.Transparent.ToArgb();   // Don't you love all those color names?

            foreach (Vector2 v in verticesB)
            {
                float tu = 0.5f + v.X / 1.8f;
                float tv = 1 - (v.Y - (-0.8f)) / 1.8f;
                gs.Write(new CustomVertex.PositionColoredTextured(v.X, v.Y , 0, clr, tu, tv));
            }

            verticesV.Unlock();
            device.SetTexture(0, texture);
            device.SetStreamSource(0, verticesV, 0);
            device.VertexFormat = CustomVertex.PositionColoredTextured.Format;

            // Head, one triangle
            device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);

            // Body, two triangles
            device.DrawPrimitives(PrimitiveType.TriangleFan, 3, 2);

            device.SetTexture(0, null);
        }
开发者ID:QuirogaM,项目名称:StepDX,代码行数:37,代码来源:Flag.cs

示例8: draw

        public void draw(Vector3 cameraLocation, Vector3 cameraRotation, Device device)
        {
            Material initialMaterial = device.Material;

            if (particleList.Count > 0)
            {
                sortParticles(particleList, 0, particleList.Count - 1, cameraLocation);
            }

            device.RenderState.AlphaBlendEnable = true;
            device.RenderState.SourceBlend = Blend.SourceAlpha;
            device.RenderState.DestinationBlend = Blend.InvSourceAlpha;

            device.SetTexture(0, particleTexture);

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

                Material material = device.Material;
                Color diffuse = material.Diffuse;
                material.Diffuse = particle.modColor;
                material.Emissive = Color.White;
                device.Material = material;

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

                float particleRadius = particle.size / 2;

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

                buffer.Unlock();

                device.VertexFormat = CustomVertex.PositionTextured.Format;

                device.SetStreamSource(0, buffer, 0);
                device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            }

            device.RenderState.AlphaBlendEnable = false;
            device.Material = initialMaterial;
        }
开发者ID:newgrounds,项目名称:Clear-Skies,代码行数:48,代码来源:ParticleEmitter.cs

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

示例10: RenderPanadapterLine

        private static void RenderPanadapterLine(Device dev)        // yt7pwr
        {
            try
            {
                if (pan_fill)
                {
                    int j = 0;
                    int i = 0;

                    for (i = 0; i < panadapter_W * 2; i++)
                    {
                        Panadapter_verts_fill[i].Color = pan_fill_color.ToArgb();
                        Panadapter_verts_fill[i].Position.X = i / 2;
                        Panadapter_verts_fill[i].Position.Y = panadapterX_data[j];
                        Panadapter_verts_fill[i + 1].Color = pan_fill_color.ToArgb();
                        Panadapter_verts_fill[i + 1].Position.X = i / 2;
                        Panadapter_verts_fill[i + 1].Position.Y = panadapter_H;
                        i++;
                        j++;
                    }

                    PanLine_vb_fill.Lock(0, 0, LockFlags.None).WriteRange(Panadapter_verts_fill, 0, panadapter_W * 2);
                    PanLine_vb_fill.Unlock();

                    dev.SetStreamSource(0, PanLine_vb_fill, 0, 20);
                    dev.DrawPrimitives(PrimitiveType.LineList, 0, panadapter_W);
                }

                for (int i = 0; i < panadapter_W; i++)
                {
                    Panadapter_verts[i].Color = data_line_color.ToArgb();
                    Panadapter_verts[i].Position.X = i;
                    Panadapter_verts[i].Position.Y = panadapterX_data[i];
                }

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

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

示例11: DrawMeshes

            /// <summary>
            /// The draw meshes.
            /// </summary>
            /// <param name="device">The device.</param>
            /// <param name="pm">The pm.</param>
            /// <remarks></remarks>
            public static void DrawMeshes(ref Device device, ParsedModel pm)
            {
                for (int x = 0; x < pm.Display.Chunk.Count; x++)
                {
                    int rawindex = pm.Display.Chunk[x];
                    VertexBuffer vb = pm.Display.meshes[x].VertexBuffer;
                    IndexBuffer ib = pm.Display.meshes[x].IndexBuffer;
                    device.SetStreamSource(0, vb, 0);
                    device.VertexFormat = HaloVertex.FVF;
                    device.Indices = ib;
                    for (int xx = 0; xx < pm.RawDataMetaChunks[rawindex].SubMeshInfo.Length; xx++)
                    {
                        int tempshade = pm.RawDataMetaChunks[rawindex].SubMeshInfo[xx].ShaderNumber;

                        Renderer.SetAlphaBlending(pm.Shaders.Shader[tempshade].Alpha, ref device);
                        device.SetTexture(0, pm.Shaders.Shader[tempshade].MainTexture);
                        device.TextureState[0].ColorOperation = TextureOperation.Modulate;
                        device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
                        device.TextureState[0].ColorArgument2 = TextureArgument.Current;
                        device.RenderState.FillMode = FillMode.Solid;
                        pm.Display.meshes[x].DrawSubset(xx);
                    }
                }
            }
开发者ID:nolenfelten,项目名称:Blam_BSP,代码行数:30,代码来源:ParsedModel.cs

示例12: Draw

        /// <summary>
        /// The draw.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <remarks></remarks>
        public void Draw(ref Device device)
        {
            device.SetStreamSource(0, vb, 0);
            device.VertexFormat = CustomVertex.PositionColored.Format;
            device.Indices = ib;

            device.RenderState.AlphaBlendEnable = false;
            device.RenderState.AlphaTestEnable = false;

            device.SetTexture(0, null);

            PrimitiveType pt;

            pt = PrimitiveType.TriangleList;
            device.DrawIndexedPrimitives(pt, 0, 0, this.verticeCount, 0, this.faceCount / 3);
        }
开发者ID:nolenfelten,项目名称:Blam_BSP,代码行数:21,代码来源:coll.cs

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

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

示例15: DrawIndex

        /// <summary>
        /// The draw index.
        /// </summary>
        /// <param name="portal">The portal.</param>
        /// <param name="device">The device.</param>
        /// <remarks></remarks>
        public void DrawIndex(int portal, ref Device device)
        {
            int i = portal;

            device.SetStreamSource(0, vb[i], 0);
            device.VertexFormat = CustomVertex.PositionColored.Format;

            device.RenderState.AlphaBlendEnable = false;
            device.RenderState.AlphaTestEnable = false;

            device.Transform.World = Matrix.Identity;
            device.SetTexture(0, null);
            device.RenderState.FillMode = FillMode.Solid;
            device.Material = Red;

            // device.RenderState.AlphaBlendEnable = true;
            // device.RenderState.AlphaTestEnable = true;
            PrimitiveType pt;

            pt = PrimitiveType.TriangleFan;
            device.DrawPrimitives(pt, 0, this.verticeCount[i] - 2);

            device.RenderState.AlphaBlendEnable = false;
            device.RenderState.AlphaTestEnable = false;
            device.RenderState.FillMode = FillMode.WireFrame;
            device.Material = Black;

            pt = PrimitiveType.TriangleFan;
            device.DrawPrimitives(pt, 0, this.verticeCount[i] - 2);

            device.Material = Default;
            device.Transform.World = mat[i];
            spheres[i].DrawSubset(0);
        }
开发者ID:nolenfelten,项目名称:Blam_BSP,代码行数:40,代码来源:PortalInfo.cs


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