src/render/direct3d/SDL_render_d3d.c
changeset 7837 2f2f0b3b4702
parent 7828 1451063c8ecd
child 7877 aa7e6130d6e9
equal deleted inserted replaced
7836:b7c1c84c33e3 7837:2f2f0b3b4702
  1214 D3D_RenderClear(SDL_Renderer * renderer)
  1214 D3D_RenderClear(SDL_Renderer * renderer)
  1215 {
  1215 {
  1216     D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
  1216     D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
  1217     DWORD color;
  1217     DWORD color;
  1218     HRESULT result;
  1218     HRESULT result;
       
  1219     int BackBufferWidth, BackBufferHeight;
  1219 
  1220 
  1220     if (D3D_ActivateRenderer(renderer) < 0) {
  1221     if (D3D_ActivateRenderer(renderer) < 0) {
  1221         return -1;
  1222         return -1;
  1222     }
  1223     }
  1223 
  1224 
  1224     color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
  1225     color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
  1225 
  1226 
       
  1227     if (renderer->target) {
       
  1228         BackBufferWidth = renderer->target->w;
       
  1229         BackBufferHeight = renderer->target->h;
       
  1230     } else {
       
  1231         BackBufferWidth = data->pparams.BackBufferWidth;
       
  1232         BackBufferHeight = data->pparams.BackBufferHeight;
       
  1233     }
       
  1234 
  1226     /* Don't reset the viewport if we don't have to! */
  1235     /* Don't reset the viewport if we don't have to! */
  1227     if (!renderer->viewport.x && !renderer->viewport.y &&
  1236     if (!renderer->viewport.x && !renderer->viewport.y &&
  1228         renderer->viewport.w == data->pparams.BackBufferWidth &&
  1237         renderer->viewport.w == BackBufferWidth &&
  1229         renderer->viewport.h == data->pparams.BackBufferHeight) {
  1238         renderer->viewport.h == BackBufferHeight) {
  1230         result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
  1239         result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
  1231     } else {
  1240     } else {
  1232         D3DVIEWPORT9 viewport;
  1241         D3DVIEWPORT9 viewport;
  1233 
  1242 
  1234         /* Clear is defined to clear the entire render target */
  1243         /* Clear is defined to clear the entire render target */
  1235         viewport.X = 0;
  1244         viewport.X = 0;
  1236         viewport.Y = 0;
  1245         viewport.Y = 0;
  1237         viewport.Width = data->pparams.BackBufferWidth;
  1246         viewport.Width = BackBufferWidth;
  1238         viewport.Height = data->pparams.BackBufferHeight;
  1247         viewport.Height = BackBufferHeight;
  1239         viewport.MinZ = 0.0f;
  1248         viewport.MinZ = 0.0f;
  1240         viewport.MaxZ = 1.0f;
  1249         viewport.MaxZ = 1.0f;
  1241         IDirect3DDevice9_SetViewport(data->device, &viewport);
  1250         IDirect3DDevice9_SetViewport(data->device, &viewport);
  1242 
  1251 
  1243         result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
  1252         result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);