using System.Collections.Generic;
using System.Runtime.InteropServices;
using MoonWorks.Graphics;
using MoonWorks.Graphics.PackedVector;
namespace MoonWorks
{
///
/// Conversion utilities for interop.
///
public static class Conversions
{
private readonly static Dictionary Sizes = new Dictionary
{
{ VertexElementFormat.Byte4, (uint) Marshal.SizeOf() },
{ VertexElementFormat.Color, (uint) Marshal.SizeOf() },
{ VertexElementFormat.Float, (uint) Marshal.SizeOf() },
{ VertexElementFormat.HalfVector2, (uint) Marshal.SizeOf() },
{ VertexElementFormat.HalfVector4, (uint) Marshal.SizeOf() },
{ VertexElementFormat.NormalizedShort2, (uint) Marshal.SizeOf() },
{ VertexElementFormat.NormalizedShort4, (uint) Marshal.SizeOf() },
{ VertexElementFormat.Short2, (uint) Marshal.SizeOf() },
{ VertexElementFormat.Short4, (uint) Marshal.SizeOf() },
{ VertexElementFormat.UInt, (uint) Marshal.SizeOf() },
{ VertexElementFormat.Vector2, (uint) Marshal.SizeOf() },
{ VertexElementFormat.Vector3, (uint) Marshal.SizeOf() },
{ VertexElementFormat.Vector4, (uint) Marshal.SizeOf() }
};
public static byte BoolToByte(bool b)
{
return (byte) (b ? 1 : 0);
}
public static bool ByteToBool(byte b)
{
return b != 0;
}
public static uint VertexElementFormatSize(VertexElementFormat format)
{
return Sizes[format];
}
}
}