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


C# VertexBuffer.Write方法代码示例

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


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

示例1: VertexBuffer_WriteTest

        public void VertexBuffer_WriteTest()
        {
            var vb = new VertexBuffer<TransformedColoredVertex>(Device);

            vb.Write(new[] {
                new TransformedColoredVertex() { Position = Vector4.Zero },
                new TransformedColoredVertex() { Position = new Vector4(0, 1, 2, 1) }
            });
            Assert.IsNotNull(vb.RawBuffer);
            Assert.AreEqual(2, vb.Count);

            vb.Write(new[] { new TransformedColoredVertex() { Position = Vector4.Zero } });
            Assert.AreEqual(3, vb.Count);
        }
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:14,代码来源:VertexBufferTest.cs

示例2: Attach

        public void Attach(SceneNode parent)
        {
            localParent = parent;
            localRoot = parent = new SceneNode(parent);
            var physicsComponent = Record.GetComponent<PhysicsComponent>();
            if (physicsComponent != null) new DebugDrawNode(parent, physicsComponent.Body);

            var transformComponent = Record.GetComponent<TransformComponent>();
            if (meshData == null) return;
            parent = new TransformNode(parent, transformComponent ?? new TransformComponent());
            var animationComponent = Record.GetComponent(default(AnimationComponent), true);
            if (animationComponent != null) parent = new AnimationNode(parent, animationComponent);
            var tri = meshData.Submeshes[0].Triangles;
            var vert = meshData.Submeshes[0].Vertices;
            var vbo = new VertexBuffer(vert.Length * SkinnedVertex.Size, BufferTarget.ArrayBuffer,
                                       BufferUsageHint.StaticDraw);
            var ibo = new VertexBuffer(tri.Length * Vector3i.Size, BufferTarget.ElementArrayBuffer,
                                       BufferUsageHint.StaticDraw);
            vbo.Write(0, vert);
            ibo.Write(0, tri);
            var vboNode = new VBONode(parent, vbo, ibo);
            foreach (var matGroup in from g in meshData.Submeshes group g by g.Material)
            {
                foreach (var geometry in matGroup)
                {
                    var mat = matGroup.Key;
                    new SubmeshNode(new MaterialNode(vboNode, mat), geometry);
                }
            }
        }
开发者ID:jyunfan2015,项目名称:Calcifer,代码行数:30,代码来源:RenderComponent.cs

示例3: VertexBuffer_OverWrite_Test

        public void VertexBuffer_OverWrite_Test()
        {
            var vb = new VertexBuffer<TransformedColoredVertex>(Device);
            vb.Write(new[] {
                new TransformedColoredVertex() { Position = Vector4.Zero },
                new TransformedColoredVertex() { Position = new Vector4(0, 1, 2, 1) }
            });

            vb.OverWrite(new[] { new TransformedColoredVertex() { Position = Vector4.Zero } });
            Assert.AreEqual(1, vb.Count);
        }
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:11,代码来源:VertexBufferTest.cs

示例4: Device

        public Device(IntPtr handle, int width, int height)
        {
            if (handle == IntPtr.Zero)
                throw new ArgumentException("Value must be a valid window handle", "handle");

            if (GetSystemMetrics(SM_REMOTESESSION) != 0)
                throw new Exception("We can't run at all under terminal services");

            int renderingTier = (RenderCapability.Tier >> 16);
            if (renderingTier < 2)
                throw new Exception("Render capability check failed, low tier=" + renderingTier);

            // Create D3D
            try
            {
                this.direct3dEx = new Direct3DEx();
                UseDeviceEx = true;
            }
            catch
            {
                this.direct3d = new Direct3D();
                UseDeviceEx = false;
            }

            // Create device
            Result result;
            if (!Direct3D.CheckDeviceType(0, DeviceType.Hardware, this.adapterFormat, this.backbufferFormat, true, out result))
                throw new Exception("CheckDeviceType failed: " + result.ToString());

            if (!Direct3D.CheckDepthStencilMatch(0, DeviceType.Hardware, this.adapterFormat, this.backbufferFormat, this.depthStencilFormat, out result))
                throw new Exception("CheckDepthStencilMatch failed: " + result.ToString());

            Capabilities deviceCaps = Direct3D.GetDeviceCaps(0, DeviceType.Hardware);
            if ((deviceCaps.DeviceCaps & DeviceCaps.HWTransformAndLight) != 0)
                this.createFlags |= CreateFlags.HardwareVertexProcessing;
            else
                this.createFlags |= CreateFlags.SoftwareVertexProcessing;

            PresentParams = new PresentParameters()
            {
                BackBufferFormat = this.backbufferFormat,
                BackBufferCount = 1,
                BackBufferWidth = width,
                BackBufferHeight = height,
                Multisample = MultisampleType.None,
                SwapEffect = SwapEffect.Discard,
                EnableAutoDepthStencil = true,
                AutoDepthStencilFormat = this.depthStencilFormat,
                PresentFlags = PresentFlags.DiscardDepthStencil,
                PresentationInterval = PresentInterval.Immediate,
                Windowed = true,
                DeviceWindowHandle = handle,
            };

            if (UseDeviceEx)
            {
                this.deviceEx = new DeviceEx(this.direct3dEx,
                        0,
                        DeviceType.Hardware,
                        handle,
                        this.createFlags,
                        PresentParams);
            }
            else
            {
                this.device = new SlimDX.Direct3D9.Device(this.direct3d,
                    0,
                    DeviceType.Hardware,
                    handle,
                    this.createFlags,
                    PresentParams);
            }

            // Create vertex declarations
            TransformedColoredVertexDecl = new TransformedColoredVertexDecl(this);
            MeshVertexDecl = new MeshVertexDecl(this);
            TextureVertexDecl = new TexturedVertexDecl(this);
            ScreenVertexDecl = new ScreenVertexDecl(this);

            ScreenVertexBuffer = new VertexBuffer<ScreenVertex>(this);
            var vertices = new ScreenVertex[]
            {
                new ScreenVertex() { Position = new Vector3(-1.0f, -1.0f, 0.5f), UV = new Vector2(0.0f, 1.0f) },
                new ScreenVertex() { Position = new Vector3(-1.0f, 1.0f, 0.5f), UV = new Vector2(0.0f, 0.0f) },
                new ScreenVertex() { Position = new Vector3(1.0f, -1.0f, 0.5f), UV = new Vector2(1.0f, 1.0f) },
                new ScreenVertex() { Position = new Vector3(1.0f, 1.0f, 0.5f), UV = new Vector2(1.0f, 0.0f) },
            };
            ScreenVertexBuffer.Write(vertices);
        }
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:89,代码来源:Device.cs


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