From dbefaf0ad3a0a68f7e85c8ec1c6a4d39cacbd94b Mon Sep 17 00:00:00 2001 From: StapleButter Date: Tue, 19 Sep 2017 20:48:18 +0200 Subject: Windows: fix colors. use fallback if hardware render mode doesn't work. --- src/libui_sdl/libui/windows/draw.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/libui_sdl/libui') diff --git a/src/libui_sdl/libui/windows/draw.cpp b/src/libui_sdl/libui/windows/draw.cpp index c28af0c..11ee048 100644 --- a/src/libui_sdl/libui/windows/draw.cpp +++ b/src/libui_sdl/libui/windows/draw.cpp @@ -63,7 +63,16 @@ ID2D1HwndRenderTarget *makeHWNDRenderTarget(HWND hwnd) &hprops, &rt); if (hr != S_OK) - logHRESULT(L"error creating HWND render target", hr); + { + props.type = D2D1_RENDER_TARGET_TYPE_DEFAULT; + hr = d2dfactory->CreateHwndRenderTarget( + &props, + &hprops, + &rt); + if (hr != S_OK) + logHRESULT(L"error creating HWND render target", hr); + } + return rt; } @@ -523,9 +532,7 @@ uiDrawBitmap* uiDrawNewBitmap(uiDrawContext* c, int width, int height) D2D1_BITMAP_PROPERTIES bp2 = D2D1::BitmapProperties(); bp2.dpiX = 0; bp2.dpiY = 0; - bp2.pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_R8G8B8A8_UNORM, D2D1_ALPHA_MODE_IGNORE); - //bp2.pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE); - // TODO: fallback: convert to BGRA if needed (RGBA only works in hardware mode) + bp2.pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE); c->rt->BeginDraw(); -- cgit v1.2.3