本文整理匯總了C#中SharpDX.Direct3D9.Texture類的典型用法代碼示例。如果您正苦於以下問題:C# Texture類的具體用法?C# Texture怎麽用?C# Texture使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Texture類屬於SharpDX.Direct3D9命名空間,在下文中一共展示了Texture類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Render
public override Texture Render(PostProcessStage postProcessStage, Texture source, Texture availableRenderTarget)
{
switch (postProcessStage)
{
case PostProcessStage.AlphaBlended:
{
//BlendState.Opaque.Apply();
//DepthStencilState.None.Apply();
//RasterizerState.CullCounterClockwise.Apply();
//MyRender.SetRenderTarget(availableRenderTarget, null);
//MyEffectVignetting effectVignetting = MyRender.GetEffect(MyEffects.Vignetting) as MyEffectVignetting;
//effectVignetting.SetInputTexture(source);
//effectVignetting.SetHalfPixel(source.GetLevelDescription(0).Width, source.GetLevelDescription(0).Height);
//effectVignetting.SetVignettingPower(VignettingPower);
//effectVignetting.EnableVignetting();
//MyRender.GetFullscreenQuad().Draw(effectVignetting);
return availableRenderTarget;
}
}
return source;
}
示例2: Render
/// <summary>
/// Render method is called directly by renderer. Depending on stage, post process can do various things
/// </summary>
/// <param name="postProcessStage">Stage indicating in which part renderer currently is.</param>public override void RenderAfterBlendLights()
public override Texture Render(PostProcessStage postProcessStage, Texture source, Texture availableRenderTarget)
{
switch (postProcessStage)
{
case PostProcessStage.AlphaBlended:
{
BlendState.Opaque.Apply();
DepthStencilState.None.Apply();
RasterizerState.CullCounterClockwise.Apply();
MyRender.SetRenderTarget(availableRenderTarget, null);
MyEffectAntiAlias effectAntiAlias = MyRender.GetEffect(MyEffects.AntiAlias) as MyEffectAntiAlias;
effectAntiAlias.SetDiffuseTexture(source);
effectAntiAlias.SetHalfPixel(source.GetLevelDescription(0).Width, source.GetLevelDescription(0).Height);
if (MyRenderConstants.RenderQualityProfile.EnableFXAA)
effectAntiAlias.ApplyFxaa();
else
return source; // Nothing to do, return source
MyRender.GetFullscreenQuad().Draw(effectAntiAlias);
return availableRenderTarget;
}
break;
}
return source;
}
示例3: Poll
public Poll(Device device, float height)
{
_height = height;
Texture = Texture ?? Texture.FromFile(device, "Assets/Textures/poll.png");
TextureTop = TextureTop ?? Texture.FromFile(device, "Assets/Textures/poll_top.png");
_topFlagLocation = new Vector3(-0.5f, 0.25f + (height / 2 - 1.5f), 0);
_flag = Add(new Sprite(device, "flag", 1));
_flag.Translate(_topFlagLocation);
Add(new GameObject
{
new MeshRenderer
{
Mesh = new TexturedCube(device, 0.5f, 0.5f, 0.5f, DefaultUV, DefaultUV, DefaultUV, DefaultUV, DefaultUV, DefaultUV),
Material = new TextureMaterial(TextureTop, false)
}
}).Translate(0, 0.25f + (height / 2 - 0.5f), 0);
Add(new GameObject
{
new MeshRenderer
{
Mesh = new TexturedCube(device, 0.2f, height - 0.5f, 0.2f, DefaultUV, DefaultUV, DefaultUV, DefaultUV, DefaultUV, DefaultUV),
Material = new TextureMaterial(Texture, false)
}
}).Translate(0, -0.25f, 0);
Add(new Trigger(SlideDown, 0.5f, height, 0.5f, Vector3.Zero));
}
示例4: Render
public override Texture Render(PostProcessStage postProcessStage, Texture source, Texture availableRenderTarget)
{
switch (postProcessStage)
{
case PostProcessStage.AlphaBlended:
{
BlendState.Opaque.Apply();
DepthStencilState.None.Apply();
RasterizerState.CullCounterClockwise.Apply();
MyRender.SetRenderTarget(availableRenderTarget, null);
MyEffectChromaticAberration effectChromaAberr = MyRender.GetEffect(MyEffects.ChromaticAberration) as MyEffectChromaticAberration;
effectChromaAberr.SetInputTexture(source);
effectChromaAberr.SetHalfPixel(source.GetLevelDescription(0).Width, source.GetLevelDescription(0).Height);
effectChromaAberr.SetAspectRatio((float)source.GetLevelDescription(0).Width / (float)source.GetLevelDescription(0).Height);
effectChromaAberr.SetDistortionLens(DistortionLens);
effectChromaAberr.SetDistortionCubic(DistortionCubic);
effectChromaAberr.SetDistortionWeights(ref DistortionWeights);
effectChromaAberr.Enable();
MyRender.GetFullscreenQuad().Draw(effectChromaAberr);
return availableRenderTarget;
}
}
return source;
}
示例5: CCHero
public CCHero(string name, CCBuff ccBuff, CCSpell ccSpells, Texture icon)
{
this.Name = name;
this.CCBuff = ccBuff;
this.CCSpells = ccSpells;
this.Icon = icon;
}
示例6: CreateTexture
public unsafe Texture CreateTexture(int index)
{
if (!_fileIndex.FilesExist)
return null;
int length, extra;
bool patched;
Stream stream = _fileIndex.Seek(index, out length, out extra, out patched);
if (stream == null)
return null;
int size = extra == 0 ? 64 : 128;
Texture texture = new Texture(_device, size, size, 0, Usage.None, Format.A1R5G5B5, Pool.Managed);
DataRectangle rect = texture.LockRectangle(0, LockFlags.None);
BinaryReader bin = new BinaryReader(stream);
ushort* line = (ushort*)rect.DataPointer;
int delta = rect.Pitch >> 1;
for (int y = 0; y < size; ++y, line += delta)
{
ushort* cur = line;
ushort* end = cur + size;
while (cur < end)
*cur++ = (ushort)(bin.ReadUInt16() ^ 0x8000);
}
texture.UnlockRectangle(0);
return texture;
}
示例7: SaveScreenshotUserFolder
public static void SaveScreenshotUserFolder(Texture texture2D, string name)
{
var datetimePrefix = MyValueFormatter.GetFormatedDateTimeForFilename(DateTime.Now);
var folder = Path.Combine(MyFileSystemUtils.GetApplicationUserDataFolder(), "Screenshots\\");
var path = Path.Combine(folder, "MinerWars_" + MyEnumsToStrings.CameraDirection[(int)MyCamera.ActualCameraDirection] + "_" + datetimePrefix + "_" + name);
SaveScreenshot(texture2D, path);
}
示例8: Render
/// <summary>
/// Render method is called directly by renderer. Depending on stage, post process can do various things
/// </summary>
/// <param name="postProcessStage">Stage indicating in which part renderer currently is.</param>public override void RenderAfterBlendLights()
public override Texture Render(PostProcessStage postProcessStage, Texture source, Texture availableRenderTarget)
{
switch (postProcessStage)
{
case PostProcessStage.HDR:
{
MyMinerGame.SetRenderTarget(availableRenderTarget, null);
MyEffectContrast effectContrast = MyRender.GetEffect(MyEffects.Contrast) as MyEffectContrast;
effectContrast.SetDiffuseTexture(source);
effectContrast.SetHalfPixel(MyUtils.GetHalfPixel(source.GetLevelDescription(0).Width, source.GetLevelDescription(0).Height));
effectContrast.SetContrast(Contrast);
effectContrast.SetHue(Hue);
effectContrast.SetSaturation(Saturation);
MyGuiManager.GetFullscreenQuad().Draw(effectContrast);
return availableRenderTarget;
}
break;
}
return source;
}
示例9: SkillBar
public SkillBar(Menu config)
{
MenuSkillBar = config.AddSubMenu(new Menu("Cooldown Tracker", "SkillBar"));
MenuSkillBar.AddItem(new MenuItem("OnAllies", "On Allies").SetValue(false));
MenuSkillBar.AddItem(new MenuItem("OnEnemies", "On Enemies").SetValue(true));
Sprite = new Sprite(Drawing.Direct3DDevice);
HudTexture = Texture.FromMemory(
Drawing.Direct3DDevice, (byte[]) new ImageConverter().ConvertTo(Resources.main, typeof(byte[])), 127, 41,
0, Usage.None, Format.A1, Pool.Managed, Filter.Default, Filter.Default, 0);
FrameLevelTexture = Texture.FromMemory(
Drawing.Direct3DDevice, (byte[]) new ImageConverter().ConvertTo(Resources.spell_level, typeof(byte[])),
2, 3, 0, Usage.None, Format.A1, Pool.Managed, Filter.Default, Filter.Default, 0);
ButtonRedTexture = Texture.FromMemory(
Drawing.Direct3DDevice, (byte[]) new ImageConverter().ConvertTo(Resources.disable, typeof(byte[])), 14,
14, 0, Usage.None, Format.A1, Pool.Managed, Filter.Default, Filter.Default, 0);
SmallText = new Font(
Drawing.Direct3DDevice,
new FontDescription
{
FaceName = "Calibri",
Height = 13,
OutputPrecision = FontPrecision.Default,
Quality = FontQuality.Default,
});
AppDomain.CurrentDomain.DomainUnload += DomainUnload;
AppDomain.CurrentDomain.ProcessExit += DomainUnload;
CustomEvents.Game.OnGameLoad += Game_OnGameLoad;
}
示例10: SetRenderTargetDX10
public void SetRenderTargetDX10(SharpDX.Direct3D10.Texture2D renderTarget)
{
if (RenderTarget != null)
{
RenderTarget = null;
base.Lock();
base.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
base.Unlock();
}
if (renderTarget == null)
return;
if (!IsShareable(renderTarget))
throw new ArgumentException("Texture must be created with ResourceOptionFlags.Shared");
Format format = DX10ImageSource.TranslateFormat(renderTarget);
if (format == Format.Unknown)
throw new ArgumentException("Texture format is not compatible with OpenSharedResource");
IntPtr handle = GetSharedHandle(renderTarget);
if (handle == IntPtr.Zero)
throw new ArgumentNullException("Handle");
RenderTarget = new Texture(DX10ImageSource.D3DDevice, renderTarget.Description.Width, renderTarget.Description.Height, 1, Usage.RenderTarget, format, Pool.Default, ref handle);
using (Surface surface = RenderTarget.GetSurfaceLevel(0))
{
base.Lock();
base.SetBackBuffer(D3DResourceType.IDirect3DSurface9, surface.NativePointer);
base.Unlock();
}
}
示例11: BlurComponent
public BlurComponent(Device graphics, int size)
{
_graphics = graphics;
Dims = size;
Format = Format.A8R8G8B8;
_sampleOffsetsHoriz = new Vector4D[SampleCount];
_sampleOffsetsVert = new Vector4D[SampleCount];
_sampleWeightsHoriz = new float[SampleCount];
_sampleWeightsVert = new float[SampleCount];
int width = Dims - 5;
int height = Dims - 5;
SetBlurEffectParameters(1.0f / width, 0, ref _sampleOffsetsHoriz, ref _sampleWeightsHoriz);
SetBlurEffectParameters(0, 1.0f / height, ref _sampleOffsetsVert, ref _sampleWeightsVert);
_effect = new GaussianBlurEffect(_graphics);
OutputTexture = new Texture(_graphics, Dims, Dims, 1, Usage.RenderTarget, Format, Pool.Default);
_intermediateTexture = new Texture(_graphics, Dims, Dims, 1, Usage.RenderTarget, Format, Pool.Default);
_sprite = new Sprite(_graphics);
}
示例12: Render
public override void Render(RenderContext parentRenderContext)
{
Effect effect = Effect;
if (!IsVisible || effect == null)
return;
RectangleF bounds = ActualBounds;
if (bounds.Width <= 0 || bounds.Height <= 0)
return;
Matrix? layoutTransformMatrix = LayoutTransform == null ? new Matrix?() : LayoutTransform.GetTransform();
Matrix? renderTransformMatrix = RenderTransform == null ? new Matrix?() : RenderTransform.GetTransform();
RenderContext localRenderContext = parentRenderContext.Derive(bounds, layoutTransformMatrix, renderTransformMatrix, RenderTransformOrigin, Opacity);
_inverseFinalTransform = Matrix.Invert(localRenderContext.Transform);
DeviceEx device = SkinContext.Device;
Surface backBuffer = device.GetRenderTarget(0);
SurfaceDescription desc = backBuffer.Description;
SurfaceDescription? textureDesc = _texture == null ? new SurfaceDescription?() : _texture.GetLevelDescription(0);
if (!textureDesc.HasValue || textureDesc.Value.Width != desc.Width || textureDesc.Value.Height != desc.Height)
{
TryDispose(ref _texture);
_texture = new Texture(device, desc.Width, desc.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
}
using (Surface destSurfaceRef = _texture.GetSurfaceLevel(0))
device.StretchRectangle(backBuffer, destSurfaceRef, TextureFilter.None);
UpdateEffectMask(effect, localRenderContext.OccupiedTransformedBounds, desc.Width, desc.Height, localRenderContext.ZOrder);
if (effect.BeginRender(_texture, new RenderContext(Matrix.Identity, 1.0d, bounds, localRenderContext.ZOrder)))
{
_effectContext.Render(0);
effect.EndRender();
}
}
示例13: SetRenderTarget
public void SetRenderTarget(CubeTexture environmentRT, CubeTexture ambientRT, Texture fullSizeRT)
{
m_setup.RenderTargets[0] = fullSizeRT;
m_environmentRT = environmentRT;
m_ambientRT = ambientRT;
m_fullSizeRT = fullSizeRT;
}
示例14: LoadContent
public override void LoadContent()
{
//int size = GetSquareDimension();
int size = 256;
m_render = new Texture(MyRender.GraphicsDevice, size, size, 1, Usage.Dynamic, Format.X8R8G8B8, Pool.Default);
m_update = new Texture(MyRender.GraphicsDevice, size, size, 1, Usage.Dynamic, Format.X8R8G8B8, Pool.Default);
UpdateBones();
}
示例15: CreateTexture
public unsafe Texture CreateTexture(int index)
{
index &= 0x3FFF;
index += 0x4000;
int length, extra;
bool patched;
Stream stream = _fileIndex.Seek(index, out length, out extra, out patched);
if (stream == null)
return null;
BinaryReader bin = new BinaryReader(stream);
bin.ReadInt32(); // Unknown
int width = bin.ReadInt16();
int height = bin.ReadInt16();
if (width <= 0 || height <= 0)
return null;
int[] lookups = new int[height];
int start = (int)bin.BaseStream.Position + (height * 2);
for (int i = 0; i < height; ++i)
lookups[i] = (int)(start + (bin.ReadUInt16() * 2));
Texture texture = new Texture(_device, width, height, 0, Usage.None, Format.A1R5G5B5, Pool.Managed);
DataRectangle rect = texture.LockRectangle(0, LockFlags.None);
ushort* line = (ushort*)rect.DataPointer;
int delta = rect.Pitch >> 1;
for (int y = 0; y < height; ++y, line += delta)
{
bin.BaseStream.Seek(lookups[y], SeekOrigin.Begin);
ushort* cur = line;
ushort* end;
int xOffset, xRun;
while (((xOffset = bin.ReadUInt16()) + (xRun = bin.ReadUInt16())) != 0)
{
cur += xOffset;
end = cur + xRun;
while (cur < end)
*cur++ = (ushort)(bin.ReadUInt16() ^ 0x8000);
}
}
texture.UnlockRectangle(0);
return texture;
}