Add d3d_get_render_state

This commit is contained in:
twinaphex 2018-01-15 06:14:20 +01:00
parent 510dfca756
commit 27caf46616
3 changed files with 28 additions and 4 deletions

View File

@ -1223,6 +1223,26 @@ void d3d_texture_blit(unsigned pixel_size,
}
}
bool d3d_get_render_state(void *data, D3DRENDERSTATETYPE state, DWORD *value)
{
LPDIRECT3DDEVICE dev = (LPDIRECT3DDEVICE)data;
if (!dev)
return false;
#if defined(HAVE_D3D9) && !defined(__cplusplus)
if (IDirect3DDevice9_GetRenderState(dev, state, value) == D3D_OK)
return true;
#elif defined(HAVE_D3D8) && !defined(__cplusplus)
if (IDirect3DDevice8_GetRenderState(dev, state, value) == D3D_OK)
return true;
#else
if (dev->GetRenderState(state, value) == D3D_OK)
return true;
#endif
return false;
}
void d3d_set_render_state(void *data, D3DRENDERSTATETYPE state, DWORD value)
{
LPDIRECT3DDEVICE dev = (LPDIRECT3DDEVICE)data;

View File

@ -147,7 +147,11 @@ bool d3d_device_get_render_target(LPDIRECT3DDEVICE dev,
void d3d_device_set_render_target(LPDIRECT3DDEVICE dev, unsigned idx,
void *data);
void d3d_set_render_state(void *data, D3DRENDERSTATETYPE state, DWORD value);
bool d3d_get_render_state(void *data,
D3DRENDERSTATETYPE state, DWORD *value);
void d3d_set_render_state(void *data,
D3DRENDERSTATETYPE state, DWORD value);
void d3d_device_set_render_target(LPDIRECT3DDEVICE dev, unsigned idx,
void *data);

View File

@ -630,7 +630,8 @@ static void xdk360_render_msg_pre(xdk360_video_font_t * font)
LPDIRECT3DDEVICE d3dr = font->d3d->dev;
/* Save state. */
d3dr->GetRenderState( D3DRS_VIEWPORTENABLE, (DWORD*)&font->m_dwSavedState );
d3d_get_render_state(d3dr, D3DRS_VIEWPORTENABLE,
(DWORD*)&font->m_dwSavedState );
/* Set the texture scaling factor as a vertex shader constant. */
/* Get the description */
@ -639,8 +640,7 @@ static void xdk360_render_msg_pre(xdk360_video_font_t * font)
/* Set render state. */
d3d_set_texture(d3dr, 0, font->m_pFontTexture);
/* Read the TextureDesc here to ensure no load/hit/store from d3d_texture_get_level_desc(). */
vTexScale[0] = 1.0f / TextureDesc.Width; /* LHS due to int->float conversion. */
vTexScale[0] = 1.0f / TextureDesc.Width;
vTexScale[1] = 1.0f / TextureDesc.Height;
vTexScale[2] = 0.0f;
vTexScale[3] = 0.0f;