EDIT 21 Feb 2017: This whole thread is irrelevant due to ZScriptification of menus. Goodbye shitty ACS menus
I'm trying to emulate what ZDoom is doing with the menu text because I'm really sick of HUDMessages with dirty pixels on the screen. Took a look inside ZDoom and did some Shift Ctrl F but I don't really understand how it's done in ZDoom. Can anyone explain it to me? Is it even possible with HUDMessage or is the drawing code such that you are forever doomed with dirty pixels.
Clean scale HUD Messages
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Clean scale HUD Messages
Last edited by Nash on Mon Feb 20, 2017 11:00 am, edited 1 time in total.
Re: Clean scale HUD Messages
Here's what ZDoom does to compute clean factors:
So if we simplify, we have:
* real screen dimensions
* letterboxed or pillarboxed screen dimensions (if appropriate, depending on aspect ratio)
* virtual screen dimensions (the low-res stuff we want to scale up)
What it's doing is looking at the height and width ratio, and taking the smaller factor of the two. There's some fudging around because of the variety of aspect ratios, but that's it.
Spoiler: CheckRatio
Code: Select all
void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany, int *_cx1, int *_cx2)
{
int ratio;
int cwidth;
int cheight;
int cx1, cy1, cx2, cy2;
ratio = CheckRatio(realwidth, realheight);
if (ratio & 4)
{
cwidth = realwidth;
cheight = realheight * BaseRatioSizes[ratio][3] / 48;
}
else
{
cwidth = realwidth * BaseRatioSizes[ratio][3] / 48;
cheight = realheight;
}
// Use whichever pair of cwidth/cheight or width/height that produces less difference
// between CleanXfac and CleanYfac.
cx1 = MAX(cwidth / designwidth, 1);
cy1 = MAX(cheight / designheight, 1);
cx2 = MAX(realwidth / designwidth, 1);
cy2 = MAX(realheight / designheight, 1);
if (abs(cx1 - cy1) <= abs(cx2 - cy2))
{ // e.g. 640x360 looks better with this.
*cleanx = cx1;
*cleany = cy1;
}
else
{ // e.g. 720x480 looks better with this.
*cleanx = cx2;
*cleany = cy2;
}
if (*cleanx > 1 && *cleany > 1 && *cleanx != *cleany)
{
if (*cleanx < *cleany)
*cleany = *cleanx;
else
*cleanx = *cleany;
}
if (_cx1 != NULL) *_cx1 = cx1;
if (_cx2 != NULL) *_cx2 = cx2;
}
* real screen dimensions
* letterboxed or pillarboxed screen dimensions (if appropriate, depending on aspect ratio)
* virtual screen dimensions (the low-res stuff we want to scale up)
What it's doing is looking at the height and width ratio, and taking the smaller factor of the two. There's some fudging around because of the variety of aspect ratios, but that's it.
Re: Clean scale HUD Messages
Thanks... that's a start. What are the inputs cleanx/y and _cx1/2 supposed to be?
Re: Clean scale HUD Messages
They aren't input. They are output. Notice that they are pointers: this function will set them. The only times the function references them, it is to set them to a value, never to read their value.
What you want is cleanx and cleany. They're the factors you are looking for.
What you want is cleanx and cleany. They're the factors you are looking for.
Re: Clean scale HUD Messages
In an ACS context, can I just move those pointers down to become variable declarations? Still struggling with understanding pointers (but that's for another thread)...
- phantombeta
- Posts: 2178
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: Clean scale HUD Messages
Even if you did, you'd have to change them to something else because ACS/ACC doesn't have pointers. (GDCC does though, which is cool :))Still struggling with understanding pointers (but that's for another thread)...
Re: Clean scale HUD Messages
In an ACS context, you'd have to make them global variables, since presumably you'll want to use them outside of that function. Also you can just ignore the _cx vars and delete the two lines that reference them.
Re: Clean scale HUD Messages
I've "converted" the stuff to ACS, and I >think< it's working but I don't know if the numbers reported are correct. It seems to look okay mostly at high resolutions, but at lower and more uncommon resolutions, the pixels are still dirty (not matching what ZDoom is doing with the clean menu scaling). Halp?
- Attachments
-
cleanscale2.pk3
- (3.51 KiB) Downloaded 45 times