Merge pull request #3407 from pchote/voxel-fbo

Voxel refactoring
This commit is contained in:
Chris Forbes
2013-06-19 14:57:17 -07:00
66 changed files with 1157 additions and 553 deletions

View File

@@ -137,6 +137,11 @@ namespace OpenRA
return v;
}
public static bool IsPowerOf2(int v)
{
return (v & (v - 1)) == 0;
}
public static Size NextPowerOf2(this Size s) { return new Size(NextPowerOf2(s.Width), NextPowerOf2(s.Height)); }
public static string JoinWith<T>(this IEnumerable<T> ts, string j)

View File

@@ -19,7 +19,7 @@ namespace OpenRA.FileFormats
{
public readonly uint FrameCount;
public readonly uint LimbCount;
float[] Transforms;
public readonly float[] Transforms;
public HvaReader(Stream s)
{
@@ -48,19 +48,6 @@ namespace OpenRA.FileFormats
}
}
public float[] TransformationMatrix(uint limb, uint frame)
{
if (frame >= FrameCount)
throw new ArgumentOutOfRangeException("frame", "Only {0} frames exist.".F(FrameCount));
if (limb >= LimbCount)
throw new ArgumentOutOfRangeException("limb", "Only {1} limbs exist.".F(LimbCount));
var t = new float[16];
Array.Copy(Transforms, 16*(LimbCount*frame + limb), t, 0, 16);
return t;
}
public static HvaReader Load(string filename)
{
using (var s = File.OpenRead(filename))

View File

@@ -37,6 +37,7 @@ namespace OpenRA.FileFormats.Graphics
IVertexBuffer<Vertex> CreateVertexBuffer( int length );
ITexture CreateTexture( Bitmap bitmap );
ITexture CreateTexture();
IFrameBuffer CreateFrameBuffer(Size s);
IShader CreateShader( string name );
Size WindowSize { get; }
@@ -54,8 +55,8 @@ namespace OpenRA.FileFormats.Graphics
void EnableDepthBuffer();
void DisableDepthBuffer();
void EnableStencilBuffer();
void DisableStencilBuffer();
void EnableAlphaBlending();
void DisableAlphaBlending();
}
public interface IVertexBuffer<T>
@@ -79,6 +80,15 @@ namespace OpenRA.FileFormats.Graphics
void SetData(Bitmap bitmap);
void SetData(uint[,] colors);
void SetData(byte[] colors, int width, int height);
byte[] GetData();
Size Size { get; }
}
public interface IFrameBuffer
{
void Bind();
void Unbind();
ITexture Texture { get; }
}
public enum PrimitiveType