anx.framework/ANX.Framework/Graphics/DynamicVertexBuffer.cs
SND\AstrorEnales_cp 5505f7dcbf - Added PlatformSystem Plugins layer
- Started Windows, Metro and Linux Platform-Plugins
- Moved the RecordingSample to the Samples folder
- Started two samples for using the graphics device in a WinForms and Wpf Editor
- Refactorings in the AddIn-System
- Moved the Window initialization-code to the Platform modules
- Changed the License text in all code files which is now way smaller
- Started ProjectConverter tool which converts all the projects and solution to the target configuration
- Changed the SupportedPlatform names in the Resource files
- Changed the WIN8 define to WINDOWSMETRO which is actually meant
- Removed NLog and started our own Logger class
- Many more stuff...
2012-08-09 09:45:04 +00:00

82 lines
2.6 KiB
C#

#region Using Statements
using System;
#endregion // Using Statements
// 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
namespace ANX.Framework.Graphics
{
public class DynamicVertexBuffer : VertexBuffer, IDynamicGraphicsResource
{
public virtual event EventHandler<EventArgs> ContentLost;
#region Private Members
private bool isContentLost;
#endregion
public DynamicVertexBuffer(GraphicsDevice graphicsDevice, Type vertexType, int vertexCount, BufferUsage usage)
: base(graphicsDevice, vertexType, vertexCount, usage)
{
graphicsDevice.DeviceReset += new EventHandler<EventArgs>(graphicsDevice_DeviceReset);
}
public DynamicVertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
: base(graphicsDevice, vertexDeclaration, vertexCount, usage)
{
graphicsDevice.DeviceReset += new EventHandler<EventArgs>(graphicsDevice_DeviceReset);
}
~DynamicVertexBuffer()
{
base.GraphicsDevice.DeviceReset -= graphicsDevice_DeviceReset;
}
private void graphicsDevice_DeviceReset(object sender, EventArgs e)
{
SetContentLost(true);
}
public void SetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride, SetDataOptions options) where T : struct
{
//TODO: SetDataOptions not used
base.SetData<T>(offsetInBytes, data, startIndex, elementCount, vertexStride);
}
public void SetData<T>(T[] data, int startIndex, int elementCount, SetDataOptions options) where T : struct
{
//TODO: SetDataOptions not used
base.SetData<T>(data, startIndex, elementCount);
}
public bool IsContentLost
{
get
{
return this.isContentLost;
}
}
public void SetContentLost(bool isContentLost)
{
this.isContentLost = isContentLost;
if (isContentLost)
{
raise_ContentLost(this, EventArgs.Empty);
}
}
protected void raise_ContentLost(object sender, EventArgs args)
{
if (ContentLost != null)
{
ContentLost(sender, args);
}
}
}
}