OpenXcom Forum

OpenXcom => Suggestions => Topic started by: Tarvis on May 08, 2013, 03:45:35 am

Title: Aspect Ratio Correction option
Post by: Tarvis on May 08, 2013, 03:45:35 am
The game seems to be designed for 16:10 aspect ratio, due to the globe in Geoscape looking round in 320x200. Right now the game is stretched to fill the whole window, which means it looks stretched or flattened if you're playing fullscreen with a 4:3 or 16:9 monitor.

It is true that most games that ran at 320x200 accounted for the fact that the resolution is usually scaled to 4:3, but as the globe looks oval when this is done, it seems XCOM wasn't designed with that in mind.

It would be nice if there was an option to letterbox the game to 16:10, especially since most video card drivers don't have 16:10 resolutions past 1280x800 enabled by default. This is merely so the game doesn't look flattened if you're playing it at 1920x1080, for example.

UFO Extender for the regular Windows version of XCOM has an option for this. It's an extremely trivial change, so I could probably add it myself if the devs have higher priorities.
Title: Re: Aspect Ratio Correction option
Post by: Fenyő on May 08, 2013, 05:51:49 am
This is a good idea.

Feel free to make this option, and then make a Pull Request on Github.

I think the option itself should set the aspect ratio itself, which could be set to 4:3, 5:4, 16:9, 16:10, 235:100.
Title: Re: Aspect Ratio Correction option
Post by: Volutar on May 08, 2013, 06:40:59 am
It is not possible until geoscape will be resolution-free.
There is static background under globe and shading pre-calculations which make that hard to accomplish properly. Improper accomplishing is not acceptable.
Title: Re: Aspect Ratio Correction option
Post by: Tarvis on May 08, 2013, 09:45:36 am
All I mean is letterboxing. Black borders. Not expanding the game geometry.

I haven't looked into the code yet so I can't say for sure, but if the 320x200 game is being stretched to fill the current resolution, then there should be a way to make it draw to a differently-sized poly. If rendering to the screen texture isn't one step then it could be done in post-processing just like the GL shaders are.

I'll look into it and see. The only complication I can think of at the moment is how shaders should handle this. Should they work off of the entire screen or only the letterboxed area? I'm leaning towards the latter.
Title: Re: Aspect Ratio Correction option
Post by: Volutar on May 08, 2013, 10:37:14 am
I think shaders really could handle these stretching and letterboxing techs.
Title: Re: Aspect Ratio Correction option
Post by: Tarvis on May 08, 2013, 11:30:32 am
OK! All it takes is altering the coordinates of the screen texture's triangle. As far as I can tell, geoscape and everything looks fine. It even adjusts the shaders accordingly (only curves the letterboxed area with CRT shaders, for example)!

Now I'll just write the option for it and it should be all set. How about mouse speed? Should that get adjusted too?
Title: Re: Aspect Ratio Correction option
Post by: Volutar on May 08, 2013, 11:52:25 am
It's interesting question. Black bars at sides or at top/bottom are unavailable for mouse cursor.. but game could be windowed... So it either scale this window into smaller projected area inside, or skips drawing at "black" areas.. Both of those options are not very elegant. It would be better to have black areas available for cursor.
But from those two I'd choose "quit drawing" method in windowed, and scaling for fullscreen.
Title: Re: Aspect Ratio Correction option
Post by: Tarvis on May 08, 2013, 04:49:37 pm
I think for windowed mode it would be best to ignore this option, because it doesn't make sense to have black bars in a window when the window itself can be resized instead; but at the same time it wouldn't match the selected resolution for windowed mode.

Should this option be added to the main screen or to Advanced Options? I could turn the fullscreen/windowed buttons into a toggle and use the space from that to make a button for it. I'll give it the following choices:

-Off
-Auto (Calculates using inwidth/inheight to be compatible with changed base resolution later if this feature is expanded upon, would be default)
-4:3
-5:4
-16:10
-16:9
-235:100

EDIT: Hmm, the SDL software-renderer scaling functions are too hardcore for me and I'm not sure how to adjust them for aspect ratio, so for now I've only got it implemented for OpenGL. Modifying the dst surface dimensions in _zoomSurfaceY perhaps? Also, Volutar is right, if I adjust the ScaleX/Y variables to scale mouse movement then the Geoscape screen and others get a little off, so for now the aspect ratio adjustment is purely visual.
Title: Re: Aspect Ratio Correction option
Post by: Fenyő on May 08, 2013, 11:12:00 pm
i vote it should only visual, leave the mouse.
And i vote it should be in the advanced options.
Title: Re: Aspect Ratio Correction option
Post by: Hythlodaeus on May 09, 2013, 01:43:16 am
I vote it should be added to the main screen, preferably near the resolution indicator. The advanced options menu is chiefly for gameplay enhancement features.
Title: Re: Aspect Ratio Correction option
Post by: Tarvis on May 09, 2013, 03:02:27 am
I was thinking main options screen as well. I was thinking the shader selection button could be replaced with a Software/OpenGL toggle button and then a Video Options button next to it which will take you to a list of shaders/aspect ratios. How does that sound?

If not, it could go as its own option under the volume options.


Here's (https://github.com/Tervees/OpenXcom/tree/Tervees) my fork if you want to check out what I've done so far. It slows down the game quite a bit since it's called from Refresh at the moment, but I'll move it to init/resize later so it's only called once per resolution call.

All I have left is to implement it for the software modes and figure out the options menu so I can add it there. I'll have to look over it and learn it all so it might take a while.
Attached are examples taken at 640x480 resolution.
Title: Re: Aspect Ratio Correction option
Post by: Warboy1982 on May 09, 2013, 08:29:05 pm
we have an "advanced graphics" menu planned for further down the road, so any effort you spend on learning the menus now may well be wasted. i'd say just add the functions and the option settings, and we'll take care of the menus. :)
Title: Re: Aspect Ratio Correction option
Post by: Volutar on May 09, 2013, 08:54:03 pm
aspect 16:10 is NATIVE. 320/200 = 16/10
I have 1920x1200 and it covers whole screen perfectly with x4 zoom.
Title: Re: Aspect Ratio Correction option
Post by: Tarvis on May 09, 2013, 09:09:26 pm
Indeed. Using the 'auto' setting I have will make it letterbox to 16:10. You won't notice a difference if you're already on a 16:10 resolution, but if you're using 1920x1080 like me it will letterbox it to not be as wide.

Auto doesn't just make it 16:10. Just in case the base resolution feature gets expanded upon later, the auto setting will calculate the ratio based on that. So if you change baseResolutionX/Y to 640x480, then 'auto' will set it to 4:3 instead, for example.

Can someone else try building my fork (https://github.com/Tervees/OpenXcom) for me and running it? I'm still getting a lot of slowdown in Battlescape even with my code commented out and I'm not sure why, it might just be an issue with my dependencies. I'm running VS2008...
Title: Re: Aspect Ratio Correction option
Post by: SupSuper on May 10, 2013, 03:16:13 am
Indeed. Using the 'auto' setting I have will make it letterbox to 16:10. You won't notice a difference if you're already on a 16:10 resolution, but if you're using 1920x1080 like me it will letterbox it to not be as wide.

Auto doesn't just make it 16:10. Just in case the base resolution feature gets expanded upon later, the auto setting will calculate the ratio based on that. So if you change baseResolutionX/Y to 640x480, then 'auto' will set it to 4:3 instead, for example.

Can someone else try building my fork (https://github.com/Tervees/OpenXcom) for me and running it? I'm still getting a lot of slowdown in Battlescape even with my code commented out and I'm not sure why, it might just be an issue with my dependencies. I'm running VS2008...
If you're running directly from VS, the game is gonna be a lot slower, because the "debugger" adds a lot of weight. Debug builds are also significantly slower than release builds.
Title: Re: Aspect Ratio Correction option
Post by: Tarvis on May 10, 2013, 05:57:09 am
I'm building the Release version then copying the .exe to the game directory.

Curiously, it happens if I build stock 0.9 from source, so I'm not sure what the problem is, and the resulting .exe from it is a good 337kb larger than the released build...

Would anyone mind uploading their deps folder? I'd like to rule that out, at least. The only other difference I can think of is including windows.h instead of afxres.h in OpenXcom.rc since the MFC library doesn't seem to come with VC Express 2008.
Title: Re: Aspect Ratio Correction option
Post by: SupSuper on May 10, 2013, 05:03:45 pm
Are you using statically-linked libraries? These will end up embedded into the EXE and make it bigger, as opposed to if you make them dynamically-linked (so the DLLs are separate from the game EXE).

You can find Windows deps and more details in the wiki: https://www.ufopaedia.org/index.php?title=Compiling_with_Microsoft_Visual_C%2B%2B_(OpenXcom)
Title: Re: Aspect Ratio Correction option
Post by: Tarvis on May 10, 2013, 10:20:35 pm
Hmm, I tried the deps package from there and now I'm getting "openxcom.exe has stopped working" on launch.

Sigh. I have a feeling it's yaml. If I replace it with the one I built then it runs, but it still has massive slowdown in the battlescape. It's not FPS slowdown, it stays at 60+fps the whole time, but the animation speeds are almost like they are all set to 1 even though they're at 6, even when using the software mode with no scaler at 640x400.
Title: Re: Aspect Ratio Correction option
Post by: tidegear on May 15, 2013, 05:24:18 am
Maybe the game could have an indicator marking which resolutions are x2, x3, etc. multiples of the games native resolution? This would be helpful for selecting larger resolutions and maintaining the games native aspect ratio.
Title: Re: Aspect Ratio Correction option
Post by: Tarvis on May 20, 2013, 08:13:44 pm
Maybe the game could have an indicator marking which resolutions are x2, x3, etc. multiples of the games native resolution? This would be helpful for selecting larger resolutions and maintaining the games native aspect ratio.
No need for this since I have this feature (mostly) done. I just can't build it properly :X

But if you wanted to know you can just do the calculations yourself, 320x200 is the base resolution. It would also be an issue because the game has a feature to change the base resolution, so that would need to be accounted for.

Title: Re: Aspect Ratio Correction option
Post by: tidegear on May 21, 2013, 08:47:18 am
But if you wanted to know you can just do the calculations yourself, 320x200 is the base resolution.

That's what I already did. Thanks for the input!