本文整理汇总了C#中VertexBuffer.FreeClientData方法的典型用法代码示例。如果您正苦于以下问题:C# VertexBuffer.FreeClientData方法的具体用法?C# VertexBuffer.FreeClientData怎么用?C# VertexBuffer.FreeClientData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexBuffer
的用法示例。
在下文中一共展示了VertexBuffer.FreeClientData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeGraphics
public void InitializeGraphics()
{
if (vb != null)
vb.Dispose();
if (mat == null)
{
Glorg2.Resource.MaterialImporter imp = new Glorg2.Resource.MaterialImporter();
using(var stream = System.IO.File.OpenRead(".\\shaders\\Grid.mxl"))
{
mat = imp.Import<StdMaterial>(stream, "grid", null);
}
}
vb = new VertexBuffer<WireframeVertex>(WireframeVertex.Description);
vb.Allocate(Columns * 2 + Rows * 2 + 4);
float tot_w = Size * Columns;
float tot_h = Size * Rows;
float fi = -tot_w / 2;
int i;
for (i = 0; i <= Columns; i++, fi += Size)
{
Vector4 color;
if(Major == 0 || (i % Major) == 0)
color = MajorColor;
else
color = MinorColor;
vb[i * 2] = new WireframeVertex() { Position = new Vector3(fi, 0, -tot_h / 2), Color = color };
vb[i * 2 + 1] = new WireframeVertex() { Position = new Vector3(fi, 0, tot_h / 2), Color = color };
}
int start = i * 2;
fi = -tot_h / 2;
for (int j = 0; j <= Rows; j++, fi += Size)
{
Vector4 color;
if (Major == 0 || (j % Major) == 0)
color = MajorColor;
else
color = MinorColor;
vb[start + j * 2] = new WireframeVertex() { Position = new Vector3(-tot_h / 2, 0, fi), Color = color };
vb[start + j * 2 + 1] = new WireframeVertex() { Position = new Vector3( tot_h / 2, 0, fi), Color = color };
}
vb.BufferData(VboUsage.GL_STATIC_DRAW);
vb.FreeClientData();
}
示例2: InitializeGraphics
public virtual void InitializeGraphics()
{
if (heightmap == null && string.IsNullOrEmpty(Heightmap))
return;
if (heightmap == null)
owner.Resources.Load(Heightmap, out heightmap);
//if (heightmap.Width != heightmap.Height)
//throw new NotSupportedException("Must be rectangular heightmap");
int num_vertices = (heightmap.Width) * (heightmap.Height);
if (vb != null)
DoDispose();
vb = new VertexBuffer<VertexPositionTexCoordNormal>(VertexPositionTexCoordNormal.Descriptor);
vb.Allocate(num_vertices);
if (mat_name != null)
owner.Resources.Load(mat_name, out mat);
size = CellSize * heightmap.Width;
float s2 = size / 2;
int vi = 0;
float xx = 0;
float yy = -s2;
Vector3[,] norms = new Vector3[heightmap.Height, heightmap.Width];
for (int i = 0; i < heightmap.Height; i++)
{
for (int j = 0; j < heightmap.Width; j++)
{
Vector3 n = new Vector3();
n.x = (heightmap[i - 1, j] - heightmap[i + 1, j]) * Height;
n.y = (heightmap[i, j - 1] - heightmap[i, j + 1]) * Height;
n.z = 2.0f / (heightmap.Width + 1) / CellSize + 2.0f / (heightmap.Height + 1) / CellSize;
norms[i, j] = n.Normalize();
}
}
for (int i = 0; i < heightmap.Height; i++)
{
xx = -s2;
for (int j = 0; j < heightmap.Width; j++, vi++)
{
vb[vi] = new VertexPositionTexCoordNormal()
{
Position = new Vector3(xx, heightmap[i, j] * Height, yy),
Normal = norms[i, j]
};
xx += CellSize;
}
yy += CellSize;
}
float offset = s2 / 2;
int x_count = heightmap.Width / 2;
int y_count = heightmap.Height / 2;
var new_size = new Vector3(s2, size / 8, s2);
blocks = new TerrainBlock[4];
blocks[0] = new TerrainBlock(0, 0, x_count, y_count, new BoundingBox()
{
Size = new_size,
Position = new Vector3(-offset, 0, offset)
}, 0, this);
blocks[1] = new TerrainBlock(x_count-1, 0, x_count, y_count, new BoundingBox()
{
Size = new_size,
Position = new Vector3(offset, 0, offset)
}, 0, this);
blocks[2] = new TerrainBlock(x_count-1, y_count-1, x_count, y_count, new BoundingBox()
{
Size = new_size,
Position = new Vector3(offset, 0, -offset)
}, 0, this);
blocks[3] = new TerrainBlock(0, y_count-1, x_count, y_count, new BoundingBox()
{
Size = new_size,
Position = new Vector3(-offset, 0, -offset)
}, 0, this);
vb.BufferData(VboUsage.GL_STATIC_DRAW);
vb.FreeClientData();
init_finished = true;
}
示例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();
}