Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cropping support #40

Open
brettmjohnson opened this issue May 8, 2021 · 7 comments
Open

Cropping support #40

brettmjohnson opened this issue May 8, 2021 · 7 comments

Comments

@brettmjohnson
Copy link

It would be super helpful to have an option to crop to the set aspect ratio, like in the example code you wrote here: https://github.com/britzl/publicexamples/tree/master/examples/crop_viewport

@britzl
Copy link
Owner

britzl commented May 10, 2021

Good suggestion!

@britzl
Copy link
Owner

britzl commented May 27, 2021

I started working on this but it complicates things such as screen to world calculations. I'll hopefully be able to solve the problems though.

@britzl
Copy link
Owner

britzl commented Jun 23, 2021

The latest version of Orthographic has a viewport configuration that can be used to achieve this. I will use this new functionality to implement crop support.

@cypaol
Copy link

cypaol commented Sep 29, 2022

Hi,
any news on the crop function for the orthographic camera?

@britzl
Copy link
Owner

britzl commented Sep 29, 2022

any news on the crop function for the orthographic camera?

No, I'm afraid I never had the time to look into it.

@cypaol
Copy link

cypaol commented Oct 1, 2022

No, I'm afraid I never had the time to look into it.

Ok, thanks anyway.
I incorporated part of the script from your example cited above (crop_viewport) in the ortographic.render_script,
now I have pillarbox or letterbox when the window dimension change so I can keep my aspect ratio view, works for FIXED_AUTO and FIXED_ZOOM options.
I'm new to Defold and to Lua, so maybe my implementation it's not elegant or efficient in every situation, for example the BOUNDS option doesn't work anymore.
Before I used GUI nodes to cover extra graphics I didn't want to show, it worked but also BOUNDS didn't work as intended.
But I thinks that the render script solution is more universal, If you ever update the Ortographic Camera I can rollback to the original ortographic.render_script.
For now it's ok, I can move on, I want to prototype some simple game, maybe apply to some future gamejam!

@gianmichelemariani
Copy link

Ah! Was hoping to get this to work already. I've played with modifying the default render script but the screen conversion makes things complicated, especially when having to deal with GUI as well.
I feel like this is a friction point especially for less experienced and new users and a comprehensive solution would help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants