tôi có một lớp vẽ và xoay khối lập phương. mỗi khi tôi xoay khối lập phương tôi tải lại bộ đệm với các giá trị mới cho khối lập phương.Ngoại lệ OutOfMemory khi vẽ hình khối
public void LoadBuffer(GraphicsDevice graphicsDevice)
{
buffer = new VertexBuffer(graphicsDevice, VertexPositionNormalTexture.VertexDeclaration, triangles * 3, BufferUsage.None);
buffer.SetData<VertexPositionNormalTexture>(verts);
graphicsDevice.SetVertexBuffer(buffer);
}
public void Draw(GraphicsDevice graphicsDevice)
{
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, triangles);
}
sau đó gọi phương thức Cube.Draw trong Game.Draw
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(ClearOptions.DepthBuffer | ClearOptions.Target, Color.White, 1f, 0);
basicEffect.Parameters["WorldViewProj"].SetValue(world * view * projection);
EffectPass pass = basicEffect.CurrentTechnique.Passes[0];
if (pass != null)
{
pass.Apply();
cube1.LoadBuffer(GraphicsDevice);
cube1.Draw(GraphicsDevice);
cube2.LoadBuffer(GraphicsDevice);
cube2.Draw(GraphicsDevice);
cube3.LoadBuffer(GraphicsDevice);
cube3.Draw(GraphicsDevice);
}
base.Draw(gameTime);
}
sau một vài phút hoặc lâu hơn tôi nhận được một ngoại lệ OutOfMemory trên dòng:
buffer.SetData<VertexPositionNormalTexture>(verts);
có thể ai đó hãy giải thích tại sao điều này xảy ra và những gì tôi có thể làm để giải quyết nó.
Hi , @harryovers, bạn đã tìm thấy một công việc xung quanh, với loại "BUG", tôi cảm thấy quá buồn khi chọn XNA. –
@DuSijun tôi đã làm điều này để làm việc nhưng nó là 2.5 năm trước vì vậy tôi thực sự không nhớ nhiều chi tiết về nó xin lỗi. – harryovers