mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
fix aspect ratio issues
This commit is contained in:
parent
2cbf45cc2f
commit
a863d8cb33
10
src/dd.c
10
src/dd.c
@ -804,11 +804,13 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
||||
}
|
||||
else if (g_config.maintas)
|
||||
{
|
||||
g_ddraw->render.viewport.width = g_ddraw->render.width;
|
||||
g_ddraw->render.viewport.height =
|
||||
(int)roundf(((float)g_ddraw->height / g_ddraw->width) * g_ddraw->render.viewport.width);
|
||||
float dst_ar = (float)g_ddraw->height / g_ddraw->width;
|
||||
float src_ar = (float)g_ddraw->render.height / g_ddraw->render.width;
|
||||
|
||||
if (g_ddraw->render.viewport.height > g_ddraw->render.height)
|
||||
g_ddraw->render.viewport.width = g_ddraw->render.width;
|
||||
g_ddraw->render.viewport.height = (int)roundf(dst_ar * g_ddraw->render.viewport.width);
|
||||
|
||||
if (src_ar < dst_ar)
|
||||
{
|
||||
g_ddraw->render.viewport.width =
|
||||
(int)roundf(((float)g_ddraw->render.viewport.width / g_ddraw->render.viewport.height) * g_ddraw->render.height);
|
||||
|
@ -382,11 +382,11 @@ void util_toggle_maximize()
|
||||
dst_rc.top = 0;
|
||||
dst_rc.left = 0;
|
||||
dst_rc.right = w;
|
||||
dst_rc.bottom = (LONG)roundf(((float)g_ddraw->height / g_ddraw->width) * w);
|
||||
dst_rc.bottom = (LONG)(((float)g_ddraw->height / g_ddraw->width) * w);
|
||||
|
||||
if (dst_rc.bottom > h)
|
||||
{
|
||||
dst_rc.right = (LONG)roundf(((float)dst_rc.right / dst_rc.bottom) * h);
|
||||
dst_rc.right = (LONG)(((float)dst_rc.right / dst_rc.bottom) * h);
|
||||
dst_rc.bottom = h;
|
||||
}
|
||||
|
||||
|
@ -324,19 +324,19 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||
case WMSZ_LEFT:
|
||||
case WMSZ_RIGHT:
|
||||
{
|
||||
windowrc->bottom += (LONG)roundf(scaleH * clientrc.right - clientrc.bottom);
|
||||
windowrc->bottom += (LONG)(scaleH * clientrc.right - clientrc.bottom);
|
||||
break;
|
||||
}
|
||||
case WMSZ_TOP:
|
||||
case WMSZ_BOTTOM:
|
||||
{
|
||||
windowrc->right += (LONG)roundf(scaleW * clientrc.bottom - clientrc.right);
|
||||
windowrc->right += (LONG)(scaleW * clientrc.bottom - clientrc.right);
|
||||
break;
|
||||
}
|
||||
case WMSZ_TOPRIGHT:
|
||||
case WMSZ_TOPLEFT:
|
||||
{
|
||||
windowrc->top -= (LONG)roundf(scaleH * clientrc.right - clientrc.bottom);
|
||||
windowrc->top -= (LONG)(scaleH * clientrc.right - clientrc.bottom);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user