Windows: fix colors. use fallback if hardware render mode doesn't work.
This commit is contained in:
parent
defe46e37e
commit
dbefaf0ad3
|
@ -58,12 +58,21 @@ ID2D1HwndRenderTarget *makeHWNDRenderTarget(HWND hwnd)
|
||||||
// according to Rick Brewster, some drivers will misbehave if we don't specify this (see http://stackoverflow.com/a/33222983/3408572)
|
// according to Rick Brewster, some drivers will misbehave if we don't specify this (see http://stackoverflow.com/a/33222983/3408572)
|
||||||
hprops.presentOptions = D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS;
|
hprops.presentOptions = D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS;
|
||||||
|
|
||||||
|
hr = d2dfactory->CreateHwndRenderTarget(
|
||||||
|
&props,
|
||||||
|
&hprops,
|
||||||
|
&rt);
|
||||||
|
if (hr != S_OK)
|
||||||
|
{
|
||||||
|
props.type = D2D1_RENDER_TARGET_TYPE_DEFAULT;
|
||||||
hr = d2dfactory->CreateHwndRenderTarget(
|
hr = d2dfactory->CreateHwndRenderTarget(
|
||||||
&props,
|
&props,
|
||||||
&hprops,
|
&hprops,
|
||||||
&rt);
|
&rt);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
logHRESULT(L"error creating HWND render target", hr);
|
logHRESULT(L"error creating HWND render target", hr);
|
||||||
|
}
|
||||||
|
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,9 +532,7 @@ uiDrawBitmap* uiDrawNewBitmap(uiDrawContext* c, int width, int height)
|
||||||
D2D1_BITMAP_PROPERTIES bp2 = D2D1::BitmapProperties();
|
D2D1_BITMAP_PROPERTIES bp2 = D2D1::BitmapProperties();
|
||||||
bp2.dpiX = 0;
|
bp2.dpiX = 0;
|
||||||
bp2.dpiY = 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);
|
||||||
//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)
|
|
||||||
|
|
||||||
c->rt->BeginDraw();
|
c->rt->BeginDraw();
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ uiArea* MainDrawArea;
|
||||||
SDL_Thread* EmuThread;
|
SDL_Thread* EmuThread;
|
||||||
int EmuRunning;
|
int EmuRunning;
|
||||||
|
|
||||||
|
bool ScreenDrawInited = false;
|
||||||
SDL_mutex* ScreenMutex;
|
SDL_mutex* ScreenMutex;
|
||||||
uiDrawBitmap* ScreenBitmap = NULL;
|
uiDrawBitmap* ScreenBitmap = NULL;
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ int EmuThreadFunc(void* burp)
|
||||||
{
|
{
|
||||||
NDS::Init();
|
NDS::Init();
|
||||||
|
|
||||||
|
ScreenDrawInited = false;
|
||||||
Touching = false;
|
Touching = false;
|
||||||
|
|
||||||
// DS:
|
// DS:
|
||||||
|
@ -160,8 +162,13 @@ int EmuThreadFunc(void* burp)
|
||||||
|
|
||||||
void OnAreaDraw(uiAreaHandler* handler, uiArea* area, uiAreaDrawParams* params)
|
void OnAreaDraw(uiAreaHandler* handler, uiArea* area, uiAreaDrawParams* params)
|
||||||
{
|
{
|
||||||
if (!ScreenBitmap)
|
if (!ScreenDrawInited)
|
||||||
|
{
|
||||||
ScreenBitmap = uiDrawNewBitmap(params->Context, 256, 384);
|
ScreenBitmap = uiDrawNewBitmap(params->Context, 256, 384);
|
||||||
|
ScreenDrawInited = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ScreenBitmap) return;
|
||||||
|
|
||||||
uiRect dorp = {0, 0, 256, 384};
|
uiRect dorp = {0, 0, 256, 384};
|
||||||
|
|
||||||
|
@ -280,7 +287,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenMutex = SDL_CreateMutex();
|
//ScreenMutex = SDL_CreateMutex();
|
||||||
|
|
||||||
uiInitOptions ui_opt;
|
uiInitOptions ui_opt;
|
||||||
memset(&ui_opt, 0, sizeof(uiInitOptions));
|
memset(&ui_opt, 0, sizeof(uiInitOptions));
|
||||||
|
@ -327,8 +334,8 @@ int main(int argc, char** argv)
|
||||||
EmuRunning = 0;
|
EmuRunning = 0;
|
||||||
SDL_WaitThread(EmuThread, NULL);
|
SDL_WaitThread(EmuThread, NULL);
|
||||||
|
|
||||||
SDL_DestroyMutex(ScreenMutex);
|
//SDL_DestroyMutex(ScreenMutex);
|
||||||
uiDrawFreeBitmap(ScreenBitmap);
|
if (ScreenBitmap) uiDrawFreeBitmap(ScreenBitmap);
|
||||||
|
|
||||||
uiUninit();
|
uiUninit();
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
Loading…
Reference in New Issue