Skip to content

Commit 4b53924

Browse files
adeybluejayrm
authored andcommitted
Fix D2D DPI scaling issues
1 parent 3ba65e6 commit 4b53924

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/gfxlib2/win32/gfx_driver_d2d.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,13 @@ static int GdiInteropSetup(D2DGlobalState* pGlobalState, HWND hwnd)
440440
pD3DTexture = NULL;
441441
renderProps.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE;
442442
renderProps.usage = D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE;
443+
renderProps.dpiX = renderProps.dpiY = 96.f;
443444
if(NOTIFY_FAILED_HR(ID2D1Factory_CreateDxgiSurfaceRenderTarget(pGlobalState->pD2DFactory, pDXGISurface, &renderProps, &pRenderTarget))) {
444445
goto errorReturn;
445446
}
446447
bitmapProps.pixelFormat.format = texDesc.Format;
447448
bitmapProps.pixelFormat.alphaMode = renderProps.pixelFormat.alphaMode;
449+
bitmapProps.dpiX = bitmapProps.dpiY = 96.f;
448450
if(NOTIFY_FAILED_HR(ID2D1RenderTarget_CreateBitmap(pRenderTarget, bitmapSize, NULL, stride, &bitmapProps, &pBitmap))) {
449451
goto errorReturn;
450452
}
@@ -513,6 +515,7 @@ static int D2DDirectSetup(D2DGlobalState* pGlobalState, HWND hwnd)
513515
renderProps.type = D2D1_RENDER_TARGET_TYPE_DEFAULT;
514516
renderProps.usage = D2D1_RENDER_TARGET_USAGE_NONE;
515517
renderProps.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE;
518+
renderProps.dpiX = renderProps.dpiY = 96.f;
516519
while(*pFormats != DXGI_FORMAT_UNKNOWN) {
517520
renderProps.pixelFormat.format = *(pFormats++);
518521
if(!NOTIFY_FAILED_HR(ID2D1Factory_CreateHwndRenderTarget(
@@ -528,6 +531,7 @@ static int D2DDirectSetup(D2DGlobalState* pGlobalState, HWND hwnd)
528531
goto errorReturn;
529532
}
530533
bitmapProps.pixelFormat = renderProps.pixelFormat;
534+
bitmapProps.dpiX = bitmapProps.dpiY = 96.f;
531535
if(NOTIFY_FAILED_HR(ID2D1HwndRenderTarget_CreateBitmap(
532536
pHwndRenderTarget,
533537
hwndRenderProps.pixelSize,

0 commit comments

Comments
 (0)