2012-08-09 09:45:04 +00:00
|
|
|
#region Using Statements
|
2011-11-07 19:21:23 +00:00
|
|
|
using System;
|
|
|
|
|
|
|
|
#endregion // Using Statements
|
|
|
|
|
2012-08-09 09:45:04 +00:00
|
|
|
// This file is part of the ANX.Framework created by the
|
|
|
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
|
|
|
// For details see: http://anxframework.codeplex.com/license
|
2011-11-07 19:21:23 +00:00
|
|
|
|
|
|
|
namespace ANX.Framework.Graphics
|
|
|
|
{
|
|
|
|
public class DynamicIndexBuffer : IndexBuffer, IDynamicGraphicsResource
|
|
|
|
{
|
|
|
|
public virtual event EventHandler<EventArgs> ContentLost;
|
|
|
|
|
2011-12-05 13:19:42 +00:00
|
|
|
#region Private Members
|
|
|
|
private bool isContentLost;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2011-11-07 19:21:23 +00:00
|
|
|
public DynamicIndexBuffer(GraphicsDevice graphicsDevice, IndexElementSize indexElementSize, int indexCount, BufferUsage usage)
|
|
|
|
: base(graphicsDevice, indexElementSize, indexCount, usage)
|
|
|
|
{
|
2011-12-05 13:19:42 +00:00
|
|
|
graphicsDevice.DeviceReset += new EventHandler<EventArgs>(graphicsDevice_DeviceReset);
|
2011-11-07 19:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public DynamicIndexBuffer(GraphicsDevice graphicsDevice, Type indexType, int indexCount, BufferUsage usage)
|
|
|
|
: base(graphicsDevice, indexType, indexCount, usage)
|
|
|
|
{
|
2011-12-05 13:19:42 +00:00
|
|
|
graphicsDevice.DeviceReset += new EventHandler<EventArgs>(graphicsDevice_DeviceReset);
|
|
|
|
}
|
|
|
|
|
|
|
|
~DynamicIndexBuffer()
|
|
|
|
{
|
|
|
|
base.GraphicsDevice.DeviceReset -= graphicsDevice_DeviceReset;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void graphicsDevice_DeviceReset(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
SetContentLost(true);
|
2011-11-07 19:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, SetDataOptions options) where T : struct
|
|
|
|
{
|
2011-12-05 13:19:42 +00:00
|
|
|
//TODO: SetDataOptions not used
|
|
|
|
base.SetData<T>(offsetInBytes, data, startIndex, elementCount);
|
2011-11-07 19:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetData<T>(T[] data, int startIndex, int elementCount, SetDataOptions options) where T : struct
|
|
|
|
{
|
2011-12-05 13:19:42 +00:00
|
|
|
//TODO: SetDataOptions not used
|
|
|
|
base.SetData<T>(data, startIndex, elementCount);
|
2011-11-07 19:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsContentLost
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2011-12-05 13:19:42 +00:00
|
|
|
return this.isContentLost;
|
2011-11-07 19:21:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetContentLost(bool isContentLost)
|
|
|
|
{
|
2011-12-05 13:19:42 +00:00
|
|
|
this.isContentLost = isContentLost;
|
|
|
|
if (isContentLost)
|
|
|
|
{
|
|
|
|
raise_ContentLost(this, EventArgs.Empty);
|
|
|
|
}
|
2011-11-07 19:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void raise_ContentLost(object sender, EventArgs args)
|
|
|
|
{
|
|
|
|
if (ContentLost != null)
|
|
|
|
{
|
|
|
|
ContentLost(sender, args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|