本文整理汇总了C#中IndexBuffer.BufferData方法的典型用法代码示例。如果您正苦于以下问题:C# IndexBuffer.BufferData方法的具体用法?C# IndexBuffer.BufferData怎么用?C# IndexBuffer.BufferData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IndexBuffer
的用法示例。
在下文中一共展示了IndexBuffer.BufferData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例2: InitializeGraphics
public void InitializeGraphics()
{
if(mat == null)
owner.Resources.Load("shaders\\Grid", out mat);
if (vb == null)
{
vb = new VertexBuffer<VertexPositionColor>(VertexPositionColor.Descriptor);
vb.Allocate(8);
}
if (ib == null)
{
ib = new IndexBuffer<uint>();
ib.Allocate(24);
ib[0] = 0;
ib[1] = 1;
ib[2] = 1;
ib[3] = 2;
ib[4] = 2;
ib[5] = 3;
ib[6] = 3;
ib[7] = 0;
ib[8] = 4;
ib[9] = 5;
ib[10] = 5;
ib[11] = 6;
ib[12] = 6;
ib[13] = 7;
ib[14] = 4;
ib[15] = 0;
ib[16] = 4;
ib[17] = 1;
ib[18] = 5;
ib[19] = 2;
ib[20] = 6;
ib[21] = 3;
ib[22] = 7;
ib.BufferData(VboUsage.GL_STATIC_DRAW);
}
if (points != null)
{
for (int i = 0; i < 8; i++)
{
vb[i] = new VertexPositionColor() { Position = points[i], Color = Colors.Yellow };
}
}
vb.BufferData(VboUsage.GL_DYNAMIC_DRAW);
}
示例3: 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();
}
示例4: Build
//.........这里部分代码省略.........
{
Position = pos[0],
Normal = Vector3.North,
TexCoord = new Vector2(0, 0)
};
vb[12] = new VertexPositionTexCoordNormal()
{
Position = pos[0],
Normal = Vector3.West,
TexCoord = new Vector2()
};
vb[13] = new VertexPositionTexCoordNormal()
{
Position = pos[3],
Normal = Vector3.West,
TexCoord = new Vector2()
};
vb[14] = new VertexPositionTexCoordNormal()
{
Position = pos[7],
Normal = Vector3.West,
TexCoord = new Vector2()
};
vb[15] = new VertexPositionTexCoordNormal()
{
Position = pos[4],
Normal = Vector3.West,
TexCoord = new Vector2()
};
vb[16] = new VertexPositionTexCoordNormal()
{
Position = pos[3],
Normal = Vector3.South,
TexCoord = new Vector2()
};
vb[17] = new VertexPositionTexCoordNormal()
{
Position = pos[2],
Normal = Vector3.South,
TexCoord = new Vector2()
};
vb[18] = new VertexPositionTexCoordNormal()
{
Position = pos[6],
Normal = Vector3.South,
TexCoord = new Vector2()
};
vb[19] = new VertexPositionTexCoordNormal()
{
Position = pos[7],
Normal = Vector3.South,
TexCoord = new Vector2()
};
vb[23] = new VertexPositionTexCoordNormal()
{
Position = pos[1],
Normal = Vector3.East,
TexCoord = new Vector2()
};
vb[22] = new VertexPositionTexCoordNormal()
{
Position = pos[2],
Normal = Vector3.East,
TexCoord = new Vector2()
};
vb[21] = new VertexPositionTexCoordNormal()
{
Position = pos[6],
Normal = Vector3.East,
TexCoord = new Vector2()
};
vb[20] = new VertexPositionTexCoordNormal()
{
Position = pos[5],
Normal = Vector3.East,
TexCoord = new Vector2()
};
int offset = 0;
ib.Allocate(36);
for (int i = 0; i < 6; i++)
{
offset = AddFaces(i * 4, offset, ib);
}
vb.BufferData(Glorg2.Graphics.OpenGL.VboUsage.GL_STATIC_DRAW);
ib.BufferData(Glorg2.Graphics.OpenGL.VboUsage.GL_STATIC_DRAW);
return ret;
}