Add d3d_device_get_backbuffer

This commit is contained in:
twinaphex 2018-01-03 15:21:48 +01:00
parent dbd2faf69a
commit 6e22e2b4fc
2 changed files with 43 additions and 0 deletions

View File

@ -939,6 +939,45 @@ bool d3d_reset(LPDIRECT3DDEVICE dev, D3DPRESENT_PARAMETERS *d3dpp)
return false;
}
bool d3d_device_get_backbuffer(LPDIRECT3DDEVICE dev,
unsigned idx, unsigned swapchain_idx,
unsigned backbuffer_type, void **data)
{
if (!dev)
return false;
#if defined(HAVE_D3D9) && !defined(__cplusplus)
#ifdef __cplusplus
if (SUCCEEDED(dev->GetBackBuffer(
swapchain_idx, idx,
(D3DBACKBUFFER_TYPE)backbuffer_type,
(LPDIRECT3DSURFACE*)data)))
return true;
#else
if (SUCCEEDED(IDirect3DDevice9_GetBackBuffer(dev,
swapchain_idx, idx,
(D3DBACKBUFFER_TYPE)backbuffer_type,
(LPDIRECT3DSURFACE*)data)))
return true;
#endif
#elif defined(HAVE_D3D8)
#ifdef __cplusplus
if (SUCCEEDED(dev->GetBackBuffer(idx,
(D3DBACKBUFFER_TYPE)backbuffer_type,
(LPDIRECT3DSURFACE*)data)))
return true;
#else
if (SUCCEEDED(IDirect3DDevice8_GetBackBuffer(dev, idx,
(D3DBACKBUFFER_TYPE)backbuffer_type,
(LPDIRECT3DSURFACE*)data)))
return true;
#endif
#endif
return false;
}
void d3d_device_free(LPDIRECT3DDEVICE dev, LPDIRECT3D pd3d)
{
if (dev)

View File

@ -167,6 +167,10 @@ bool d3d_create_device(LPDIRECT3DDEVICE *dev,
bool d3d_reset(LPDIRECT3DDEVICE dev, D3DPRESENT_PARAMETERS *d3dpp);
bool d3d_device_get_backbuffer(LPDIRECT3DDEVICE dev,
unsigned idx, unsigned swapchain_idx,
unsigned backbuffer_type, void **data);
void d3d_device_free(LPDIRECT3DDEVICE dev, LPDIRECT3D pd3d);
D3DTEXTUREFILTERTYPE d3d_translate_filter(unsigned type);