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

174 lines
4.9 KiB
C#

#region Using Statements
using System;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA;
using SharpDX.Direct3D10;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace ANX.RenderSystem.Windows.DX10
{
public class SamplerState_DX10 : INativeSamplerState
{
#region Private Members
private SamplerStateDescription description;
private SharpDX.Direct3D10.SamplerState nativeSamplerState;
private bool nativeSamplerStateDirty;
private bool bound;
#endregion // Private Members
public SamplerState_DX10()
{
this.description = new SamplerStateDescription();
this.nativeSamplerStateDirty = true;
}
public void Apply(GraphicsDevice graphicsDevice, int index)
{
GraphicsDeviceWindowsDX10 gdx10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10;
Device device = gdx10.NativeDevice;
UpdateNativeSamplerState(device);
this.bound = true;
device.PixelShader.SetSampler(index, this.nativeSamplerState);
}
public void Release()
{
this.bound = false;
}
public bool IsBound
{
get
{
return this.bound;
}
}
public ANX.Framework.Graphics.TextureAddressMode AddressU
{
set
{
SharpDX.Direct3D10.TextureAddressMode mode = FormatConverter.Translate(value);
if (description.AddressU != mode)
{
description.AddressU = mode;
nativeSamplerStateDirty = true;
}
}
}
public ANX.Framework.Graphics.TextureAddressMode AddressV
{
set
{
SharpDX.Direct3D10.TextureAddressMode mode = FormatConverter.Translate(value);
if (description.AddressV != mode)
{
description.AddressV = mode;
nativeSamplerStateDirty = true;
}
}
}
public ANX.Framework.Graphics.TextureAddressMode AddressW
{
set
{
SharpDX.Direct3D10.TextureAddressMode mode = FormatConverter.Translate(value);
if (description.AddressW != mode)
{
description.AddressW = mode;
nativeSamplerStateDirty = true;
}
}
}
public TextureFilter Filter
{
set
{
SharpDX.Direct3D10.Filter filter = FormatConverter.Translate(value);
if (description.Filter != filter)
{
description.Filter = filter;
nativeSamplerStateDirty = true;
}
}
}
public int MaxAnisotropy
{
set
{
if (description.MaximumAnisotropy != value)
{
description.MaximumAnisotropy = value;
nativeSamplerStateDirty = true;
}
}
}
public int MaxMipLevel
{
set
{
if (description.MaximumLod != value)
{
description.MaximumLod = value;
nativeSamplerStateDirty = true;
}
}
}
public float MipMapLevelOfDetailBias
{
set
{
if (description.MipLodBias != value)
{
description.MipLodBias = value;
nativeSamplerStateDirty = true;
}
}
}
public void Dispose()
{
if (this.nativeSamplerState != null)
{
this.nativeSamplerState.Dispose();
this.nativeSamplerState = null;
}
}
private void UpdateNativeSamplerState(Device device)
{
if (this.nativeSamplerStateDirty == true || this.nativeSamplerState == null)
{
if (this.nativeSamplerState != null)
{
this.nativeSamplerState.Dispose();
this.nativeSamplerState = null;
}
this.nativeSamplerState = new SharpDX.Direct3D10.SamplerState(device, ref this.description);
this.nativeSamplerStateDirty = false;
}
}
}
}