Skip to content

Commit

Permalink
Create d3d_device_set_render_target
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Oct 1, 2017
1 parent 30af756 commit 8b1ae94
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
13 changes: 13 additions & 0 deletions gfx/common/d3d_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,19 @@ void d3d_enable_blend_func(void *data)
d3d_set_render_state(dev, D3DRS_ALPHABLENDENABLE, true);
}

void d3d_device_set_render_target(LPDIRECT3DDEVICE dev, unsigned idx,
void *data)
{
LPDIRECT3DSURFACE surf = (LPDIRECT3DSURFACE)data;
#if defined(HAVE_D3D9) && !defined(__cplusplus)
IDirect3DDevice9_SetRenderTarget(dev, idx, surf);
#elif defined(HAVE_D3D8) && !defined(__cplusplus)
IDirect3DDevice8_SetRenderTarget(dev, idx, surf);
#else
dev->SetRenderTarget(idx, surf);
#endif
}

void d3d_enable_alpha_blend_texture_func(void *data)
{
LPDIRECT3DDEVICE dev = (LPDIRECT3DDEVICE)data;
Expand Down
6 changes: 6 additions & 0 deletions gfx/common/d3d_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,14 @@ void d3d_surface_free(void *data);
bool d3d_device_get_render_target(LPDIRECT3DDEVICE dev,
unsigned idx, void **data);

void d3d_device_set_render_target(LPDIRECT3DDEVICE dev, unsigned idx,
void *data);

void d3d_set_render_state(void *data, D3DRENDERSTATETYPE state, DWORD value);

void d3d_device_set_render_target(LPDIRECT3DDEVICE dev, unsigned idx,
void *data);

bool d3d_reset(LPDIRECT3DDEVICE dev, D3DPRESENT_PARAMETERS *d3dpp);

void d3d_device_free(LPDIRECT3DDEVICE dev, LPDIRECT3D pd3d);
Expand Down
5 changes: 3 additions & 2 deletions gfx/drivers_renderchain/d3d9_cg_renderchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,8 @@ static bool d3d9_cg_renderchain_render(
Pass *to_pass = (Pass*)&chain->passes[i + 1];

to_pass->tex->GetSurfaceLevel(0, &target);
d3dr->SetRenderTarget(0, target);

d3d_device_set_render_target(d3dr, 0, (void*)target);

d3d9_cg_renderchain_convert_geometry(chain, &from_pass->info,
&out_width, &out_height,
Expand Down Expand Up @@ -1459,7 +1460,7 @@ static bool d3d9_cg_renderchain_render(
}

/* Final pass */
d3dr->SetRenderTarget(0, back_buffer);
d3d_device_set_render_target(d3dr, 0, (void*)back_buffer);

last_pass = (Pass*)&chain->passes.back();

Expand Down

0 comments on commit 8b1ae94

Please sign in to comment.