Community Forum

renderText position

Forum Overview >> Farming Simulator 17

CategoryFarming Simulator 17
Created29.10.2016 16:17


Tykonket (Unknown) 29.10.2016 16:22
Hi guys, I wasted 2 hours for the correct positioning of 2 rendered text, after I have tested the positions in differents resolutions and i found a big problem, until the resolution aspect ratio is 16:9 (the one I used for positioning the texts) they are positioned and scaled perfectly, but when the aspect ratio changes, both position and scale go wrong.
How can I solve this problem?

D. Ecker (Decker_MMIV) 31.10.2016 11:23
There is a global-variable called g_screenAspectRatio which you could use to calculate the widths with.

Maybe there are other already available methods/functions within the game to use, but I do currently not know of them.

My suggestions would be to primarily use height or Y-pos as the 'base', and then calculate width using the g_screenAspectRatio value.

There is also a getTextWidth() method, which could help you in determining how wide the text is, you are about to render.

Tykonket (Unknown) 02.11.2016 14:11
Ok, I already use the getTextWidth(), what I was really needing is g_screenAspectRatio.
Thank you for the answer, do you know something about how to work with the new GUI scale setting?

Tykonket (Unknown) 02.11.2016 16:34
For who will have my same problem.
Assumption: since the aspect ratio is the ratio between width and height, the x positions haven't to change between differents resolutions.
In my opinion the best solution for this problem is:

baseAspectRatio = 1.7777777777777; --this is your ratio (in my case 16:9), in which you find the correct positions
aspectRatioMultiplier = g_screenAspectRatio / baseAspectRatio;
text1.y = text1.y * aspectRatioMultiplier; --apply this to all your y positions
text1.fontsize = text1.fontsize * aspectRatioMultiplier; --apply this to all your fontsize

This is simple and will work perfectly, I suggest to use this method!
I'm still searching a way to solve the problem with HUD scale setting.


Note: Log in to post. Create a new account here.