Cleanup in many graphics classes, mostly regions, usings and class order, added attributes and implemented some smaller methods

This commit is contained in:
SND\AstrorEnales_cp 2012-09-04 08:31:17 +00:00
parent 28f3010330
commit 7031e5b44e
63 changed files with 1606 additions and 1933 deletions

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,5 @@
#region Using Statements
using System; using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,5 @@
#region Using Statements
using System; using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,5 @@
#region Using Statements
using System; using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,7 +1,6 @@
#region Using Statements
using System; using System;
using System.Globalization;
#endregion // Using Statements using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,41 +8,21 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("AstrorEnales")]
public class DisplayMode public class DisplayMode
{ {
public float AspectRatio public float AspectRatio { get; set; }
{ public SurfaceFormat Format { get; set; }
get; public int Width { get; set; }
set; public int Height { get; set; }
} public Rectangle TitleSafeArea { get; set; }
public SurfaceFormat Format
{
get;
set;
}
public int Height
{
get;
set;
}
public Rectangle TitleSafeArea
{
get;
set;
}
public int Width
{
get;
set;
}
public override string ToString() public override string ToString()
{ {
throw new NotImplementedException(); return String.Format(CultureInfo.CurrentCulture, "{{Width:{0} Height:{1} Format:{2} AspectRatio:{3}}}",
Width, Height, Format, AspectRatio);
} }
} }
} }

View File

@ -1,8 +1,5 @@
#region Using Statements
using System; using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
@ -11,47 +8,6 @@ namespace ANX.Framework.Graphics
{ {
public sealed class EffectAnnotation public sealed class EffectAnnotation
{ {
public bool GetValueBoolean()
{
throw new NotImplementedException();
}
public int GetValueInt32()
{
throw new NotImplementedException();
}
public Matrix GetValueMatrix()
{
throw new NotImplementedException();
}
public float GetValueSingle()
{
throw new NotImplementedException();
}
public string GetValueString()
{
throw new NotImplementedException();
}
public Vector2 GetValueVector2()
{
throw new NotImplementedException();
}
public Vector3 GetValueVector3()
{
throw new NotImplementedException();
}
public Vector4 GetValueVector4()
{
throw new NotImplementedException();
}
public int ColumnCount public int ColumnCount
{ {
get get
@ -100,5 +56,44 @@ namespace ANX.Framework.Graphics
} }
} }
public bool GetValueBoolean()
{
throw new NotImplementedException();
}
public int GetValueInt32()
{
throw new NotImplementedException();
}
public Matrix GetValueMatrix()
{
throw new NotImplementedException();
}
public float GetValueSingle()
{
throw new NotImplementedException();
}
public string GetValueString()
{
throw new NotImplementedException();
}
public Vector2 GetValueVector2()
{
throw new NotImplementedException();
}
public Vector3 GetValueVector3()
{
throw new NotImplementedException();
}
public Vector4 GetValueVector4()
{
throw new NotImplementedException();
}
} }
} }

View File

@ -1,13 +1,3 @@
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ANX.Framework.NonXNA;
using ANX.Framework.Graphics;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,12 +1,6 @@
#region Using Statements
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ANX.Framework.NonXNA;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ANX.Framework.NonXNA;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -16,9 +10,9 @@ namespace ANX.Framework.Graphics
{ {
public sealed class EffectParameter public sealed class EffectParameter
{ {
#region Public
private INativeEffectParameter nativeParameter; private INativeEffectParameter nativeParameter;
#region Public
public INativeEffectParameter NativeParameter public INativeEffectParameter NativeParameter
{ {
get get
@ -30,6 +24,7 @@ namespace ANX.Framework.Graphics
this.nativeParameter = value; this.nativeParameter = value;
} }
} }
public EffectAnnotationCollection Annotations public EffectAnnotationCollection Annotations
{ {
get get

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,5 @@
#region Using Statements
using System; using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
@ -15,21 +12,6 @@ namespace ANX.Framework.Graphics
private EffectAnnotationCollection annotations; private EffectAnnotationCollection annotations;
private Effect parentEffect; private Effect parentEffect;
internal EffectPass(Effect parentEffect)
{
if (parentEffect == null)
{
throw new ArgumentNullException("parentEffect");
}
this.parentEffect = parentEffect;
}
public void Apply()
{
this.parentEffect.NativeEffect.Apply(this.parentEffect.GraphicsDevice);
}
public string Name public string Name
{ {
get get
@ -45,5 +27,18 @@ namespace ANX.Framework.Graphics
return this.annotations; return this.annotations;
} }
} }
internal EffectPass(Effect parentEffect)
{
if (parentEffect == null)
throw new ArgumentNullException("parentEffect");
this.parentEffect = parentEffect;
}
public void Apply()
{
this.parentEffect.NativeEffect.Apply(this.parentEffect.GraphicsDevice);
}
} }
} }

View File

@ -1,12 +1,6 @@
#region Using Statements
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
@ -19,13 +13,6 @@ namespace ANX.Framework.Graphics
private INativeEffectTechnique nativeTechnique; private INativeEffectTechnique nativeTechnique;
private EffectPassCollection effectPassCollection; private EffectPassCollection effectPassCollection;
internal EffectTechnique(Effect parentEffect, INativeEffectTechnique nativeTechnique)
{
this.parentEffect = parentEffect;
this.nativeTechnique = nativeTechnique;
this.effectPassCollection = new EffectPassCollection(parentEffect, parentEffect.NativeEffect, nativeTechnique);
}
internal INativeEffectTechnique NativeTechnique internal INativeEffectTechnique NativeTechnique
{ {
get get
@ -57,5 +44,12 @@ namespace ANX.Framework.Graphics
return this.effectPassCollection; return this.effectPassCollection;
} }
} }
internal EffectTechnique(Effect parentEffect, INativeEffectTechnique nativeTechnique)
{
this.parentEffect = parentEffect;
this.nativeTechnique = nativeTechnique;
this.effectPassCollection = new EffectPassCollection(parentEffect, parentEffect.NativeEffect, nativeTechnique);
}
} }
} }

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,13 +1,9 @@
#region Using Statements
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
@ -16,45 +12,28 @@ namespace ANX.Framework.Graphics
{ {
public sealed class GraphicsAdapter public sealed class GraphicsAdapter
{ {
private static List<GraphicsAdapter> adapters;
private DisplayModeCollection supportedDisplayModes;
static GraphicsAdapter()
{
adapters = new List<GraphicsAdapter>();
IRenderSystemCreator renderSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
adapters.AddRange(renderSystemCreator.GetAdapterList());
}
public static ReadOnlyCollection<GraphicsAdapter> Adapters public static ReadOnlyCollection<GraphicsAdapter> Adapters
{ {
get get;
{ private set;
return new ReadOnlyCollection<GraphicsAdapter>(adapters);
}
} }
public static GraphicsAdapter DefaultAdapter public static GraphicsAdapter DefaultAdapter
{ {
get get
{ {
GraphicsAdapter defaultAdapter = adapters.Where(a => a.IsDefaultAdapter).First<GraphicsAdapter>(); return Adapters.Where(a => a.IsDefaultAdapter).First<GraphicsAdapter>();
return defaultAdapter;
} }
} }
public static bool UseNullDevice public static bool UseNullDevice { get; set; }
{ public static bool UseReferenceDevice { get; set; }
get; public int DeviceId { get; set; }
set; public string DeviceName { get; set; }
} public bool IsDefaultAdapter { get; set; }
public int Revision { get; set; }
public static bool UseReferenceDevice public int SubSystemId { get; set; }
{ public int VendorId { get; set; }
get;
set;
}
public DisplayMode CurrentDisplayMode public DisplayMode CurrentDisplayMode
{ {
@ -72,24 +51,6 @@ namespace ANX.Framework.Graphics
} }
} }
public int DeviceId
{
get;
set;
}
public string DeviceName
{
get;
set;
}
public bool IsDefaultAdapter
{
get;
set;
}
public bool IsWideScreen public bool IsWideScreen
{ {
get get
@ -106,34 +67,12 @@ namespace ANX.Framework.Graphics
} }
} }
public int Revision public DisplayModeCollection SupportedDisplayModes { get; set; }
{
get;
set;
}
public int SubSystemId static GraphicsAdapter()
{ {
get; var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
set; Adapters = new ReadOnlyCollection<GraphicsAdapter>(creator.GetAdapterList());
}
public DisplayModeCollection SupportedDisplayModes
{
get
{
return this.supportedDisplayModes;
}
set
{
this.supportedDisplayModes = value;
}
}
public int VendorId
{
get;
set;
} }
public bool IsProfileSupported(GraphicsProfile graphicsProfile) public bool IsProfileSupported(GraphicsProfile graphicsProfile)
@ -141,15 +80,18 @@ namespace ANX.Framework.Graphics
throw new NotImplementedException(); throw new NotImplementedException();
} }
public bool QueryBackBufferFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat, out int selectedMultiSampleCount) public bool QueryBackBufferFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat,
int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat,
out int selectedMultiSampleCount)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public bool QueryRenderTargetFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat, out int selectedMultiSampleCount) public bool QueryRenderTargetFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat,
int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat,
out int selectedMultiSampleCount)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
} }

View File

@ -1,11 +1,3 @@
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,7 +1,5 @@
#region Using Statements
using System; using System;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,12 +7,13 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Tested)]
internal interface IDynamicGraphicsResource internal interface IDynamicGraphicsResource
{ {
event EventHandler<EventArgs> ContentLost;
void SetContentLost(bool isContentLost);
bool IsContentLost { get; } bool IsContentLost { get; }
event EventHandler<EventArgs> ContentLost;
void SetContentLost(bool isContentLost);
} }
} }

View File

@ -1,9 +1,5 @@
#region Using Statements
using System;
using ANX.Framework.NonXNA.Development; using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
@ -16,11 +12,8 @@ namespace ANX.Framework.Graphics
public interface IEffectFog public interface IEffectFog
{ {
Vector3 FogColor { get; set; } Vector3 FogColor { get; set; }
bool FogEnabled { get; set; } bool FogEnabled { get; set; }
float FogEnd { get; set; } float FogEnd { get; set; }
float FogStart { get; set; } float FogStart { get; set; }
} }
} }

View File

@ -1,9 +1,5 @@
#region Using Statements
using System;
using ANX.Framework.NonXNA.Development; using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
@ -15,16 +11,12 @@ namespace ANX.Framework.Graphics
[Developer("Glatzemann")] [Developer("Glatzemann")]
public interface IEffectLights public interface IEffectLights
{ {
void EnableDefaultLighting();
Vector3 AmbientLightColor { get; set; } Vector3 AmbientLightColor { get; set; }
DirectionalLight DirectionalLight0 { get; } DirectionalLight DirectionalLight0 { get; }
DirectionalLight DirectionalLight1 { get; } DirectionalLight DirectionalLight1 { get; }
DirectionalLight DirectionalLight2 { get; } DirectionalLight DirectionalLight2 { get; }
bool LightingEnabled { get; set; } bool LightingEnabled { get; set; }
void EnableDefaultLighting();
} }
} }

View File

@ -1,9 +1,5 @@
#region Using Statements
using System;
using ANX.Framework.NonXNA.Development; using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
@ -16,9 +12,7 @@ namespace ANX.Framework.Graphics
public interface IEffectMatrices public interface IEffectMatrices
{ {
Matrix Projection { get; set; } Matrix Projection { get; set; }
Matrix View { get; set; } Matrix View { get; set; }
Matrix World { get; set; } Matrix World { get; set; }
} }
} }

View File

@ -1,13 +1,6 @@
#region Using Statements
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA.Development; using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,9 +1,5 @@
#region Using Statements
using System;
using ANX.Framework.NonXNA.Development; using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,9 +1,5 @@
#region Using Statements
using System;
using ANX.Framework.NonXNA.Development; using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,7 +1,5 @@
#region Using Statements
using System; using System;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,12 +7,23 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
public sealed class ModelMeshPart public sealed class ModelMeshPart
{ {
#region Private
internal ModelMesh parentMesh; internal ModelMesh parentMesh;
private Effect effect; private Effect effect;
private IndexBuffer indexBuffer;
private int numVertices;
private int primitiveCount;
private int startIndex;
private Object tag;
private VertexBuffer vertexBuffer;
private int vertexOffset;
#endregion
#region Public
public Effect Effect public Effect Effect
{ {
get { return effect; } get { return effect; }
@ -29,44 +38,33 @@ namespace ANX.Framework.Graphics
} }
} }
private IndexBuffer indexBuffer;
public IndexBuffer IndexBuffer public IndexBuffer IndexBuffer
{ {
get { return indexBuffer; } get { return indexBuffer; }
internal set { this.indexBuffer = value; } internal set { this.indexBuffer = value; }
} }
private int numVertices;
public int NumVertices public int NumVertices
{ {
get { return numVertices; } get { return numVertices; }
} }
private int primitiveCount;
public int PrimitiveCount public int PrimitiveCount
{ {
get { return primitiveCount; } get { return primitiveCount; }
} }
private int startIndex;
public int StartIndex public int StartIndex
{ {
get { return startIndex; } get { return startIndex; }
} }
private Object tag;
public Object Tag public Object Tag
{ {
get { return tag; } get { return tag; }
set { tag = value; } set { tag = value; }
} }
private VertexBuffer vertexBuffer;
public VertexBuffer VertexBuffer public VertexBuffer VertexBuffer
{ {
@ -74,12 +72,12 @@ namespace ANX.Framework.Graphics
internal set { this.vertexBuffer = value; } internal set { this.vertexBuffer = value; }
} }
private int vertexOffset;
public int VertexOffset public int VertexOffset
{ {
get { return vertexOffset; } get { return vertexOffset; }
} }
#endregion
internal ModelMeshPart(int vertexOffset, int numVertices, int startIndex, int primitiveCount, object tag) internal ModelMeshPart(int vertexOffset, int numVertices, int startIndex, int primitiveCount, object tag)
{ {

View File

@ -1,10 +1,8 @@
#region Using Statements
using System; using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Collections; using System.Collections;
using System.Collections.Generic;
#endregion // Using Statements using System.Collections.ObjectModel;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -12,6 +10,8 @@ using System.Collections;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
public sealed class ModelMeshPartCollection : ReadOnlyCollection<ModelMeshPart> public sealed class ModelMeshPartCollection : ReadOnlyCollection<ModelMeshPart>
{ {
private ModelMeshPart[] modelMeshParts; private ModelMeshPart[] modelMeshParts;
@ -32,12 +32,6 @@ namespace ANX.Framework.Graphics
private ModelMeshPart[] wrappedArray; private ModelMeshPart[] wrappedArray;
private int position; private int position;
internal Enumerator(ModelMeshPart[] wrappedArray)
{
this.wrappedArray = wrappedArray;
this.position = -1;
}
public ModelMeshPart Current public ModelMeshPart Current
{ {
get get
@ -46,6 +40,20 @@ namespace ANX.Framework.Graphics
} }
} }
object IEnumerator.Current
{
get
{
return this.Current;
}
}
internal Enumerator(ModelMeshPart[] wrappedArray)
{
this.wrappedArray = wrappedArray;
this.position = -1;
}
public bool MoveNext() public bool MoveNext()
{ {
this.position++; this.position++;
@ -65,14 +73,6 @@ namespace ANX.Framework.Graphics
public void Dispose() public void Dispose()
{ {
} }
object IEnumerator.Current
{
get
{
return this.Current;
}
}
} }
} }
} }

View File

@ -1,12 +1,5 @@
#region Using Statements
using System; using System;
using System.Collections.Generic; using ANX.Framework.NonXNA.Development;
using System.Linq;
using System.Text;
using ANX.Framework.NonXNA;
using ANX.Framework.Graphics;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -14,6 +7,7 @@ using ANX.Framework.Graphics;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
public sealed class NoSuitableGraphicsDeviceException : Exception public sealed class NoSuitableGraphicsDeviceException : Exception
{ {
public NoSuitableGraphicsDeviceException() public NoSuitableGraphicsDeviceException()

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.Development;
using ANX.Framework.NonXNA.RenderSystem; using ANX.Framework.NonXNA.RenderSystem;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
@ -9,6 +10,9 @@ using ANX.Framework.NonXNA.RenderSystem;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("AstrorEnales")]
public class OcclusionQuery : GraphicsResource, IGraphicsResource public class OcclusionQuery : GraphicsResource, IGraphicsResource
{ {
#region Private #region Private

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -8,8 +9,15 @@ using ANX.Framework.NonXNA;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
public class RasterizerState : GraphicsResource public class RasterizerState : GraphicsResource
{ {
#region Constants
public static readonly RasterizerState CullClockwise;
public static readonly RasterizerState CullCounterClockwise;
public static readonly RasterizerState CullNone;
#endregion
#region Private #region Private
private INativeRasterizerState nativeRasterizerState; private INativeRasterizerState nativeRasterizerState;
@ -19,15 +27,9 @@ namespace ANX.Framework.Graphics
private bool multiSampleAntiAlias; private bool multiSampleAntiAlias;
private bool scissorTestEnable; private bool scissorTestEnable;
private float slopeScaleDepthBias; private float slopeScaleDepthBias;
#endregion #endregion
#region Public #region Public
public static readonly RasterizerState CullClockwise;
public static readonly RasterizerState CullCounterClockwise;
public static readonly RasterizerState CullNone;
#region NativeRasterizerState
internal INativeRasterizerState NativeRasterizerState internal INativeRasterizerState NativeRasterizerState
{ {
get get
@ -35,9 +37,7 @@ namespace ANX.Framework.Graphics
return this.nativeRasterizerState; return this.nativeRasterizerState;
} }
} }
#endregion
#region CullMode
public CullMode CullMode public CullMode CullMode
{ {
get get
@ -46,15 +46,12 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
ValidateSetProperty(); ThrowIfBound();
this.cullMode = value; this.cullMode = value;
this.nativeRasterizerState.CullMode = value; this.nativeRasterizerState.CullMode = value;
} }
} }
#endregion
#region DepthBias
public float DepthBias public float DepthBias
{ {
get get
@ -63,15 +60,12 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
ValidateSetProperty(); ThrowIfBound();
this.depthBias = value; this.depthBias = value;
this.nativeRasterizerState.DepthBias = value; this.nativeRasterizerState.DepthBias = value;
} }
} }
#endregion
#region FillMode
public FillMode FillMode public FillMode FillMode
{ {
get get
@ -80,15 +74,12 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
ValidateSetProperty(); ThrowIfBound();
this.fillMode = value; this.fillMode = value;
this.nativeRasterizerState.FillMode = value; this.nativeRasterizerState.FillMode = value;
} }
} }
#endregion
#region MultiSampleAntiAlias
public bool MultiSampleAntiAlias public bool MultiSampleAntiAlias
{ {
get get
@ -97,15 +88,12 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
ValidateSetProperty(); ThrowIfBound();
this.multiSampleAntiAlias = value; this.multiSampleAntiAlias = value;
this.nativeRasterizerState.MultiSampleAntiAlias = value; this.nativeRasterizerState.MultiSampleAntiAlias = value;
} }
} }
#endregion
#region SlopeScaleDepthBias
public bool ScissorTestEnable public bool ScissorTestEnable
{ {
get get
@ -114,15 +102,12 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
ValidateSetProperty(); ThrowIfBound();
this.scissorTestEnable = value; this.scissorTestEnable = value;
this.nativeRasterizerState.ScissorTestEnable = value; this.nativeRasterizerState.ScissorTestEnable = value;
} }
} }
#endregion
#region SlopeScaleDepthBias
public float SlopeScaleDepthBias public float SlopeScaleDepthBias
{ {
get get
@ -131,21 +116,18 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
ValidateSetProperty(); ThrowIfBound();
this.slopeScaleDepthBias = value; this.slopeScaleDepthBias = value;
this.nativeRasterizerState.SlopeScaleDepthBias = value; this.nativeRasterizerState.SlopeScaleDepthBias = value;
} }
} }
#endregion #endregion
#endregion
#region Constructor #region Constructor
public RasterizerState() public RasterizerState()
{ {
this.nativeRasterizerState = var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>() this.nativeRasterizerState = creator.CreateRasterizerState();
.CreateRasterizerState();
this.CullMode = CullMode.CullCounterClockwiseFace; this.CullMode = CullMode.CullCounterClockwiseFace;
this.DepthBias = 0f; this.DepthBias = 0f;
@ -157,9 +139,8 @@ namespace ANX.Framework.Graphics
private RasterizerState(CullMode cullMode, string name) private RasterizerState(CullMode cullMode, string name)
{ {
this.nativeRasterizerState = var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>() this.nativeRasterizerState = creator.CreateRasterizerState();
.CreateRasterizerState();
this.CullMode = cullMode; this.CullMode = cullMode;
this.DepthBias = 0f; this.DepthBias = 0f;
@ -167,30 +148,24 @@ namespace ANX.Framework.Graphics
this.MultiSampleAntiAlias = true; this.MultiSampleAntiAlias = true;
this.ScissorTestEnable = false; this.ScissorTestEnable = false;
this.SlopeScaleDepthBias = 0f; this.SlopeScaleDepthBias = 0f;
Name = name; Name = name;
} }
static RasterizerState() static RasterizerState()
{ {
CullClockwise = new RasterizerState(CullMode.CullClockwiseFace, CullClockwise = new RasterizerState(CullMode.CullClockwiseFace, "RasterizerState.CullClockwise");
"RasterizerState.CullClockwise"); CullCounterClockwise = new RasterizerState(CullMode.CullCounterClockwiseFace, "RasterizerState.CullCounterClockwise");
CullCounterClockwise = new RasterizerState(CullMode.CullCounterClockwiseFace,
"RasterizerState.CullCounterClockwise");
CullNone = new RasterizerState(CullMode.None, "RasterizerState.CullNone"); CullNone = new RasterizerState(CullMode.None, "RasterizerState.CullNone");
} }
#endregion #endregion
#region ValidateSetProperty (private helper) #region ThrowIfBound
private void ValidateSetProperty() private void ThrowIfBound()
{ {
if (this.nativeRasterizerState.IsBound) if (this.nativeRasterizerState.IsBound)
{ throw new InvalidOperationException("You are not allowed to change RasterizerState properties " +
throw new InvalidOperationException(
"You are not allowed to change RasterizerState properties " +
"while it is bound to the GraphicsDevice."); "while it is bound to the GraphicsDevice.");
} }
}
#endregion #endregion
#region Dispose #region Dispose

View File

@ -1,15 +1,7 @@
#region Using Statements
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ANX.Framework.NonXNA;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA.RenderSystem;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.CompilerServices; using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.RenderSystem;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -21,61 +13,13 @@ namespace ANX.Framework.Graphics
{ {
public event EventHandler<EventArgs> ContentLost; public event EventHandler<EventArgs> ContentLost;
#region Private Members #region Private
private DepthFormat depthStencilFormat; private DepthFormat depthStencilFormat;
private int multiSampleCount; private int multiSampleCount;
private RenderTargetUsage usage; private RenderTargetUsage usage;
private bool isContentLost; private bool isContentLost;
private INativeRenderTarget2D nativeRenderTarget; private INativeRenderTarget2D nativeRenderTarget;
#endregion
#endregion // Private Members
#region Constructors
public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height)
: base(graphicsDevice)
{
this.width = width;
this.height = height;
base.levelCount = 1;
base.format = SurfaceFormat.Color;
this.depthStencilFormat = DepthFormat.None;
this.multiSampleCount = 0;
this.usage = RenderTargetUsage.DiscardContents;
this.nativeRenderTarget = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateRenderTarget(graphicsDevice, width, height, false, SurfaceFormat.Color, this.depthStencilFormat, this.multiSampleCount, this.usage);
base.nativeTexture = this.nativeRenderTarget as INativeTexture2D;
}
public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, [MarshalAsAttribute(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat)
: base(graphicsDevice)
{
this.depthStencilFormat = DepthFormat.None;
this.multiSampleCount = 0;
this.usage = RenderTargetUsage.DiscardContents;
this.nativeRenderTarget = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateRenderTarget(graphicsDevice, width, height, false, SurfaceFormat.Color, this.depthStencilFormat, this.multiSampleCount, this.usage);
base.nativeTexture = this.nativeRenderTarget as INativeTexture2D;
}
public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, [MarshalAsAttribute(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
: base(graphicsDevice)
{
this.depthStencilFormat = preferredDepthFormat;
this.multiSampleCount = preferredMultiSampleCount;
this.usage = usage;
this.nativeRenderTarget = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateRenderTarget(graphicsDevice, width, height, false, SurfaceFormat.Color, this.depthStencilFormat, this.multiSampleCount, this.usage);
base.nativeTexture = this.nativeRenderTarget as INativeTexture2D;
}
#endregion // Constructors
protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged)
{
throw new NotImplementedException();
}
internal INativeRenderTarget2D NativeRenderTarget internal INativeRenderTarget2D NativeRenderTarget
{ {
@ -117,13 +61,66 @@ namespace ANX.Framework.Graphics
} }
} }
#region Constructor
public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height)
: base(graphicsDevice)
{
this.width = width;
this.height = height;
base.levelCount = 1;
base.format = SurfaceFormat.Color;
this.depthStencilFormat = DepthFormat.None;
this.multiSampleCount = 0;
this.usage = RenderTargetUsage.DiscardContents;
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
this.nativeRenderTarget = creator.CreateRenderTarget(graphicsDevice, width, height, false, SurfaceFormat.Color,
this.depthStencilFormat, this.multiSampleCount, this.usage);
base.nativeTexture = this.nativeRenderTarget as INativeTexture2D;
}
public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height,
[MarshalAsAttribute(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat)
: base(graphicsDevice)
{
this.depthStencilFormat = DepthFormat.None;
this.multiSampleCount = 0;
this.usage = RenderTargetUsage.DiscardContents;
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
this.nativeRenderTarget = creator.CreateRenderTarget(graphicsDevice, width, height, false, SurfaceFormat.Color,
this.depthStencilFormat, this.multiSampleCount, this.usage);
base.nativeTexture = this.nativeRenderTarget as INativeTexture2D;
}
public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height,
[MarshalAsAttribute(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat,
int preferredMultiSampleCount, RenderTargetUsage usage)
: base(graphicsDevice)
{
this.depthStencilFormat = preferredDepthFormat;
this.multiSampleCount = preferredMultiSampleCount;
this.usage = usage;
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
this.nativeRenderTarget = creator.CreateRenderTarget(graphicsDevice, width, height, false, SurfaceFormat.Color,
this.depthStencilFormat, this.multiSampleCount, this.usage);
base.nativeTexture = this.nativeRenderTarget as INativeTexture2D;
}
#endregion
protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged)
{
throw new NotImplementedException();
}
void IDynamicGraphicsResource.SetContentLost(bool isContentLost) void IDynamicGraphicsResource.SetContentLost(bool isContentLost)
{ {
this.isContentLost = isContentLost; this.isContentLost = isContentLost;
if (isContentLost) if (isContentLost)
{
raise_ContentLost(this, EventArgs.Empty); raise_ContentLost(this, EventArgs.Empty);
}
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -131,9 +128,7 @@ namespace ANX.Framework.Graphics
protected void raise_ContentLost(object sender, EventArgs args) protected void raise_ContentLost(object sender, EventArgs args)
{ {
if (ContentLost != null) if (ContentLost != null)
{
ContentLost(sender, args); ContentLost(sender, args);
} }
} }
}
} }

View File

@ -1,7 +1,5 @@
#region Using Statements
using System; using System;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,12 +7,31 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
public struct RenderTargetBinding public struct RenderTargetBinding
{ {
#region Private Members #region Private
private Texture renderTarget; private Texture renderTarget;
private CubeMapFace cubeMapFace; private CubeMapFace cubeMapFace;
#endregion // Private Members #endregion
#region Public
public Texture RenderTarget
{
get
{
return this.renderTarget;
}
}
public CubeMapFace CubeMapFace
{
get
{
return this.cubeMapFace;
}
}
#endregion
public RenderTargetBinding(RenderTarget2D renderTarget) public RenderTargetBinding(RenderTarget2D renderTarget)
{ {
@ -32,21 +49,5 @@ namespace ANX.Framework.Graphics
{ {
return new RenderTargetBinding(renderTarget); return new RenderTargetBinding(renderTarget);
} }
public Texture RenderTarget
{
get
{
return this.renderTarget;
}
}
public CubeMapFace CubeMapFace
{
get
{
return this.cubeMapFace;
}
}
} }
} }

View File

@ -1,13 +1,6 @@
#region Using Statements
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ANX.Framework.NonXNA;
using ANX.Framework.Graphics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -15,27 +8,11 @@ using System.Runtime.InteropServices;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(0)]
public class RenderTargetCube : TextureCube, IDynamicGraphicsResource public class RenderTargetCube : TextureCube, IDynamicGraphicsResource
{ {
public event EventHandler<EventArgs> ContentLost; public event EventHandler<EventArgs> ContentLost;
public RenderTargetCube(GraphicsDevice graphicsDevice, int size, [MarshalAsAttribute(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat)
: base(graphicsDevice, size, mipMap, preferredFormat)
{
throw new NotImplementedException();
}
public RenderTargetCube(GraphicsDevice graphicsDevice, int size, [MarshalAsAttribute(UnmanagedType.U1)] bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
: base(graphicsDevice, size, mipMap, preferredFormat)
{
throw new NotImplementedException();
}
protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged)
{
throw new NotImplementedException();
}
public DepthFormat DepthStencilFormat public DepthFormat DepthStencilFormat
{ {
get get
@ -68,6 +45,26 @@ namespace ANX.Framework.Graphics
} }
} }
public RenderTargetCube(GraphicsDevice graphicsDevice, int size, [MarshalAsAttribute(UnmanagedType.U1)] bool mipMap,
SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat)
: base(graphicsDevice, size, mipMap, preferredFormat)
{
throw new NotImplementedException();
}
public RenderTargetCube(GraphicsDevice graphicsDevice, int size, [MarshalAsAttribute(UnmanagedType.U1)] bool mipMap,
SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount,
RenderTargetUsage usage)
: base(graphicsDevice, size, mipMap, preferredFormat)
{
throw new NotImplementedException();
}
protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged)
{
throw new NotImplementedException();
}
void IDynamicGraphicsResource.SetContentLost(bool isContentLost) void IDynamicGraphicsResource.SetContentLost(bool isContentLost)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@ -76,9 +73,7 @@ namespace ANX.Framework.Graphics
protected void raise_ContentLost(object sender, EventArgs args) protected void raise_ContentLost(object sender, EventArgs args)
{ {
if (ContentLost != null) if (ContentLost != null)
{
ContentLost(sender, args); ContentLost(sender, args);
} }
} }
}
} }

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,7 +1,5 @@
#region Using Statements
using System; using System;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,17 +7,14 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
public sealed class ResourceCreatedEventArgs : EventArgs public sealed class ResourceCreatedEventArgs : EventArgs
{ {
public object Resource { get; set; }
public ResourceCreatedEventArgs(object resource) public ResourceCreatedEventArgs(object resource)
{ {
this.Resource = resource; this.Resource = resource;
} }
public object Resource
{
get;
set;
}
} }
} }

View File

@ -1,7 +1,5 @@
#region Using Statements
using System; using System;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,24 +7,16 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
public sealed class ResourceDestroyedEventArgs : EventArgs public sealed class ResourceDestroyedEventArgs : EventArgs
{ {
public string Name { get; set; }
public object Tag { get; set; }
public ResourceDestroyedEventArgs(string name, object tag) public ResourceDestroyedEventArgs(string name, object tag)
{ {
this.Tag = tag; this.Tag = tag;
this.Name = name; this.Name = name;
} }
public string Name
{
get;
set;
}
public object Tag
{
get;
set;
}
} }
} }

View File

@ -1,9 +1,7 @@
#region Using Statements
using System; using System;
using ANX.Framework.NonXNA;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ANX.Framework.NonXNA;
#endregion // Using Statements using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -11,9 +9,19 @@ using System.Runtime.InteropServices;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
public class SamplerState : GraphicsResource public class SamplerState : GraphicsResource
{ {
#region Private Members #region Constants
public static readonly SamplerState AnisotropicClamp;
public static readonly SamplerState AnisotropicWrap;
public static readonly SamplerState LinearClamp;
public static readonly SamplerState LinearWrap;
public static readonly SamplerState PointClamp;
public static readonly SamplerState PointWrap;
#endregion
#region Private
private INativeSamplerState nativeSamplerState; private INativeSamplerState nativeSamplerState;
private TextureAddressMode addressU; private TextureAddressMode addressU;
@ -23,54 +31,9 @@ namespace ANX.Framework.Graphics
private int maxAnisotropy; private int maxAnisotropy;
private int maxMipLevel; private int maxMipLevel;
private float mipMapLevelOfDetailBias; private float mipMapLevelOfDetailBias;
#endregion
#endregion // Private Members #region Public
public static readonly SamplerState AnisotropicClamp;
public static readonly SamplerState AnisotropicWrap;
public static readonly SamplerState LinearClamp;
public static readonly SamplerState LinearWrap;
public static readonly SamplerState PointClamp;
public static readonly SamplerState PointWrap;
public SamplerState()
{
this.nativeSamplerState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateSamplerState();
this.AddressU = TextureAddressMode.Wrap;
this.AddressV = TextureAddressMode.Wrap;
this.AddressW = TextureAddressMode.Wrap;
this.Filter = TextureFilter.Linear;
this.MaxAnisotropy = 0;
this.MaxMipLevel = 0;
this.MipMapLevelOfDetailBias = 0f;
}
private SamplerState(TextureFilter filter, TextureAddressMode addressMode, string name)
{
this.nativeSamplerState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateSamplerState();
this.AddressU = addressMode;
this.AddressV = addressMode;
this.AddressW = addressMode;
this.Filter = filter;
this.MaxAnisotropy = 0;
this.MaxMipLevel = 0;
this.MipMapLevelOfDetailBias = 0f;
Name = name;
}
static SamplerState()
{
PointWrap = new SamplerState(TextureFilter.Point, TextureAddressMode.Wrap, "SamplerState.PointWrap");
PointClamp = new SamplerState(TextureFilter.Point, TextureAddressMode.Clamp, "SamplerState.PointClamp");
LinearWrap = new SamplerState(TextureFilter.Linear, TextureAddressMode.Wrap, "SamplerState.LinearWrap");
LinearClamp = new SamplerState(TextureFilter.Linear, TextureAddressMode.Clamp, "SamplerState.LinearClamp");
AnisotropicWrap = new SamplerState(TextureFilter.Anisotropic, TextureAddressMode.Wrap, "SamplerState.AnisotropicWrap");
AnisotropicClamp = new SamplerState(TextureFilter.Anisotropic, TextureAddressMode.Clamp, "SamplerState.AnisotropicClamp");
}
internal INativeSamplerState NativeSamplerState internal INativeSamplerState NativeSamplerState
{ {
get get
@ -87,11 +50,7 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
if (this.nativeSamplerState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change SamplerState properties while it is bound to the GraphicsDevice.");
}
this.addressU = value; this.addressU = value;
this.nativeSamplerState.AddressU = value; this.nativeSamplerState.AddressU = value;
} }
@ -105,11 +64,7 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
if (this.nativeSamplerState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change SamplerState properties while it is bound to the GraphicsDevice.");
}
this.addressV = value; this.addressV = value;
this.nativeSamplerState.AddressV = value; this.nativeSamplerState.AddressV = value;
} }
@ -123,11 +78,7 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
if (this.nativeSamplerState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change SamplerState properties while it is bound to the GraphicsDevice.");
}
this.addressW = value; this.addressW = value;
this.nativeSamplerState.AddressW = value; this.nativeSamplerState.AddressW = value;
} }
@ -141,11 +92,7 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
if (this.nativeSamplerState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change SamplerState properties while it is bound to the GraphicsDevice.");
}
this.filter = value; this.filter = value;
this.nativeSamplerState.Filter = value; this.nativeSamplerState.Filter = value;
} }
@ -159,11 +106,7 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
if (this.nativeSamplerState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change SamplerState properties while it is bound to the GraphicsDevice.");
}
this.maxAnisotropy = value; this.maxAnisotropy = value;
this.nativeSamplerState.MaxAnisotropy = value; this.nativeSamplerState.MaxAnisotropy = value;
} }
@ -177,11 +120,7 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
if (this.nativeSamplerState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change SamplerState properties while it is bound to the GraphicsDevice.");
}
this.maxMipLevel = value; this.maxMipLevel = value;
this.nativeSamplerState.MaxMipLevel = value; this.nativeSamplerState.MaxMipLevel = value;
} }
@ -195,16 +134,53 @@ namespace ANX.Framework.Graphics
} }
set set
{ {
if (this.nativeSamplerState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change SamplerState properties while it is bound to the GraphicsDevice.");
}
this.mipMapLevelOfDetailBias = value; this.mipMapLevelOfDetailBias = value;
this.nativeSamplerState.MipMapLevelOfDetailBias = value; this.nativeSamplerState.MipMapLevelOfDetailBias = value;
} }
} }
#endregion
#region Constructor
public SamplerState()
{
CreateNative();
AddressU = TextureAddressMode.Wrap;
AddressV = TextureAddressMode.Wrap;
AddressW = TextureAddressMode.Wrap;
Filter = TextureFilter.Linear;
MaxAnisotropy = 0;
MaxMipLevel = 0;
MipMapLevelOfDetailBias = 0f;
}
private SamplerState(TextureFilter filter, TextureAddressMode addressMode, string name)
{
CreateNative();
AddressU = addressMode;
AddressV = addressMode;
AddressW = addressMode;
Filter = filter;
MaxAnisotropy = 0;
MaxMipLevel = 0;
MipMapLevelOfDetailBias = 0f;
Name = name;
}
static SamplerState()
{
PointWrap = new SamplerState(TextureFilter.Point, TextureAddressMode.Wrap, "SamplerState.PointWrap");
PointClamp = new SamplerState(TextureFilter.Point, TextureAddressMode.Clamp, "SamplerState.PointClamp");
LinearWrap = new SamplerState(TextureFilter.Linear, TextureAddressMode.Wrap, "SamplerState.LinearWrap");
LinearClamp = new SamplerState(TextureFilter.Linear, TextureAddressMode.Clamp, "SamplerState.LinearClamp");
AnisotropicWrap = new SamplerState(TextureFilter.Anisotropic, TextureAddressMode.Wrap,
"SamplerState.AnisotropicWrap");
AnisotropicClamp = new SamplerState(TextureFilter.Anisotropic, TextureAddressMode.Clamp,
"SamplerState.AnisotropicClamp");
}
#endregion
#region Dispose
public override void Dispose() public override void Dispose()
{ {
if (this.nativeSamplerState != null) if (this.nativeSamplerState != null)
@ -218,5 +194,23 @@ namespace ANX.Framework.Graphics
{ {
base.Dispose(disposeManaged); base.Dispose(disposeManaged);
} }
#endregion
#region CreateNative
private void CreateNative()
{
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
nativeSamplerState = creator.CreateSamplerState();
}
#endregion
#region ThrowIfBound
private void ThrowIfBound()
{
if (nativeSamplerState.IsBound)
throw new InvalidOperationException("You are not allowed to change SamplerState properties while it is " +
"bound to the GraphicsDevice.");
}
#endregion
} }
} }

View File

@ -1,7 +1,4 @@
#region Using Statements using ANX.Framework.NonXNA.Development;
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,6 +6,7 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
public sealed class SamplerStateCollection public sealed class SamplerStateCollection
{ {
private SamplerState[] samplerStates; private SamplerState[] samplerStates;
@ -20,10 +18,8 @@ namespace ANX.Framework.Graphics
this.samplerStates = new SamplerState[maxSamplers]; this.samplerStates = new SamplerState[maxSamplers];
for (int i = 0; i < samplerStates.Length; i++) for (int i = 0; i < samplerStates.Length; i++)
{
samplerStates[i] = SamplerState.LinearWrap; samplerStates[i] = SamplerState.LinearWrap;
} }
}
public SamplerState this[int index] public SamplerState this[int index]
{ {

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,5 @@
#region Using Statements
using System; using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,5 @@
#region Using Statements
using System; using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,9 +1,4 @@
#region Using Statements
using System;
using ANX.Framework.NonXNA.RenderSystem; using ANX.Framework.NonXNA.RenderSystem;
using ANX.Framework.NonXNA;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -17,19 +12,6 @@ namespace ANX.Framework.Graphics
protected internal SurfaceFormat format; protected internal SurfaceFormat format;
protected internal INativeTexture nativeTexture; protected internal INativeTexture nativeTexture;
public Texture(GraphicsDevice graphicsDevice)
: base(graphicsDevice)
{
base.GraphicsDevice.ResourceCreated += GraphicsDevice_ResourceCreated;
base.GraphicsDevice.ResourceDestroyed += GraphicsDevice_ResourceDestroyed;
}
~Texture()
{
base.GraphicsDevice.ResourceCreated -= GraphicsDevice_ResourceCreated;
base.GraphicsDevice.ResourceDestroyed -= GraphicsDevice_ResourceDestroyed;
}
public int LevelCount public int LevelCount
{ {
get get
@ -59,6 +41,19 @@ namespace ANX.Framework.Graphics
} }
} }
public Texture(GraphicsDevice graphicsDevice)
: base(graphicsDevice)
{
base.GraphicsDevice.ResourceCreated += GraphicsDevice_ResourceCreated;
base.GraphicsDevice.ResourceDestroyed += GraphicsDevice_ResourceDestroyed;
}
~Texture()
{
base.GraphicsDevice.ResourceCreated -= GraphicsDevice_ResourceCreated;
base.GraphicsDevice.ResourceDestroyed -= GraphicsDevice_ResourceDestroyed;
}
public override void Dispose() public override void Dispose()
{ {
Dispose(true); Dispose(true);
@ -77,21 +72,12 @@ namespace ANX.Framework.Graphics
private void GraphicsDevice_ResourceDestroyed(object sender, ResourceDestroyedEventArgs e) private void GraphicsDevice_ResourceDestroyed(object sender, ResourceDestroyedEventArgs e)
{ {
if (nativeTexture != null) Dispose(true);
{
nativeTexture.Dispose();
nativeTexture = null;
}
} }
private void GraphicsDevice_ResourceCreated(object sender, ResourceCreatedEventArgs e) private void GraphicsDevice_ResourceCreated(object sender, ResourceCreatedEventArgs e)
{ {
if (nativeTexture != null) Dispose(true);
{
nativeTexture.Dispose();
nativeTexture = null;
}
ReCreateNativeTextureSurface(); ReCreateNativeTextureSurface();
} }
} }

View File

@ -1,12 +1,9 @@
#region Using Statements
using System; using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.RenderSystem; using ANX.Framework.NonXNA.RenderSystem;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
@ -25,9 +22,7 @@ namespace ANX.Framework.Graphics
get get
{ {
if (nativeTexture2D == null) if (nativeTexture2D == null)
{
CreateNativeTextureSurface(); CreateNativeTextureSurface();
}
return nativeTexture2D; return nativeTexture2D;
} }
@ -93,14 +88,12 @@ namespace ANX.Framework.Graphics
#endregion #endregion
#region FromStream (TODO) #region FromStream (TODO)
public static Texture2D FromStream(GraphicsDevice graphicsDevice, public static Texture2D FromStream(GraphicsDevice graphicsDevice, Stream stream)
Stream stream)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public static Texture2D FromStream(GraphicsDevice graphicsDevice, public static Texture2D FromStream(GraphicsDevice graphicsDevice, Stream stream, int width, int height,
Stream stream, int width, int height,
[MarshalAsAttribute(UnmanagedType.U1)] bool zoom) [MarshalAsAttribute(UnmanagedType.U1)] bool zoom)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@ -108,8 +101,7 @@ namespace ANX.Framework.Graphics
#endregion #endregion
#region GetData #region GetData
public void GetData<T>(int level, Nullable<Rectangle> rect, T[] data, public void GetData<T>(int level, Nullable<Rectangle> rect, T[] data, int startIndex, int elementCount) where T : struct
int startIndex, int elementCount) where T : struct
{ {
NativeTexture2D.GetData(level, rect, data, startIndex, elementCount); NativeTexture2D.GetData(level, rect, data, startIndex, elementCount);
} }
@ -126,8 +118,7 @@ namespace ANX.Framework.Graphics
#endregion #endregion
#region SetData #region SetData
public void SetData<T>(int level, Nullable<Rectangle> rect, T[] data, public void SetData<T>(int level, Nullable<Rectangle> rect, T[] data, int startIndex, int elementCount) where T : struct
int startIndex, int elementCount) where T : struct
{ {
NativeTexture2D.SetData(level, rect, data, startIndex, elementCount); NativeTexture2D.SetData(level, rect, data, startIndex, elementCount);
} }
@ -163,8 +154,7 @@ namespace ANX.Framework.Graphics
base.Dispose(true); base.Dispose(true);
} }
protected override void Dispose( protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged)
[MarshalAs(UnmanagedType.U1)] bool disposeManaged)
{ {
base.Dispose(disposeManaged); base.Dispose(disposeManaged);
} }
@ -180,8 +170,8 @@ namespace ANX.Framework.Graphics
#region CreateNativeTextureSurface #region CreateNativeTextureSurface
private void CreateNativeTextureSurface() private void CreateNativeTextureSurface()
{ {
nativeTexture2D = var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateTexture(GraphicsDevice, format, width, height, levelCount); nativeTexture2D = creator.CreateTexture(GraphicsDevice, format, width, height, levelCount);
base.nativeTexture = nativeTexture2D; base.nativeTexture = nativeTexture2D;
} }
#endregion #endregion

View File

@ -1,8 +1,6 @@
#region Using Statements
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -10,15 +8,35 @@ using System.Runtime.InteropServices;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(0)]
public class Texture3D : Texture, IGraphicsResource public class Texture3D : Texture, IGraphicsResource
{ {
public Texture3D(GraphicsDevice graphics, int width, int height, int depth, [MarshalAsAttribute(UnmanagedType.U1)] bool mipMap, SurfaceFormat format) public int Depth
: base(graphics)
{ {
get;
private set;
} }
public void GetData<T>(int level, int left, int top, int right, int bottom, int front, int back, T[] data, int startIndex, int elementCount) where T : struct public int Width
{
get;
private set;
}
public int Height
{
get;
private set;
}
public Texture3D(GraphicsDevice graphics, int width, int height, int depth,
[MarshalAsAttribute(UnmanagedType.U1)] bool mipMap, SurfaceFormat format)
: base(graphics)
{
}
public void GetData<T>(int level, int left, int top, int right, int bottom, int front, int back, T[] data,
int startIndex, int elementCount) where T : struct
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -33,7 +51,8 @@ namespace ANX.Framework.Graphics
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void SetData<T>(int level, int left, int top, int right, int bottom, int front, int back, T[] data, int startIndex, int elementCount) where T : struct public void SetData<T>(int level, int left, int top, int right, int bottom, int front, int back, T[] data,
int startIndex, int elementCount) where T : struct
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -58,24 +77,6 @@ namespace ANX.Framework.Graphics
throw new NotImplementedException(); throw new NotImplementedException();
} }
public int Depth
{
get;
private set;
}
public int Width
{
get;
private set;
}
public int Height
{
get;
private set;
}
internal override void ReCreateNativeTextureSurface() internal override void ReCreateNativeTextureSurface()
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,6 @@
#region Using Statements
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -10,15 +8,25 @@ using System.Runtime.InteropServices;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(0)]
public class TextureCube : Texture, IGraphicsResource public class TextureCube : Texture, IGraphicsResource
{ {
public TextureCube(GraphicsDevice graphics, int size, [MarshalAsAttribute(UnmanagedType.U1)] bool mipMap, SurfaceFormat format) public int Size
{
get;
private set;
}
public TextureCube(GraphicsDevice graphics, int size, [MarshalAsAttribute(UnmanagedType.U1)] bool mipMap,
SurfaceFormat format)
: base(graphics) : base(graphics)
{ {
this.Size = size; this.Size = size;
} }
public void GetData<T>(CubeMapFace cubeMapFace, int level, Nullable<Rectangle> rect, T[] data, int startIndex, int elementCount) where T : struct #region GetData (TODO)
public void GetData<T>(CubeMapFace cubeMapFace, int level, Nullable<Rectangle> rect, T[] data, int startIndex,
int elementCount) where T : struct
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -32,8 +40,11 @@ namespace ANX.Framework.Graphics
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion
public void SetData<T>(CubeMapFace cubeMapFace, int level, Nullable<Rectangle> rect, T[] data, int startIndex, int elementCount) where T : struct #region SetData (TODO)
public void SetData<T>(CubeMapFace cubeMapFace, int level, Nullable<Rectangle> rect, T[] data, int startIndex,
int elementCount) where T : struct
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -47,6 +58,7 @@ namespace ANX.Framework.Graphics
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion
public override void Dispose() public override void Dispose()
{ {
@ -58,12 +70,6 @@ namespace ANX.Framework.Graphics
throw new NotImplementedException(); throw new NotImplementedException();
} }
public int Size
{
get;
private set;
}
internal override void ReCreateNativeTextureSurface() internal override void ReCreateNativeTextureSurface()
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,7 +1,4 @@
#region Using Statements using ANX.Framework.NonXNA.Development;
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,13 +6,40 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
public struct VertexBufferBinding public struct VertexBufferBinding
{ {
#region Private Members #region Private
private VertexBuffer vertexBuffer; private VertexBuffer vertexBuffer;
private int instanceFrequency; private int instanceFrequency;
private int vertexOffset; private int vertexOffset;
#endregion // Private Members #endregion
#region Public
public VertexBuffer VertexBuffer
{
get
{
return this.vertexBuffer;
}
}
public int InstanceFrequency
{
get
{
return this.instanceFrequency;
}
}
public int VertexOffset
{
get
{
return this.vertexOffset;
}
}
#endregion
public VertexBufferBinding(VertexBuffer vertexBuffer) public VertexBufferBinding(VertexBuffer vertexBuffer)
{ {
@ -42,29 +66,5 @@ namespace ANX.Framework.Graphics
{ {
return new VertexBufferBinding(vertexBuffer); return new VertexBufferBinding(vertexBuffer);
} }
public VertexBuffer VertexBuffer
{
get
{
return this.vertexBuffer;
}
}
public int InstanceFrequency
{
get
{
return this.instanceFrequency;
}
}
public int VertexOffset
{
get
{
return this.vertexOffset;
}
}
} }
} }

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -7,6 +8,7 @@ using System.Runtime.InteropServices;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
public class VertexDeclaration : GraphicsResource public class VertexDeclaration : GraphicsResource
{ {
private VertexElement[] elements; private VertexElement[] elements;
@ -33,10 +35,7 @@ namespace ANX.Framework.Graphics
public VertexElement[] GetVertexElements() public VertexElement[] GetVertexElements()
{ {
if (elements != null) return (elements != null) ? (elements.Clone() as VertexElement[]) : null;
return elements.Clone() as VertexElement[];
else
return null;
} }
public override void Dispose() public override void Dispose()
@ -70,7 +69,7 @@ namespace ANX.Framework.Graphics
case VertexElementFormat.Vector4: case VertexElementFormat.Vector4:
return 16; return 16;
default: default:
throw new ArgumentException("unknown VertexElementFormat size '" + format + "'"); throw new ArgumentException("Unknown VertexElementFormat size '" + format + "'.");
} }
} }
} }

View File

@ -1,7 +1,5 @@
#region Using Statements
using System; using System;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,24 +7,17 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(95)]
public struct VertexElement public struct VertexElement
{ {
#region Private Members #region Private
private int offset; private int offset;
private VertexElementFormat elementFormat; private VertexElementFormat elementFormat;
private VertexElementUsage elementUsage; private VertexElementUsage elementUsage;
private int usageIndex; private int usageIndex;
#endregion
#endregion // Private Members #region Public
public VertexElement(int offset, VertexElementFormat elementFormat, VertexElementUsage elementUsage, int usageIndex)
{
this.offset = offset;
this.elementFormat = elementFormat;
this.elementUsage = elementUsage;
this.usageIndex = usageIndex;
}
public int Offset public int Offset
{ {
get get
@ -74,6 +65,15 @@ namespace ANX.Framework.Graphics
this.usageIndex = value; this.usageIndex = value;
} }
} }
#endregion
public VertexElement(int offset, VertexElementFormat elementFormat, VertexElementUsage elementUsage, int usageIndex)
{
this.offset = offset;
this.elementFormat = elementFormat;
this.elementUsage = elementUsage;
this.usageIndex = usageIndex;
}
public override int GetHashCode() public override int GetHashCode()
{ {
@ -82,27 +82,28 @@ namespace ANX.Framework.Graphics
public override string ToString() public override string ToString()
{ {
return string.Format("{{Offset:{0} Format:{1} Usage:{2} UsageIndex:{3}}}", this.offset, this.elementFormat, this.elementUsage, this.usageIndex); return String.Format("{{Offset:{0} Format:{1} Usage:{2} UsageIndex:{3}}}", offset, elementFormat, elementUsage,
usageIndex);
} }
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj != null && obj.GetType() == this.GetType()) if (obj != null && obj is VertexElement)
{
return this == (VertexElement)obj; return this == (VertexElement)obj;
}
return false; return false;
} }
public static bool operator ==(VertexElement lhs, VertexElement rhs) public static bool operator ==(VertexElement lhs, VertexElement rhs)
{ {
return lhs.offset == rhs.offset && lhs.elementFormat == rhs.elementFormat && lhs.elementUsage == rhs.elementUsage && lhs.usageIndex == rhs.usageIndex; return lhs.offset == rhs.offset && lhs.elementFormat == rhs.elementFormat && lhs.elementUsage == rhs.elementUsage &&
lhs.usageIndex == rhs.usageIndex;
} }
public static bool operator !=(VertexElement lhs, VertexElement rhs) public static bool operator !=(VertexElement lhs, VertexElement rhs)
{ {
return lhs.offset != rhs.offset || lhs.elementFormat != rhs.elementFormat || lhs.elementUsage != rhs.elementUsage || lhs.usageIndex == rhs.usageIndex; return lhs.offset != rhs.offset || lhs.elementFormat != rhs.elementFormat || lhs.elementUsage != rhs.elementUsage ||
lhs.usageIndex == rhs.usageIndex;
} }
} }
} }

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,8 +1,3 @@
#region Using Statements
using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -1,4 +1,5 @@
using System; using System;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -6,6 +7,7 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(95)]
public struct VertexPositionColor : IVertexType public struct VertexPositionColor : IVertexType
{ {
public Vector3 Position; public Vector3 Position;
@ -15,10 +17,7 @@ namespace ANX.Framework.Graphics
VertexDeclaration IVertexType.VertexDeclaration VertexDeclaration IVertexType.VertexDeclaration
{ {
get get { return VertexDeclaration; }
{
return VertexDeclaration;
}
} }
public VertexPositionColor(Vector3 position, Color color) public VertexPositionColor(Vector3 position, Color color)
@ -31,15 +30,12 @@ namespace ANX.Framework.Graphics
{ {
VertexElement[] elements = VertexElement[] elements =
{ {
new VertexElement(0, VertexElementFormat.Vector3, new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Color, VertexElementUsage.Color, 0),
new VertexElement(12, VertexElementFormat.Color,
VertexElementUsage.Color, 0),
}; };
VertexDeclaration declaration = new VertexDeclaration(16, elements); VertexDeclaration = new VertexDeclaration(16, elements);
declaration.Name = "VertexPositionColor.VertexDeclaration"; VertexDeclaration.Name = "VertexPositionColor.VertexDeclaration";
VertexDeclaration = declaration;
} }
public override int GetHashCode() public override int GetHashCode()
@ -49,16 +45,13 @@ namespace ANX.Framework.Graphics
public override string ToString() public override string ToString()
{ {
return string.Format("{{Position:{0} Color:{1}}}", return String.Format("{{Position:{0} Color:{1}}}", Position, Color);
this.Position, this.Color);
} }
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj != null && obj.GetType() == this.GetType()) if (obj != null && obj is VertexPositionColor)
{
return this == (VertexPositionColor)obj; return this == (VertexPositionColor)obj;
}
return false; return false;
} }
@ -70,8 +63,7 @@ namespace ANX.Framework.Graphics
public static bool operator !=(VertexPositionColor lhs, VertexPositionColor rhs) public static bool operator !=(VertexPositionColor lhs, VertexPositionColor rhs)
{ {
return lhs.Color.Equals(rhs.Color) == false || return lhs.Color.Equals(rhs.Color) == false || lhs.Position.Equals(rhs.Position) == false;
lhs.Position.Equals(rhs.Position) == false;
} }
} }
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -6,6 +7,7 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(95)]
public struct VertexPositionColorTexture : IVertexType public struct VertexPositionColorTexture : IVertexType
{ {
public Vector3 Position; public Vector3 Position;
@ -16,14 +18,10 @@ namespace ANX.Framework.Graphics
VertexDeclaration IVertexType.VertexDeclaration VertexDeclaration IVertexType.VertexDeclaration
{ {
get get { return VertexDeclaration; }
{
return VertexDeclaration;
}
} }
public VertexPositionColorTexture(Vector3 position, Color color, public VertexPositionColorTexture(Vector3 position, Color color, Vector2 textureCoordinate)
Vector2 textureCoordinate)
{ {
this.Position = position; this.Position = position;
this.Color = color; this.Color = color;
@ -34,17 +32,13 @@ namespace ANX.Framework.Graphics
{ {
VertexElement[] elements = VertexElement[] elements =
{ {
new VertexElement(0, VertexElementFormat.Vector3, new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Color, VertexElementUsage.Color, 0),
new VertexElement(12, VertexElementFormat.Color, new VertexElement(16, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
VertexElementUsage.Color, 0),
new VertexElement(16, VertexElementFormat.Vector2,
VertexElementUsage.TextureCoordinate, 0),
}; };
VertexDeclaration delcaration = new VertexDeclaration(24, elements); VertexDeclaration = new VertexDeclaration(24, elements);
delcaration.Name = "VertexPositionColorTexture.VertexDeclaration"; VertexDeclaration.Name = "VertexPositionColorTexture.VertexDeclaration";
VertexDeclaration = delcaration;
} }
public override int GetHashCode() public override int GetHashCode()
@ -54,33 +48,26 @@ namespace ANX.Framework.Graphics
public override string ToString() public override string ToString()
{ {
return string.Format("{{Position:{0} Color:{1} TextureCoordinate:{2}}}", return String.Format("{{Position:{0} Color:{1} TextureCoordinate:{2}}}", Position, Color, TextureCoordinate);
this.Position, this.Color, this.TextureCoordinate);
} }
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj != null && obj.GetType() == this.GetType()) if (obj != null && obj is VertexPositionColorTexture)
{
return this == (VertexPositionColorTexture)obj; return this == (VertexPositionColorTexture)obj;
}
return false; return false;
} }
public static bool operator ==(VertexPositionColorTexture lhs, public static bool operator ==(VertexPositionColorTexture lhs, VertexPositionColorTexture rhs)
VertexPositionColorTexture rhs)
{ {
return lhs.Color.Equals(rhs.Color) && return lhs.Color.Equals(rhs.Color) && lhs.Position.Equals(rhs.Position) &&
lhs.Position.Equals(rhs.Position) &&
lhs.TextureCoordinate.Equals(rhs.TextureCoordinate); lhs.TextureCoordinate.Equals(rhs.TextureCoordinate);
} }
public static bool operator !=(VertexPositionColorTexture lhs, public static bool operator !=(VertexPositionColorTexture lhs, VertexPositionColorTexture rhs)
VertexPositionColorTexture rhs)
{ {
return lhs.Color.Equals(rhs.Color) == false || return lhs.Color.Equals(rhs.Color) == false || lhs.Position.Equals(rhs.Position) == false ||
lhs.Position.Equals(rhs.Position) == false ||
lhs.TextureCoordinate.Equals(rhs.TextureCoordinate) == false; lhs.TextureCoordinate.Equals(rhs.TextureCoordinate) == false;
} }
} }

View File

@ -1,7 +1,5 @@
#region Using Statements
using System; using System;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,6 +7,7 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(95)]
public struct VertexPositionNormalTexture : IVertexType public struct VertexPositionNormalTexture : IVertexType
{ {
public Vector3 Position; public Vector3 Position;
@ -31,13 +30,14 @@ namespace ANX.Framework.Graphics
static VertexPositionNormalTexture() static VertexPositionNormalTexture()
{ {
VertexElement[] elements = new VertexElement[] { new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), VertexElement[] elements = new VertexElement[]
{
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0), new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0), new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
}; };
VertexDeclaration d = new VertexDeclaration(32, elements); VertexDeclaration = new VertexDeclaration(32, elements);
d.Name = "VertexPositionNormalTexture.VertexDeclaration"; VertexDeclaration.Name = "VertexPositionNormalTexture.VertexDeclaration";
VertexDeclaration = d;
} }
public override int GetHashCode() public override int GetHashCode()
@ -47,27 +47,27 @@ namespace ANX.Framework.Graphics
public override string ToString() public override string ToString()
{ {
return string.Format("{{Position:{0} Normal:{1} TextureCoordinate:{2}}}", this.Position, this.Normal, this.TextureCoordinate); return String.Format("{{Position:{0} Normal:{1} TextureCoordinate:{2}}}", Position, Normal, TextureCoordinate);
} }
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj != null && obj.GetType() == this.GetType()) if (obj != null && obj is VertexPositionNormalTexture)
{
return this == (VertexPositionNormalTexture)obj; return this == (VertexPositionNormalTexture)obj;
}
return false; return false;
} }
public static bool operator ==(VertexPositionNormalTexture lhs, VertexPositionNormalTexture rhs) public static bool operator ==(VertexPositionNormalTexture lhs, VertexPositionNormalTexture rhs)
{ {
return lhs.Normal.Equals(rhs.Normal) && lhs.Position.Equals(rhs.Position) && lhs.TextureCoordinate.Equals(rhs.TextureCoordinate); return lhs.Normal.Equals(rhs.Normal) && lhs.Position.Equals(rhs.Position) &&
lhs.TextureCoordinate.Equals(rhs.TextureCoordinate);
} }
public static bool operator !=(VertexPositionNormalTexture lhs, VertexPositionNormalTexture rhs) public static bool operator !=(VertexPositionNormalTexture lhs, VertexPositionNormalTexture rhs)
{ {
return !lhs.Normal.Equals(rhs.Normal) || !lhs.Position.Equals(rhs.Position) || !lhs.TextureCoordinate.Equals(rhs.TextureCoordinate); return lhs.Normal.Equals(rhs.Normal) == false || lhs.Position.Equals(rhs.Position) == false ||
lhs.TextureCoordinate.Equals(rhs.TextureCoordinate) == false;
} }
} }
} }

View File

@ -1,7 +1,5 @@
#region Using Statements
using System; using System;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,6 +7,7 @@ using System;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(95)]
public struct VertexPositionTexture : IVertexType public struct VertexPositionTexture : IVertexType
{ {
public Vector3 Position; public Vector3 Position;
@ -29,12 +28,13 @@ namespace ANX.Framework.Graphics
static VertexPositionTexture() static VertexPositionTexture()
{ {
VertexElement[] elements = new VertexElement[] { new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), VertexElement[] elements = new VertexElement[]
{
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(12, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0), new VertexElement(12, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
}; };
VertexDeclaration d = new VertexDeclaration(20, elements); VertexDeclaration = new VertexDeclaration(20, elements);
d.Name = "VertexPositionTexture.VertexDeclaration"; VertexDeclaration.Name = "VertexPositionTexture.VertexDeclaration";
VertexDeclaration = d;
} }
public override int GetHashCode() public override int GetHashCode()
@ -44,15 +44,13 @@ namespace ANX.Framework.Graphics
public override string ToString() public override string ToString()
{ {
return string.Format("{{Position:{0} TextureCoordinate:{1}}}", this.Position, this.TextureCoordinate); return String.Format("{{Position:{0} TextureCoordinate:{1}}}", Position, TextureCoordinate);
} }
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj != null && obj.GetType() == this.GetType()) if (obj != null && obj is VertexPositionTexture)
{
return this == (VertexPositionTexture)obj; return this == (VertexPositionTexture)obj;
}
return false; return false;
} }

View File

@ -1,8 +1,5 @@
#region Using Statements
using System; using System;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
@ -11,50 +8,22 @@ namespace ANX.Framework.Graphics
{ {
public struct Viewport public struct Viewport
{ {
#region Private
private int x; private int x;
private int y; private int y;
private int width; private int width;
private int height; private int height;
private float near; private float near;
private float far; private float far;
#endregion
public Viewport(int x, int y, int width, int height) #region Public
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.near = 0f;
this.far = 1f;
}
public Viewport(Rectangle bounds)
{
this.x = bounds.X;
this.y = bounds.Y;
this.width = bounds.Width;
this.height = bounds.Height; this.near = 0f;
this.far = 1f;
}
public Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world)
{
throw new NotImplementedException();
}
public Vector3 Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world)
{
throw new NotImplementedException();
}
public float AspectRatio public float AspectRatio
{ {
get get
{ {
if (this.width != 0 && this.height != 0) if (this.width != 0 && this.height != 0)
{
return (float)width / (float)height; return (float)width / (float)height;
}
return 0f; return 0f;
} }
@ -115,7 +84,8 @@ namespace ANX.Framework.Graphics
{ {
get get
{ {
throw new NotImplementedException(); // On Windows Xna simply returns the rectangle. Check if we need any other implementation on other platforms!
return new Rectangle(x, y, width, height);
} }
} }
@ -154,10 +124,81 @@ namespace ANX.Framework.Graphics
this.y = value; this.y = value;
} }
} }
#endregion
#region Constructor
public Viewport(int x, int y, int width, int height)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.near = 0f;
this.far = 1f;
}
public Viewport(Rectangle bounds)
{
this.x = bounds.X;
this.y = bounds.Y;
this.width = bounds.Width;
this.height = bounds.Height;
this.near = 0f;
this.far = 1f;
}
#endregion
#region Project
public Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world)
{
Matrix wv;
Matrix wvp;
Matrix.Multiply(ref world, ref view, out wv);
Matrix.Multiply(ref wv, ref projection, out wvp);
Vector3 vector;
Vector3.Transform(ref source, ref wvp, out vector);
float num = source.X * wvp.M14 + source.Y * wvp.M24 + source.Z * wvp.M34 + wvp.M44;
if (WithinEpsilon(num) == false)
vector /= num;
vector.X = (vector.X + 1f) * 0.5f * (float)width + (float)x;
vector.Y = (-vector.Y + 1f) * 0.5f * (float)height + (float)y;
vector.Z = vector.Z * (far - near) + near;
return vector;
}
#endregion
#region Unproject
public Vector3 Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world)
{
Matrix wv;
Matrix wvp;
Matrix.Multiply(ref world, ref view, out wv);
Matrix.Multiply(ref wv, ref projection, out wvp);
wvp = Matrix.Invert(wvp);
source.X = (source.X - (float)x) / (float)width * 2f - 1f;
source.Y = -((source.Y - (float)y) / (float)height * 2f - 1f);
source.Z = (source.Z - near) / (far - near);
Vector3 vector;
Vector3.Transform(ref source, ref wvp, out vector);
float num = source.X * wvp.M14 + source.Y * wvp.M24 + source.Z * wvp.M34 + wvp.M44;
return (WithinEpsilon(num) == false) ? vector /= num : vector;
}
#endregion
#region WithinEpsilon
private static bool WithinEpsilon(float num)
{
num -= 1f;
return -1.401298E-45f <= num && num <= 1.401298E-45f;
}
#endregion
#region ToString
public override string ToString() public override string ToString()
{ {
return String.Format("Viewport X: {0} Y:{1} Width: {2} Height: {3} AspectRatio: {4} MinDepth: {5} MaxDepth: {6}", X, Y, Width, Height, AspectRatio, MinDepth, MaxDepth); return String.Format("Viewport X: {0} Y:{1} Width: {2} Height: {3} AspectRatio: {4} MinDepth: {5} MaxDepth: {6}",
X, Y, Width, Height, AspectRatio, MinDepth, MaxDepth);
} }
#endregion
} }
} }