src/render/direct3d11/SDL_render_d3d11.c
changeset 8620 a27695b26b57
parent 8615 097646deaef2
child 8668 07dce0097f29
equal deleted inserted replaced
8619:a4538a64b9bb 8620:a27695b26b57
  1436 {
  1436 {
  1437     D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
  1437     D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
  1438     ID3D11Texture2D *backBuffer = NULL;
  1438     ID3D11Texture2D *backBuffer = NULL;
  1439     HRESULT result = S_OK;
  1439     HRESULT result = S_OK;
  1440     int w, h;
  1440     int w, h;
  1441     BOOL swapDimensions;
       
  1442 
  1441 
  1443     /* Release the previous render target view */
  1442     /* Release the previous render target view */
  1444     D3D11_ReleaseMainRenderTargetView(renderer);
  1443     D3D11_ReleaseMainRenderTargetView(renderer);
  1445 
  1444 
  1446     /* The width and height of the swap chain must be based on the window's
  1445     /* The width and height of the swap chain must be based on the display's
  1447      * landscape-oriented width and height. If the window is in a portrait
  1446      * non-rotated size.
  1448      * rotation, the dimensions must be reversed.
       
  1449      */
  1447      */
  1450     SDL_GetWindowSize(renderer->window, &w, &h);
  1448     SDL_GetWindowSize(renderer->window, &w, &h);
  1451     data->rotation = D3D11_GetCurrentRotation();
  1449     data->rotation = D3D11_GetCurrentRotation();
  1452 
  1450     if (D3D11_IsDisplayRotated90Degrees(data->rotation)) {
  1453 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
       
  1454     swapDimensions = FALSE;
       
  1455 #else
       
  1456     swapDimensions = D3D11_IsDisplayRotated90Degrees(data->rotation);
       
  1457 #endif
       
  1458     if (swapDimensions) {
       
  1459         int tmp = w;
  1451         int tmp = w;
  1460         w = h;
  1452         w = h;
  1461         h = tmp;
  1453         h = tmp;
  1462     }
  1454     }
  1463 
  1455 
  1464     if (data->swapChain) {
  1456     if (data->swapChain) {
       
  1457         /* IDXGISwapChain::ResizeBuffers is not available on Windows Phone 8. */
       
  1458 #if !defined(__WINRT__) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP)
  1465         /* If the swap chain already exists, resize it. */
  1459         /* If the swap chain already exists, resize it. */
  1466         result = IDXGISwapChain_ResizeBuffers(data->swapChain,
  1460         result = IDXGISwapChain_ResizeBuffers(data->swapChain,
  1467             0,
  1461             0,
  1468             w, h,
  1462             w, h,
  1469             DXGI_FORMAT_UNKNOWN,
  1463             DXGI_FORMAT_UNKNOWN,
  1471             );
  1465             );
  1472         if (FAILED(result)) {
  1466         if (FAILED(result)) {
  1473             WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain::ResizeBuffers", result);
  1467             WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain::ResizeBuffers", result);
  1474             goto done;
  1468             goto done;
  1475         }
  1469         }
       
  1470 #endif
  1476     } else {
  1471     } else {
  1477         result = D3D11_CreateSwapChain(renderer, w, h);
  1472         result = D3D11_CreateSwapChain(renderer, w, h);
  1478         if (FAILED(result)) {
  1473         if (FAILED(result)) {
  1479             goto done;
  1474             goto done;
  1480         }
  1475         }