本文整理匯總了C#中SharpDX.Direct3D9.Device.GetBackBuffer方法的典型用法代碼示例。如果您正苦於以下問題:C# Device.GetBackBuffer方法的具體用法?C# Device.GetBackBuffer怎麽用?C# Device.GetBackBuffer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SharpDX.Direct3D9.Device
的用法示例。
在下文中一共展示了Device.GetBackBuffer方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: HandleCaptureRequest
private void HandleCaptureRequest(Device device)
{
try
{
for (int i = 0; i < BUFFERS; i++)
{
bool tmp;
if (this.issuedQueries[i] && this.queries[i].GetData(out tmp, false))
{
this.issuedQueries[i] = false;
try
{
var lockedRect = this.surfaces[i].LockRectangle(LockFlags.ReadOnly);
this.surfaceDataPointer = lockedRect.DataPointer;
this.currentSurface = i;
this.surfaceLocked[i] = true;
}
catch (Exception ex)
{
DebugMessage(ex.ToString());
}
}
}
if (previousRequestId != null || lastRequestId != null)
{
this.previousRequestId = null;
int nextCapture = (curCapture == BUFFERS - 1) ? 0 : (curCapture + 1);
var sourceTexture = copySurfaces[curCapture];
try
{
using (var backbuffer = device.GetBackBuffer(0, 0))
{
device.StretchRectangle(backbuffer, sourceTexture, TextureFilter.None);
}
if (copyWait < BUFFERS - 1)
{
copyWait++;
}
else
{
var prevSourceTexture = copySurfaces[nextCapture];
var targetTexture = surfaces[nextCapture];
if (this.surfaceLocked[nextCapture])
{
lock (this.surfaceLocks[nextCapture])
{
this.surfaces[nextCapture].UnlockRectangle();
this.surfaceLocked[nextCapture] = false;
}
}
try
{
device.GetRenderTargetData(prevSourceTexture, targetTexture);
}
catch (Exception ex)
{
DebugMessage(ex.ToString());
}
this.queries[nextCapture].Issue(Issue.End);
this.issuedQueries[nextCapture] = true;
}
}
catch (Exception ex)
{
this.DebugMessage(ex.ToString());
}
curCapture = nextCapture;
}
}
catch (Exception e)
{
this.DebugMessage(e.ToString());
}
}
示例2: HandleCaptureRequest
private void HandleCaptureRequest(Device device)
{
try
{
bool tmp;
if (this.queryIssued && this.query.GetData(out tmp, false))
{
this.queryIssued = false;
var lockedRect = this.surface.LockRectangle(LockFlags.ReadOnly);
this.surfaceDataPointer = lockedRect.DataPointer;
this.surfaceLocked = true;
this.copyEvent.Set();
}
using (var backbuffer = device.GetBackBuffer(0, 0))
{
device.StretchRectangle(backbuffer, this.renderTarget, TextureFilter.None);
}
if (this.surfaceLocked)
{
lock (this.renderTargetLock)
{
if (this.surfaceLocked)
{
this.surface.UnlockRectangle();
this.surfaceLocked = false;
}
}
}
try
{
var cooplevel = device.TestCooperativeLevel();
if (cooplevel.Code == ResultCode.Success.Code)
{
device.GetRenderTargetData(this.renderTarget, this.surface);
this.query.Issue(Issue.End);
this.queryIssued = true;
}
else
{
this.DebugMessage(string.Format("DirectX Error: TestCooperativeLevel = {0}", cooplevel.Code));
}
}
catch (Exception ex)
{
this.DebugMessage(ex.ToString());
}
}
catch (Exception e)
{
this.DebugMessage(e.ToString());
}
}
示例3: HandleCaptureRequest
private void HandleCaptureRequest(Device device)
{
try
{
if (_killThread)
{
return;
}
for (var i = 0; i < BUFFERS; i++)
{
bool tmp;
if (_issuedQueries[i]
&& _queries[i].GetData(out tmp, false))
{
_issuedQueries[i] = false;
var lockedRect = _surfaces[i].LockRectangle(LockFlags.ReadOnly);
_surfaceDataPointer = lockedRect.DataPointer;
_currentSurface = i;
_surfaceLocked[i] = true;
_copyReadySignal.Set();
}
}
if (_captureWaitHandle.WaitOne(0)
|| _copyWait < BUFFERS - 1)
{
var nextCapture = (_curCapture == BUFFERS - 1) ? 0 : (_curCapture + 1);
try
{
using (var backbuffer = device.GetBackBuffer(0, 0))
{
var sourceTexture = _copySurfaces[_curCapture];
device.StretchRectangle(backbuffer, sourceTexture, TextureFilter.None);
}
if (_copyWait < BUFFERS - 1)
{
_copyWait++;
}
else
{
var prevSourceTexture = _copySurfaces[nextCapture];
var targetTexture = _surfaces[nextCapture];
if (_surfaceLocked[nextCapture])
{
lock (_surfaceLocks[nextCapture])
{
_surfaces[nextCapture].UnlockRectangle();
_surfaceLocked[nextCapture] = false;
}
}
try
{
device.GetRenderTargetData(prevSourceTexture, targetTexture);
}
catch (Exception ex)
{
DebugMessage(ex.ToString());
}
_queries[nextCapture].Issue(Issue.End);
_issuedQueries[nextCapture] = true;
}
}
catch (Exception ex)
{
DebugMessage(ex.ToString());
}
finally
{
_captureWaitHandle.Reset();
_curCapture = nextCapture;
}
}
}
catch (Exception e)
{
DebugMessage(e.ToString());
}
}
示例4: HandleCaptureRequest
private void HandleCaptureRequest(Device device)
{
if (Request == null)
{
return;
}
try
{
bool tmp;
if (queryIssued && query.GetData(out tmp, false))
{
queryIssued = false;
var lockedRect = surface.LockRectangle(LockFlags.ReadOnly);
surfaceDataPointer = lockedRect.DataPointer;
surfaceLocked = true;
new Thread(HandleCaptureRequestThread).Start();
}
using (var backbuffer = device.GetBackBuffer(0, 0))
{
device.StretchRectangle(backbuffer, renderTarget, TextureFilter.None);
}
if (surfaceLocked)
{
lock (renderTargetLock)
{
if (!this.surfaceLocked)
{
return;
}
this.surface.UnlockRectangle();
this.surfaceLocked = false;
}
}
try
{
device.GetRenderTargetData(renderTarget, surface);
query.Issue(Issue.End);
queryIssued = true;
}
catch (Exception ex)
{
DebugMessage(ex.ToString());
}
}
catch (Exception e)
{
DebugMessage(e.ToString());
}
}
示例5: DoCaptureRenderTarget
private void DoCaptureRenderTarget(Device device, string hook)
{
try
{
if (isCapturing && signalEnd.WaitOne(0))
{
ClearD3D9Data();
isCapturing = false;
stopRequested = true;
}
if (!isCapturing)
{
return;
}
if (!bHasTextures)
{
using (Surface backbuffer = device.GetRenderTarget(0))
{
copyData.format = (int)backbuffer.Description.Format;
copyData.width = backbuffer.Description.Width;
copyData.height = backbuffer.Description.Height;
}
DoD3DHooks(device);
}
if (!bHasTextures)
{
return;
}
long timeVal = DateTime.Now.Ticks;
long frameTime = 1000000 / targetFps; // lock at 30 fps
if (frameTime != 0)
{
for (var i = 0; i < NUM_BUFFERS; i++)
{
if (issuedQueries[i])
{
bool tmp;
if (queries[i].GetData(out tmp, false))
{
issuedQueries[i] = false;
Surface targetTexture = textures[i];
try
{
var lockedRect = targetTexture.LockRectangle(LockFlags.ReadOnly);
pCopyData = lockedRect.DataPointer;
curCPUTexture = i;
lockedTextures[i] = true;
hCopyEvent.Set();
}
catch (Exception ex)
{
DebugMessage(ex.ToString());
}
}
}
}
long timeElapsed = timeVal - lastTime;
if (timeElapsed >= frameTime)
{
lastTime += frameTime;
if (timeElapsed > frameTime * 2)
{
lastTime = timeVal;
}
var nextCapture = (curCapture == NUM_BUFFERS - 1) ? 0 : (curCapture + 1);
Surface sourceTexture = copyD3D9Textures[curCapture];
using (var backbuffer = device.GetBackBuffer(0, 0))
{
device.StretchRectangle(backbuffer, sourceTexture, TextureFilter.None);
}
if (copyWait < (NUM_BUFFERS - 1))
{
copyWait++;
}
else
{
Surface prevSourceTexture = copyD3D9Textures[nextCapture];
Surface targetTexture = textures[nextCapture];
if (lockedTextures[nextCapture])
{
Monitor.Enter(dataMutexes[nextCapture]);
targetTexture.UnlockRectangle();
lockedTextures[nextCapture] = false;
Monitor.Exit(dataMutexes[nextCapture]);
}
try
{
device.GetRenderTargetData(prevSourceTexture, targetTexture);
//.........這裏部分代碼省略.........