110,534
社区成员
发帖
与我相关
我的任务
分享
static private float VX0 = -1.0f;
static private float VY0 = -1.0f;
static private float VZ0 = 0.0f;
static private float VX1 = 1.0f;
static private float VY1 = -1.0f;
static private float VZ1 = 0.0f;
static private float VX2 = 0.0f;
static private float VY2 = 2.0f;
static private float VZ2 = 0.0f;
VertexBuffer vertexBuffer = null;
public void OnCreateVertexBuffer(object sender, EventArgs e)
{
VertexBuffer vb = (VertexBuffer)sender;
CustomVertex.PositionColored[] verts = (CustomVertex.PositionColored[])vb.Lock(0, 0);
verts[0].X = VX0; verts[0].Y = VY0; verts[0].Z = VZ0; verts[0].Color = System.Drawing.Color.DarkGoldenrod.ToArgb();
verts[1].X = VX1; verts[1].Y = VY1; verts[1].Z = VZ1; verts[1].Color = System.Drawing.Color.MediumOrchid.ToArgb();
verts[2].X = VX2; verts[2].Y = VY2; verts[2].Z = VZ2; verts[2].Color = System.Drawing.Color.Cornsilk.ToArgb();
vb.Unlock();
}
private void Render()
{
pictureBox.Click += new EventHandler(pictureBox_Click);
}
void pictureBox_Click(object sender, EventArgs e)
{
VX0 -= 1.0f; VY0 -= 1.0f;
VX1 += 1.0f; VY1 -= 1.0f;
VY2 += 1.0f;
this.OnCreateVertexBuffer(vertexBuffer, null);
}
虽然看不到你的完整代码,但估计是Render()这个方法反复执行,Click事件被重复绑定的结果