mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
Implement letter- and windowboxing for GDI
This commit is contained in:
parent
6c7e656c67
commit
3f061f3a3b
19
main.c
19
main.c
@ -265,6 +265,7 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
RECT rc = { 0, 0, ddraw->render.width, ddraw->render.height };
|
||||
POINT pt;
|
||||
|
||||
switch(uMsg)
|
||||
@ -372,6 +373,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
return ddraw->WndProc(hWnd, uMsg, wParam, MAKELPARAM(pt.x, pt.y));
|
||||
}
|
||||
return ddraw->WndProc(hWnd, uMsg, wParam, lParam);
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
EnterCriticalSection(&ddraw->cs);
|
||||
FillRect(ddraw->render.hDC, &rc, (HBRUSH) GetStockObject(BLACK_BRUSH));
|
||||
LeaveCriticalSection(&ddraw->cs);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
@ -601,6 +608,8 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
|
||||
"windowed=true\n"
|
||||
"; show window borders in windowed mode\n"
|
||||
"border=true\n"
|
||||
"; use letter- or windowboxing to make a best fit (GDI only!)\n"
|
||||
"boxing=false\n"
|
||||
"; real rendering rate, -1 = screen rate, 0 = unlimited, n = cap\n"
|
||||
"maxfps=0\n"
|
||||
"; vertical synchronization, enable if you get tearing (OpenGL only)\n"
|
||||
@ -641,6 +650,16 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
|
||||
This->border = TRUE;
|
||||
}
|
||||
|
||||
GetPrivateProfileStringA("ddraw", "boxing", "FALSE", tmp, sizeof(tmp), ini_path);
|
||||
if(tolower(tmp[0]) == 'n' || tolower(tmp[0]) == 'f' || tmp[0] == '0')
|
||||
{
|
||||
This->boxing = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
This->boxing = TRUE;
|
||||
}
|
||||
|
||||
This->render.maxfps = GetPrivateProfileIntA("ddraw", "maxfps", 0, ini_path);
|
||||
This->render.width = GetPrivateProfileIntA("ddraw", "width", 640, ini_path);
|
||||
if(This->render.width < 640)
|
||||
|
1
main.h
1
main.h
@ -39,6 +39,7 @@ typedef struct IDirectDrawImpl
|
||||
DWORD bpp;
|
||||
BOOL windowed;
|
||||
BOOL border;
|
||||
BOOL boxing;
|
||||
BOOL windowed_init;
|
||||
DEVMODE mode;
|
||||
struct IDirectDrawSurfaceImpl *primary;
|
||||
|
1
render.c
1
render.c
@ -99,6 +99,7 @@ DWORD WINAPI render_main(void)
|
||||
|
||||
/* convert ddraw surface to opengl texture */
|
||||
EnterCriticalSection(&ddraw->cs);
|
||||
|
||||
if(ddraw->primary && ddraw->primary->palette)
|
||||
{
|
||||
if(ddraw->vhack && detect_cutscene())
|
||||
|
@ -31,10 +31,31 @@ DWORD WINAPI render_soft_main(void)
|
||||
bmi->bmiHeader.biBitCount = ddraw->bpp;
|
||||
bmi->bmiHeader.biCompression = BI_RGB;
|
||||
|
||||
DWORD dst_top = 0;
|
||||
DWORD dst_left = 0;
|
||||
DWORD dst_width = ddraw->render.width;
|
||||
DWORD dst_height = ddraw->render.height;
|
||||
|
||||
DWORD tick_start = 0;
|
||||
DWORD tick_end = 0;
|
||||
DWORD frame_len = 0;
|
||||
|
||||
if (ddraw->boxing)
|
||||
{
|
||||
dst_width = ddraw->width;
|
||||
dst_height = ddraw->height;
|
||||
|
||||
/* test if we can double scale the window */
|
||||
if (ddraw->width * 2 <= ddraw->render.width && ddraw->height * 2 <= ddraw->render.height)
|
||||
{
|
||||
dst_width *= 2;
|
||||
dst_height *= 2;
|
||||
}
|
||||
|
||||
dst_top = ddraw->render.height / 2 - dst_height / 2;
|
||||
dst_left = ddraw->render.width / 2 - dst_width / 2;
|
||||
}
|
||||
|
||||
if(ddraw->render.maxfps < 0)
|
||||
{
|
||||
ddraw->render.maxfps = ddraw->mode.dmDisplayFrequency;
|
||||
@ -53,6 +74,7 @@ DWORD WINAPI render_soft_main(void)
|
||||
}
|
||||
|
||||
EnterCriticalSection(&ddraw->cs);
|
||||
|
||||
if (ddraw->primary && (ddraw->primary->palette || ddraw->bpp == 16))
|
||||
{
|
||||
if (ddraw->primary->palette && ddraw->primary->palette->data_rgb == NULL)
|
||||
@ -62,7 +84,7 @@ DWORD WINAPI render_soft_main(void)
|
||||
|
||||
if (ddraw->render.width != ddraw->width || ddraw->render.height != ddraw->height)
|
||||
{
|
||||
StretchDIBits(ddraw->render.hDC, 0, 0, ddraw->render.width, ddraw->render.height, 0, 0, ddraw->width, ddraw->height, ddraw->primary->surface, bmi, DIB_RGB_COLORS, SRCCOPY);
|
||||
StretchDIBits(ddraw->render.hDC, dst_left, dst_top, dst_width, dst_height, 0, 0, ddraw->width, ddraw->height, ddraw->primary->surface, bmi, DIB_RGB_COLORS, SRCCOPY);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user