Allow SheetBuilder to generate 1/2/4 channel sheets.

This makes the SpriteFont RBGA sprite hack explicit,
and adds a DualIndexed option to be used by the voxel
renderer.
This commit is contained in:
Paul Chote
2013-05-06 20:48:09 +12:00
parent 28d4df355d
commit 4ebe547a05
4 changed files with 34 additions and 24 deletions

View File

@@ -32,12 +32,13 @@ namespace OpenRA.Graphics
static readonly int[] channelMasks = { 2, 1, 0, 3 }; // yes, our channel order is nuts.
public static void FastCopyIntoChannel(Sprite dest, byte[] src)
public static void FastCopyIntoChannel(Sprite dest, byte[] src) { FastCopyIntoChannel(dest, 0, src); }
public static void FastCopyIntoChannel(Sprite dest, int channelOffset, byte[] src)
{
var data = dest.sheet.Data;
var srcStride = dest.bounds.Width;
var destStride = dest.sheet.Size.Width * 4;
var destOffset = destStride * dest.bounds.Top + dest.bounds.Left * 4 + channelMasks[(int)dest.channel];
var destOffset = destStride * dest.bounds.Top + dest.bounds.Left * 4 + channelMasks[(int)dest.channel + channelOffset];
var destSkip = destStride - 4 * srcStride;
var height = dest.bounds.Height;