本文整理汇总了C#中IndexBuffer.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# IndexBuffer.Commit方法的具体用法?C# IndexBuffer.Commit怎么用?C# IndexBuffer.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IndexBuffer
的用法示例。
在下文中一共展示了IndexBuffer.Commit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Sprite
public Sprite (Stream stream, TextureSettings settings, Vector4 rect, bool relativeRect, Vector4 color, bool flipV = true) {
var tex = new Texture(stream, settings);
_material = new SpriteMaterial(new SpriteShader(), tex);
if (rect == Vector4.Zero)
rect = new Vector4(0, 0, tex.Size.Width, tex.Size.Height);
else if (relativeRect) {
rect.X *= tex.Size.Width;
rect.Y *= tex.Size.Height;
rect.Z *= tex.Size.Width;
rect.W *= tex.Size.Height;
}
_size = new Vector2(rect.Z - rect.X, rect.W - rect.Y);
_vbuffer = new VertexBuffer(VertexFormat.PositionColorUV);
_vbuffer.Data = new [] {
rect.X, rect.Y, 0f, color.X, color.Y, color.Z, color.W, 0f, flipV ? 1f : 0f,
rect.Z, rect.Y, 0f, color.X, color.Y, color.Z, color.W, 1f, flipV ? 1f : 0f,
rect.Z, rect.W, 0f, color.X, color.Y, color.Z, color.W, 1f, flipV ? 0f : 1f,
rect.X, rect.W, 0f, color.X, color.Y, color.Z, color.W, 0f, flipV ? 0f : 1f
};
_vbuffer.Commit ();
_ibuffer = new IndexBuffer();
_ibuffer.Data = new [] { 0, 1, 2, 2, 3, 0 };
_ibuffer.Commit ();
_ioffset = 0;
_icount = 6;
_ownResources = true;
}
示例2: Quad
public Quad (Material material, Vector4 rect, Vector4 color, bool flipV = false) {
_material = material;
_color = color;
_vbuffer = new VertexBuffer (VertexFormat.PositionColorUV);
_ibuffer = new IndexBuffer ();
if (rect == Vector4.Zero)
rect = new Vector4(-0.5f, -0.5f, 0.5f, 0.5f);
_vbuffer.Data = new [] {
rect.X, rect.Y, 0f, _color.X, _color.Y, _color.Z, _color.W, 0f, flipV ? 1f : 0f,
rect.Z, rect.Y, 0f, _color.X, _color.Y, _color.Z, _color.W, 1f, flipV ? 1f : 0f,
rect.Z, rect.W, 0f, _color.X, _color.Y, _color.Z, _color.W, 1f, flipV ? 0f : 1f,
rect.X, rect.W, 0f, _color.X, _color.Y, _color.Z, _color.W, 0f, flipV ? 0f : 1f
};
_vbuffer.Commit ();
_ibuffer.Data = new [] { 0, 1, 2, 2, 3, 0 };
_ibuffer.Commit ();
}