1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-24 17:49:52 +01:00

use roundf for maintas

This commit is contained in:
FunkyFr3sh 2023-12-29 01:40:49 +01:00
parent ff1c8fb0a3
commit 988cad0200
3 changed files with 8 additions and 6 deletions

View File

@ -1,4 +1,5 @@
#include <windows.h> #include <windows.h>
#include <math.h>
#include "ddraw.h" #include "ddraw.h"
#include "IDirectDraw.h" #include "IDirectDraw.h"
#include "dd.h" #include "dd.h"
@ -805,7 +806,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
{ {
g_ddraw->render.viewport.width = g_ddraw->render.width; g_ddraw->render.viewport.width = g_ddraw->render.width;
g_ddraw->render.viewport.height = g_ddraw->render.viewport.height =
(int)(((float)g_ddraw->height / g_ddraw->width) * g_ddraw->render.viewport.width); (int)roundf(((float)g_ddraw->height / g_ddraw->width) * g_ddraw->render.viewport.width);
if (g_ddraw->render.viewport.height > g_ddraw->render.height) if (g_ddraw->render.viewport.height > g_ddraw->render.height)
{ {

View File

@ -1,5 +1,6 @@
#include <windows.h> #include <windows.h>
#include <intrin.h> #include <intrin.h>
#include <math.h>
#include "ddraw.h" #include "ddraw.h"
#include "debug.h" #include "debug.h"
#include "dd.h" #include "dd.h"
@ -381,11 +382,11 @@ void util_toggle_maximize()
dst_rc.top = 0; dst_rc.top = 0;
dst_rc.left = 0; dst_rc.left = 0;
dst_rc.right = w; dst_rc.right = w;
dst_rc.bottom = (LONG)(((float)g_ddraw->height / g_ddraw->width) * w); dst_rc.bottom = (LONG)roundf(((float)g_ddraw->height / g_ddraw->width) * w);
if (dst_rc.bottom > h) if (dst_rc.bottom > h)
{ {
dst_rc.right = (LONG)(((float)dst_rc.right / dst_rc.bottom) * h); dst_rc.right = (LONG)roundf(((float)dst_rc.right / dst_rc.bottom) * h);
dst_rc.bottom = h; dst_rc.bottom = h;
} }

View File

@ -324,19 +324,19 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
case WMSZ_LEFT: case WMSZ_LEFT:
case WMSZ_RIGHT: case WMSZ_RIGHT:
{ {
windowrc->bottom += (LONG)(scaleH * clientrc.right - clientrc.bottom); windowrc->bottom += (LONG)roundf(scaleH * clientrc.right - clientrc.bottom);
break; break;
} }
case WMSZ_TOP: case WMSZ_TOP:
case WMSZ_BOTTOM: case WMSZ_BOTTOM:
{ {
windowrc->right += (LONG)(scaleW * clientrc.bottom - clientrc.right); windowrc->right += (LONG)roundf(scaleW * clientrc.bottom - clientrc.right);
break; break;
} }
case WMSZ_TOPRIGHT: case WMSZ_TOPRIGHT:
case WMSZ_TOPLEFT: case WMSZ_TOPLEFT:
{ {
windowrc->top -= (LONG)(scaleH * clientrc.right - clientrc.bottom); windowrc->top -= (LONG)roundf(scaleH * clientrc.right - clientrc.bottom);
break; break;
} }
} }