rgrams / rendercam

A universal render script & camera package for all the common camera types. (for Defold)
The Unlicense
98 stars 18 forks source link

Use "fixed width" or "fixed height" based on window aspect ratio #7

Open subsoap opened 6 years ago

subsoap commented 6 years ago

For a game project I want to be able to scale the game to maintain a 16:9 gameplay area. But with the area to the left and ride drawn, but not the top and bottom areas as the window is scaled.

I think only way to get this right now without changing rendercam source would be to have two camera objects and toggle them based on window ratio? One with fixed aspect ratio enabled for taller more than wider, and the other with fixed aspect ratio disabled + fixed height for wider more than taller. Do you think it would be useful to add support for this without needing two camera objects? Would need option for portrait / landscape both.

It would also be useful to have a max width / max height so that only up to that distance is drawn but aspect ratio is still maintained.

This is for orthographic projects.

rgrams commented 6 years ago

Can you give me an example project with this working with two cameras? That way I can see and test exactly what you want.

subsoap commented 6 years ago

Here is a sample. Resize the window so that it is very wide and a little tall / a little tall and very wide.

rendercam_test.zip

rgrams commented 6 years ago

Gotcha, thanks. So black bars on the top, but never on the sides. Or fixed height, only with a minimum width. I can see how you would want this. Hmm . . . I'll have to think about the best way to do it. It might be easiest to just support changing cameras at runtime, so you could do what you have already, only with one camera. You can use Rendercam's "window_update" subscribe thing instead of doing it every update.