本文整理汇总了C#中SharpDX.Direct3D9.Device.GetSwapChain方法的典型用法代码示例。如果您正苦于以下问题:C# Device.GetSwapChain方法的具体用法?C# Device.GetSwapChain怎么用?C# Device.GetSwapChain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpDX.Direct3D9.Device
的用法示例。
在下文中一共展示了Device.GetSwapChain方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupData
private void SetupData(Device device)
{
this.DebugMessage("SetupData called");
using (SwapChain swapChain = device.GetSwapChain(0))
{
PresentParameters pp = swapChain.PresentParameters;
this.width = pp.BackBufferWidth;
this.height = pp.BackBufferHeight;
this.format = pp.BackBufferFormat;
this.DebugMessage(string.Format("D3D9 Setup: w: {0} h: {1} f: {2}", this.width, this.height, this.format));
}
this.hooksStarted = true;
}
示例2: DoCaptureRenderTarget
/// <summary>
/// Implementation of capturing from the render target of the Direct3D9 Device (or DeviceEx)
/// </summary>
/// <param name="device"></param>
void DoCaptureRenderTarget(Device device, string hook)
{
this.Frame();
try
{
#region Screenshot Request
// Single frame capture request
if (this.Request != null)
{
DateTime start = DateTime.Now;
try
{
using (Surface renderTargetTemp = device.GetRenderTarget(0))
{
int width, height;
// TODO: If resizing the captured image is required it can be adjusted here
//if (renderTargetTemp.Description.Width > 1280)
//{
// width = 1280;
// height = (int)Math.Round((renderTargetTemp.Description.Height * (1280.0 / renderTargetTemp.Description.Width)));
//}
//else
{
width = renderTargetTemp.Description.Width;
height = renderTargetTemp.Description.Height;
}
// First ensure we have a Surface to the render target data into
if (_renderTarget == null)
{
// Create offscreen surface to use as copy of render target data
using (SwapChain sc = device.GetSwapChain(0))
{
_renderTarget = Surface.CreateOffscreenPlain(device, width, height, sc.PresentParameters.BackBufferFormat, Pool.SystemMemory);
}
}
// Create our resolved surface (resizing if necessary and to resolve any multi-sampling)
using (Surface resolvedSurface = Surface.CreateRenderTarget(device, width, height, renderTargetTemp.Description.Format, MultisampleType.None, 0, false))
{
// Resize from Render Surface to resolvedSurface
device.StretchRectangle(renderTargetTemp, resolvedSurface, TextureFilter.None);
// Get Render Data
device.GetRenderTargetData(resolvedSurface, _renderTarget);
}
}
if (Request != null)
ProcessRequest();
}
finally
{
// We have completed the request - mark it as null so we do not continue to try to capture the same request
// Note: If you are after high frame rates, consider implementing buffers here to capture more frequently
// and send back to the host application as needed. The IPC overhead significantly slows down
// the whole process if sending frame by frame.
Request = null;
}
DateTime end = DateTime.Now;
this.DebugMessage(hook + ": Capture time: " + (end - start).ToString());
}
#endregion
if (this.Config.ShowOverlay)
{
#region Draw frame rate
// TODO: font needs to be created and then reused, not created each frame!
using (SharpDX.Direct3D9.Font font = new SharpDX.Direct3D9.Font(device, new FontDescription()
{
Height = 16,
FaceName = "Arial",
Italic = false,
Width = 0,
MipLevels = 1,
CharacterSet = FontCharacterSet.Default,
OutputPrecision = FontPrecision.Default,
Quality = FontQuality.Antialiased,
PitchAndFamily = FontPitchAndFamily.Default | FontPitchAndFamily.DontCare,
Weight = FontWeight.Bold
}))
{
if (this.FPS.GetFPS() >= 1)
{
font.DrawText(null, String.Format("{0:N0} fps", this.FPS.GetFPS()), 5, 5, SharpDX.Color.Red);
}
if (this.TextDisplay != null && this.TextDisplay.Display)
{
font.DrawText(null, this.TextDisplay.Text, 5, 25, new SharpDX.ColorBGRA(255, 0, 0, (byte)Math.Round((Math.Abs(1.0f - TextDisplay.Remaining) * 255f))));
//.........这里部分代码省略.........
示例3: DoCaptureRenderTarget
/// <summary>
/// Implementation of capturing from the render target of the Direct3D9 Device (or DeviceEx)
/// </summary>
/// <param name="device"></param>
void DoCaptureRenderTarget(Device device, string hook)
{
try
{
#region Screenshot Request
// Single frame capture request
if (this.Request != null)
{
DateTime start = DateTime.Now;
try
{
using (Surface renderTargetTemp = device.GetRenderTarget(0))
{
int width, height;
// TODO: If resizing the captured image is required it can be adjusted here
//if (renderTargetTemp.Description.Width > 1280)
//{
// width = 1280;
// height = (int)Math.Round((renderTargetTemp.Description.Height * (1280.0 / renderTargetTemp.Description.Width)));
//}
//else
{
width = renderTargetTemp.Description.Width;
height = renderTargetTemp.Description.Height;
}
// First ensure we have a Surface to the render target data into
if (_renderTarget == null)
{
// Create offscreen surface to use as copy of render target data
using (SwapChain sc = device.GetSwapChain(0))
{
_renderTarget = Surface.CreateOffscreenPlain(device, width, height,
sc.PresentParameters.BackBufferFormat, Pool.SystemMemory);
}
}
// Create our resolved surface (resizing if necessary and to resolve any multi-sampling)
using (
Surface resolvedSurface = Surface.CreateRenderTarget(device, width, height,
renderTargetTemp.Description.Format, MultisampleType.None, 0, false))
{
// Resize from Render Surface to resolvedSurface
device.StretchRectangle(renderTargetTemp, resolvedSurface, TextureFilter.None);
// Get Render Data
device.GetRenderTargetData(resolvedSurface, _renderTarget);
}
}
if (Request != null)
ProcessRequest();
}
finally
{
// We have completed the request - mark it as null so we do not continue to try to capture the same request
// Note: If you are after high frame rates, consider implementing buffers here to capture more frequently
// and send back to the host application as needed. The IPC overhead significantly slows down
// the whole process if sending frame by frame.
Request = null;
}
DateTime end = DateTime.Now;
this.DebugMessage(hook + ": Capture time: " + (end - start).ToString());
}
#endregion
if (this.Config.ShowOverlay)
{
// SHIT
this.Frame();
#region Draw frame rate
// TODO: font needs to be created and then reused, not created each frame!
using (var font = new SharpDX.Direct3D9.Font(device, new FontDescription()
{
Height = 26,
FaceName = "Quartz MS",
Italic = false,
Width = 0,
MipLevels = 1,
CharacterSet = FontCharacterSet.Default,
OutputPrecision = FontPrecision.Default,
Quality = FontQuality.Antialiased,
PitchAndFamily = FontPitchAndFamily.Default | FontPitchAndFamily.DontCare,
Weight = FontWeight.Normal
}))
{
// Make a Texture from a file...
//.........这里部分代码省略.........
示例4: SetupData
private void SetupData(Device device)
{
DebugMessage("SetupData called");
using (var swapChain = device.GetSwapChain(0))
{
var pp = swapChain.PresentParameters;
_copyData.width = pp.BackBufferWidth;
_copyData.height = pp.BackBufferHeight;
_copyData.format = (int)pp.BackBufferFormat;
DebugMessage(string.Format("D3D9 Setup: w: {0} h: {1} f: {2}", _copyData.width, _copyData.height, pp.BackBufferFormat));
}
_hooksStarted = true;
}
示例5: SetupD3D9
private void SetupD3D9(Device device)
{
try
{
DebugMessage("Setting up Direct3D...");
using (SwapChain swapChain = device.GetSwapChain(0))
{
PresentParameters pp = swapChain.PresentParameters;
this.copyData.width = pp.BackBufferWidth;
this.copyData.height = pp.BackBufferHeight;
this.copyData.format = (int)pp.BackBufferFormat;
DebugMessage(string.Format("D3D9 Setup: w: {0} h: {1} f: {2}", copyData.width, copyData.height, copyData.format));
isCapturing = true;
lastTime = 0;
}
}
catch (Exception ex)
{
DebugMessage(ex.ToString());
}
}