1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

fix palette issues on GetDC

This commit is contained in:
FunkyFr3sh 2018-10-27 07:43:47 +02:00
parent 5477e5139a
commit 8e53cdc5fa
2 changed files with 15 additions and 7 deletions

View File

@ -43,8 +43,13 @@ void DrawFrameInfoStart()
RECT debugrc = { 0, 0, ddraw->width, ddraw->height };
if (ddraw->primary && ddraw->primary->palette)
DrawText(ddraw->primary->hDC, debugText, -1, &debugrc, DT_NOCLIP);
{
if (ddraw->primary->palette->data_rgb)
SetDIBColorTable(ddraw->primary->hDC, 0, 256, ddraw->primary->palette->data_rgb);
DrawText(ddraw->primary->hDC, debugText, -1, &debugrc, DT_NOCLIP);
}
DWORD tick_start = timeGetTime();
if (tick_start >= tick_fps)
{

View File

@ -376,6 +376,15 @@ HRESULT __stdcall ddraw_surface_GetDC(IDirectDrawSurfaceImpl *This, HDC FAR *a)
#if _DEBUG_X
printf("IDirectDrawSurface::GetDC(This=%p, ...)\n", This);
#endif
RGBQUAD *data =
This->palette && This->palette->data_rgb ? This->palette->data_rgb :
ddraw->primary && ddraw->primary->palette ? ddraw->primary->palette->data_rgb :
NULL;
if (data)
SetDIBColorTable(This->hDC, 0, 256, data);
*a = This->hDC;
return DD_OK;
}
@ -648,12 +657,6 @@ HRESULT __stdcall ddraw_CreateSurface(IDirectDrawImpl *This, LPDDSURFACEDESC lpD
Surface->bmi->bmiColors[i].rgbReserved = 0;
}
#if _DEBUG
Surface->bmi->bmiColors[255].rgbRed = 250;
Surface->bmi->bmiColors[255].rgbGreen = 250;
Surface->bmi->bmiColors[255].rgbBlue = 250;
#endif
Surface->lXPitch = Surface->bpp / 8;
Surface->lPitch = Surface->width * Surface->lXPitch;