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

boxing and maintain aspect ratio now also working with opengl

This commit is contained in:
FunkyFr3sh 2018-03-14 15:12:56 +01:00
parent ecaaf8e647
commit 65525e14dd
3 changed files with 47 additions and 7 deletions

View File

@ -1,6 +1,6 @@
1 VERSIONINFO
FILEVERSION 1,1,5,4
PRODUCTVERSION 1,1,5,4
FILEVERSION 1,1,5,5
PRODUCTVERSION 1,1,5,5
{
BLOCK "StringFileInfo"
{
@ -8,13 +8,13 @@ PRODUCTVERSION 1,1,5,4
{
VALUE "CompanyName", "cncnet.org"
VALUE "FileDescription", "DirectDraw replacement for C&C95 and Red Alert"
VALUE "FileVersion", "1.1.5.4"
VALUE "FileVersion", "1.1.5.5"
VALUE "InternalName", "ddraw"
VALUE "LegalCopyright", "Copyright (c) 2010-2018"
VALUE "LegalTrademarks", ""
VALUE "OriginalFileName", "ddraw.dll"
VALUE "ProductName", "DirectDraw replacement for C&C95 and Red Alert"
VALUE "ProductVersion", "1.1.5.4"
VALUE "ProductVersion", "1.1.5.5"
VALUE "Comments", "https://cncnet.org"
}
}

View File

@ -895,9 +895,9 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
"windowed=false\n"
"; show window borders in windowed mode\n"
"border=true\n"
"; maintain aspect ratio (GDI only!)\n"
"; maintain aspect ratio\n"
"maintas=false\n"
"; use letter- or windowboxing to make a best fit (GDI only!)\n"
"; use letter- or windowboxing to make a best fit\n"
"boxing=false\n"
"; real rendering rate, -1 = screen rate, 0 = unlimited, n = cap\n"
"maxfps=0\n"

View File

@ -117,8 +117,48 @@ DWORD WINAPI render_main(void)
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tex_width, tex_height, 0, PIXEL_FORMAT, GL_UNSIGNED_BYTE, tex);
glViewport(0, 0, ddraw->render.width, ddraw->render.height);
DWORD dst_top = 0;
DWORD dst_left = 0;
DWORD dst_width = ddraw->render.width;
DWORD dst_height = ddraw->render.height;
if (ddraw->maintas)
{
dst_width = ddraw->render.width;
dst_height = ((float)ddraw->height / ddraw->width) * dst_width;
if (dst_height > ddraw->render.height)
{
dst_width = ((float)dst_width / dst_height) * ddraw->render.height;
dst_height = ddraw->render.height;
}
dst_top = ddraw->render.height / 2 - dst_height / 2;
dst_left = ddraw->render.width / 2 - dst_width / 2;
}
else if (ddraw->boxing)
{
dst_width = ddraw->width;
dst_height = ddraw->height;
int i;
for (i = 20; i-- > 1;)
{
if (ddraw->width * i <= ddraw->render.width && ddraw->height * i <= ddraw->render.height)
{
dst_width *= i;
dst_height *= i;
break;
}
}
dst_top = ddraw->render.height / 2 - dst_height / 2;
dst_left = ddraw->render.width / 2 - dst_width / 2;
}
glViewport(dst_left, dst_top, dst_width, dst_height);
if(ddraw->render.filter)
{
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);