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


C# IndexBuffer.FreeClientData方法代码示例

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


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

示例1: TerrainBlock

            internal TerrainBlock(int x_start, int y_start, int x_count, int y_count,  BoundingBox box, int subdivision, Terrain owner)
            {
                bounds = box;
                if (subdivision < owner.Subdivisions)
                {
                    x_count /= 2;
                    y_count /= 2;
                    Vector3 new_size = box.Size / 2;
                    new_size.y = box.Size.y;
                    float offset = box.Size.x / 4;

                    children = new List<TerrainBlock>();

                    children.Add(new TerrainBlock(x_start, y_start, x_count, y_count, new BoundingBox() { Size = new_size, Position = box.Position + new Vector3(-offset, 0, offset) }, subdivision + 1, owner));
                    children.Add(new TerrainBlock(x_start + x_count, y_start, x_count, y_count, new BoundingBox() { Size = new_size, Position = box.Position + new Vector3(offset, 0, offset) }, subdivision + 1, owner));
                    children.Add(new TerrainBlock(x_start + x_count, y_start + y_count, x_count, y_count, new BoundingBox() { Size = new_size, Position = box.Position + new Vector3(offset, 0, -offset) }, subdivision + 1, owner));
                    children.Add(new TerrainBlock(x_start, y_start + y_count, x_count, y_count, new BoundingBox() { Size = new_size, Position = box.Position + new Vector3(-offset, 0, -offset) }, subdivision + 1, owner));
                }
                else
                {
                    ib = new IndexBuffer<int>();
                    ib.Allocate(6 * (x_count) * (y_count));
                    int index = 0;
                    for (int i = 0; i < y_count; i++)
                    {
                        for (int j = 0; j < x_count; j++)
                        {
                            int i1 = (y_start + i) * owner.heightmap.Width + x_start + j;
                            int i2 = (y_start + i) * owner.heightmap.Width + x_start + j + 1;
                            int i3 = (y_start + i + 1) * owner.heightmap.Width + x_start + j + 1;
                            int i4 = (y_start + i + 1) * owner.heightmap.Width + x_start + j;

                            ib[index++] = i1;
                            ib[index++] = i3;
                            ib[index++] = i2;

                            ib[index++] = i1;
                            ib[index++] = i4;
                            ib[index++] = i3;
                        }
                    }
                    ib.BufferData(VboUsage.GL_STATIC_DRAW);
                    ib.FreeClientData();
                }
            }
开发者ID:r-bel,项目名称:glorg2,代码行数:45,代码来源:Terrain.cs

示例2: Build

        protected override void Build()
        {
            vb = new VertexBuffer<Vector3>(Vector3.Descriptor);

            vb.Allocate(8);
            ib = new IndexBuffer<ushort>();
            ib.Allocate(4 * 6);

            vb[0] = new Vector3(-0.5f, -0.5f, -0.5f);
            vb[1] = new Vector3(0.5f, -0.5f, -0.5f);
            vb[2] = new Vector3(0.5f, 0.5f, -0.5f);
            vb[3] = new Vector3(-0.5f, 0.5f, -0.5f);

            vb[4] = new Vector3(-0.5f, -0.5f, 0.5f);
            vb[5] = new Vector3(0.5f, -0.5f, 0.5f);
            vb[6] = new Vector3(0.5f, 0.5f, 0.5f);
            vb[7] = new Vector3(-0.5f, 0.5f, 0.5f);

            ib[0] = 0;
            ib[1] = 1;
            ib[2] = 2;
            ib[3] = 3;

            ib[4] = 4;
            ib[5] = 0;
            ib[6] = 3;
            ib[7] = 7;

            ib[8] = 5;
            ib[9] = 4;
            ib[10] = 7;
            ib[11] = 6;

            ib[12] = 1;
            ib[13] = 5;
            ib[14] = 6;
            ib[15] = 2;

            ib[16] = 6;
            ib[17] = 7;
            ib[18] = 3;
            ib[19] = 2;

            ib[20] = 0;
            ib[21] = 4;
            ib[22] = 5;
            ib[23] = 1;

            vb.BufferData(VboUsage.GL_STATIC_DRAW);
            ib.BufferData(VboUsage.GL_STATIC_DRAW);
            // Client data is no longer needed. Free it!
            vb.FreeClientData();
            ib.FreeClientData();
        }
开发者ID:r-bel,项目名称:glorg2,代码行数:54,代码来源:Box.cs


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