本文整理汇总了C++中IDirect3DSwapChain9::GetPresentParameters方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DSwapChain9::GetPresentParameters方法的具体用法?C++ IDirect3DSwapChain9::GetPresentParameters怎么用?C++ IDirect3DSwapChain9::GetPresentParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirect3DSwapChain9
的用法示例。
在下文中一共展示了IDirect3DSwapChain9::GetPresentParameters方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetGammaRamp
void _stdcall ProxyDevice::GetGammaRamp(D3DGAMMARAMP *a)
{
IDirect3DSwapChain9 *sc;
D3DPRESENT_PARAMETERS pp;
realDevice->GetSwapChain(0, &sc);
sc->GetPresentParameters(&pp);
sc->Release();
if(pp.Windowed)
GetDeviceGammaRamp(GetDC(pp.hDeviceWindow), (void*)a);
else
realDevice->GetGammaRamp(0, a);
}
示例2: set_synchronization
void set_synchronization(bool enable) //TODO: Needs to be rewritten
{
if (d3dmgr == NULL) { return; }
IDirect3DSwapChain9 *sc;
d3dmgr->GetSwapChain(0, &sc);
D3DPRESENT_PARAMETERS d3dpp;
sc->GetPresentParameters(&d3dpp);
if (enable) {
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; //Present the frame immediately
} else {
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; //Present the frame immediately
}
sc->Release();
d3dmgr->Reset(&d3dpp);
}
示例3: WindowResized
void WindowResized() {
if (d3dmgr == NULL) { return; }
IDirect3DSwapChain9 *sc;
d3dmgr->GetSwapChain(0, &sc);
D3DPRESENT_PARAMETERS d3dpp;
sc->GetPresentParameters(&d3dpp);
int ww = window_get_width(),
wh = window_get_height();
d3dpp.BackBufferWidth = ww <= 0 ? 1 : ww;
d3dpp.BackBufferHeight = wh <= 0 ? 1 : wh;
sc->Release();
OnDeviceLost();
d3dmgr->Reset(&d3dpp);
OnDeviceReset();
// clear the window color, viewport does not need set because backbuffer was just recreated
enigma_user::draw_clear(enigma_user::window_get_color());
}
示例4:
//-----------------------------------------------------------------------------
bool D3D9StereoDriverAMD::getPresentParamsAndVerifyStereoSettings()
{
// Verify the swap chain exists
UINT numberOfSwapChains = mDevice->GetNumberOfSwapChains();
if (numberOfSwapChains < 0)
return false;
// Get the first swap chain
IDirect3DSwapChain9* swapChain = NULL;
if (FAILED(mDevice->GetSwapChain(0, &swapChain)))
return false;
// Cache the swap chain presentation parameters and release the swap chain
swapChain->GetPresentParameters(&mSwapChainPresentParameters);
swapChain->Release();
// Check if multi sample type must be set to a value greater than 1 to enable stereo
if (D3DMULTISAMPLE_NONE == mSwapChainPresentParameters.MultiSampleType || D3DMULTISAMPLE_NONMASKABLE == mSwapChainPresentParameters.MultiSampleType)
return false;
return true;
}
示例5:
static bool d3d9_get_swap_desc(D3DPRESENT_PARAMETERS &pp)
{
IDirect3DSwapChain9 *swap = nullptr;
HRESULT hr;
hr = data.device->GetSwapChain(0, &swap);
if (FAILED(hr)) {
hlog_hr("d3d9_get_swap_desc: Failed to get swap chain", hr);
return false;
}
hr = swap->GetPresentParameters(&pp);
swap->Release();
if (FAILED(hr)) {
hlog_hr("d3d9_get_swap_desc: Failed to get "
"presentation parameters", hr);
return false;
}
return true;
}
示例6: display_reset
void display_reset(int samples, bool vsync) {
if (d3dmgr == NULL) { return; }
IDirect3DSwapChain9 *sc;
d3dmgr->GetSwapChain(0, &sc);
D3DPRESENT_PARAMETERS d3dpp;
sc->GetPresentParameters(&d3dpp);
if (vsync) {
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; //Present the frame immediately
} else {
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; //Present the frame immediately
}
d3dpp.MultiSampleType = (D3DMULTISAMPLE_TYPE)((int)D3DMULTISAMPLE_NONE + samples); // Levels of multi-sampling
d3dpp.MultiSampleQuality = 0; //No multi-sampling
if (samples) {
d3dmgr->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
} else {
d3dmgr->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE);
}
sc->Release();
enigma::OnDeviceLost();
d3dmgr->Reset(&d3dpp);
enigma::OnDeviceReset();
}
示例7: CheckIfNewDevice
//Given device to draw to, see if we already have it cached and if not, cache it.
//Also check if we have switched mode (i.e. we were windowed and this device is
//a fullscreen device, or we were full-screen and this is a windowed one).
void CFSXGUI::CheckIfNewDevice(IDirect3DDevice9 *pI)
{
if (!pI)
return;
//Check if already have it
bool bAlreadyHave = false;
if (m_WindowedDeviceDesc.pDevice == pI)
bAlreadyHave = true;
else for (size_t i = 0; !bAlreadyHave && i < m_aFullscreenDevices.size(); i++)
{
if (m_aFullscreenDevices[i].pDevice == pI)
bAlreadyHave = true;
}
//If we don't have it, determine if it's windowed or full-screen device and cache it
if (!bAlreadyHave)
{
IDirect3DSwapChain9 *pISwapChain;
if (FAILED(pI->GetSwapChain(0, &pISwapChain)))
return;
D3DPRESENT_PARAMETERS PP;
if (FAILED(pISwapChain->GetPresentParameters(&PP)))
{
pISwapChain->Release();
return;
}
pISwapChain->Release();
//Windowed?
if (PP.Windowed)
{
//There is only one windowed device, so we don't cache it. Also since we're presenting
//on one, we must be in windowed mode.
m_WindowedDeviceDesc.hWnd = PP.hDeviceWindow; //should always be m_hFSXWin?
m_WindowedDeviceDesc.pDevice = pI;
m_pFullscreenPrimaryDevice = nullptr;
if (!m_bInWindowedMode)
{
m_bInWindowedMode = true;
NotifyDialogsNowWindowed(PP.hDeviceWindow);
}
}
//Fullscreen -- add to list.
else
{
static DeviceDescStruct D;
D.hWnd = PP.hDeviceWindow;
D.pDevice = pI;
m_aFullscreenDevices.push_back(D);
//Currently only draw to device associated with FSX's main window (primary screen on multi-monitor setups).
//We cache the other devices in case we want to drag to other monitors in fullscreen mode, someday.
if (PP.hDeviceWindow == m_hFSXWindow)
{
m_pFullscreenPrimaryDevice = pI;
m_bInWindowedMode = false;
m_WindowedDeviceDesc.pDevice = nullptr; //no longer valid (FSX likely deletes it)
NotifyDialogsNowFullscreen(pI, PP.BackBufferWidth, PP.BackBufferHeight);
}
}
}
return;
}
示例8: DistortAndPresent
bool OculusVR::OnPresent_Direct3D9(IDirect3DDevice9* device)
{
const CHAR* head = "OculusVR::OnPresent_Direct3D9";
if (Renderer == nullptr)
{
Renderer = new Direct3D11Helper(EDirect3D::DXGI0, device);
if (Renderer == nullptr)
{
LVMSG(head, "alloc renderer object failed");
return false;
}
}
if (device != nullptr)
{
IDirect3DSwapChain9* swapChain = nullptr;
D3DPRESENT_PARAMETERS params;
if (FAILED(device->GetSwapChain(0, &swapChain)) ||
FAILED(swapChain->GetPresentParameters(¶ms)))
{
LVERROR(head, "get target window from direct9 device failed");
return false;
}
SGlobalSharedDataInst.SetTargetWindow(params.hDeviceWindow);
SAFE_RELEASE(swapChain);
}
if (!EnsureInitialized(Renderer->GetSwapChain(), false))
{
return false;
}
if (!Renderer->UpdateBuffer_Direct3D9(device))
{
LVMSG(head, "update buffer with direct9 device failed");
return false;
}
//{
// if (RTV == nullptr)
// {
// if (Renderer->CreateRenderTargetView(Renderer->GetBufferDirect3D9Copy(), &RTV))
// {
// return false;
// }
// }
// RenderStateCache cache(Renderer->GetContext());
// cache.Capture();
// D3D11_VIEWPORT vp;
// vp.TopLeftX = Layer[0]->EyeRenderViewport[0].Pos.x;
// vp.TopLeftY = Layer[0]->EyeRenderViewport[0].Pos.y;
// vp.Width = Layer[0]->EyeRenderViewport[0].Size.w;
// vp.Height = Layer[0]->EyeRenderViewport[0].Size.h;
// vp.MinDepth = 0.01f;
// vp.MaxDepth = 10000.f;
// Renderer->GetContext()->RSSetViewports(1, &vp);
// Renderer->GetContext()->OMSetRenderTargets(1, &RTV, nullptr);
// Renderer->UpdateCursor(LVVec3(2.f, 2.f, -1.f), 0.1f, DirectX::XMMatrixIdentity(), DirectX::XMMatrixIdentity(),
// SGlobalSharedDataInst.GetBDrawCursor());
// cache.Restore();
//}
Layer[0]->GetEyePoses();
ID3D11Texture2D* dst = Layer[0]->pEyeRenderTexture[0]->GetBuffer();
if (!Renderer->OutputBuffer_Texture2D_Direct3D9(dst))
{
return false;
}
Layer[0]->Commit(0);
ovrResult ret = DistortAndPresent(1);
if (!OVR_SUCCESS(ret))
{
//LVERROR(head, "submit failed(%d), ...", ret);
return false;
}
return true;
}
示例9: RECT
HRESULT WINAPI D3D9Present(IDirect3DDevice9 *pDev, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) {
D3D9FrameGrabber *d3d9FrameGrabber = D3D9FrameGrabber::getInstance();
Logger *logger = d3d9FrameGrabber->m_logger;
DWORD errorcode;
if (WAIT_OBJECT_0 == (errorcode = WaitForSingleObject(d3d9FrameGrabber->m_syncRunMutex, 0))) {
IPCContext *ipcContext = d3d9FrameGrabber->m_ipcContext;
logger->reportLogDebug(L"D3D9Present");
HRESULT hRes;
RECT newRect = RECT();
IDirect3DSurface9 *pBackBuffer = NULL;
IDirect3DSurface9 *pDemultisampledSurf = NULL;
IDirect3DSurface9 *pOffscreenSurf = NULL;
IDirect3DSwapChain9 *pSc = NULL;
D3DPRESENT_PARAMETERS params;
if(FAILED( hRes = pDev->GetSwapChain(0, &pSc))) {
logger->reportLogError(L"d3d9present couldn't get swapchain. result 0x%x", hRes);
goto end;
}
hRes = pSc->GetPresentParameters(¶ms);
if (FAILED(hRes) || params.Windowed) {
goto end;
}
if(FAILED( hRes = pDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer))) {
goto end;
}
D3DSURFACE_DESC surfDesc;
pBackBuffer->GetDesc(&surfDesc);
hRes = pDev->CreateRenderTarget(
surfDesc.Width, surfDesc.Height,
surfDesc.Format, D3DMULTISAMPLE_NONE, 0, false,
&pDemultisampledSurf, NULL );
if (FAILED(hRes))
{
logger->reportLogError(L"GetFramePrep: FAILED to create demultisampled render target. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format );
goto end;
}
hRes = pDev->StretchRect(pBackBuffer, NULL, pDemultisampledSurf, NULL, D3DTEXF_LINEAR );
if (FAILED(hRes))
{
logger->reportLogError(L"GetFramePrep: StretchRect FAILED for image surfacee. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format );
goto end;
}
hRes = pDev->CreateOffscreenPlainSurface(
surfDesc.Width, surfDesc.Height,
surfDesc.Format, D3DPOOL_SYSTEMMEM,
&pOffscreenSurf, NULL );
if (FAILED(hRes))
{
logger->reportLogError(L"GetFramePrep: FAILED to create image surface. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format );
goto end;
}
hRes = pDev->GetRenderTargetData(pDemultisampledSurf, pOffscreenSurf );
if (FAILED(hRes))
{
logger->reportLogError(L"GetFramePrep: GetRenderTargetData() FAILED for image surfacee. 0x%x, width=%u, height=%u, format=%x", hRes, surfDesc.Width, surfDesc.Height, surfDesc.Format );
goto end;
}
D3DLOCKED_RECT lockedSrcRect;
newRect.right = surfDesc.Width;
newRect.bottom = surfDesc.Height;
hRes = pOffscreenSurf->LockRect( &lockedSrcRect, &newRect, 0);
if (FAILED(hRes))
{
logger->reportLogError(L"GetFramePrep: FAILED to lock source rect. (0x%x)", hRes );
goto end;
}
ipcContext->m_memDesc.width = surfDesc.Width;
ipcContext->m_memDesc.height = surfDesc.Height;
ipcContext->m_memDesc.rowPitch = lockedSrcRect.Pitch;
ipcContext->m_memDesc.frameId++;
ipcContext->m_memDesc.format = getCompatibleBufferFormat(surfDesc.Format);
DWORD errorcode;
if (WAIT_OBJECT_0 == (errorcode = WaitForSingleObject(ipcContext->m_hMutex, 0))) {
// reportLog(EVENTLOG_INFORMATION_TYPE, L"d3d9 writing description to mem mapped file");
memcpy(ipcContext->m_pMemMap, &(ipcContext->m_memDesc), sizeof (ipcContext->m_memDesc));
// reportLog(EVENTLOG_INFORMATION_TYPE, L"d3d9 writing data to mem mapped file");
PVOID pMemDataMap = incPtr(ipcContext->m_pMemMap, sizeof (ipcContext->m_memDesc));
if (static_cast<UINT>(lockedSrcRect.Pitch) == surfDesc.Width * 4) {
memcpy(pMemDataMap, lockedSrcRect.pBits, surfDesc.Width * surfDesc.Height * 4);
} else {
UINT i = 0, cleanOffset = 0, pitchOffset = 0;
while (i < surfDesc.Height) {
memcpy(incPtr(pMemDataMap, cleanOffset), incPtr(lockedSrcRect.pBits, pitchOffset), surfDesc.Width * 4);
cleanOffset += surfDesc.Width * 4;
pitchOffset += lockedSrcRect.Pitch;
i++;
}
}
//.........这里部分代码省略.........