tetra
tetra copied to clipboard
Add some utility methods to ScreenScaler
This PR would add some useful utility methods to the ScreenScaler
struct.
First of all the current sizes (inner and outer) can easily be retrieved.
Furthermore a scaling factor can be calculated. The scaling factor is a single floating point number, representing how much unscaled objects need to be scaled up (or down respectively) in order to fit the screen using the ScalingMode
of the screen scaler.
Motivation
This would allow easy integration of 3rd party libraries using the OpenGL context (e.g. UI libraries).
fn update(&mut self, ctx: &mut Context) -> Result<(), Error> {
self.ui_scale = self.scaler.scale_factor();
}
fn draw(&mut self, ctx: &mut Context) -> Result<(), Error> {
ui_library::draw(ctx, &self.ui, self.ui_scale); // Just some pseudo usage example of a 3rd party library
}
This seems like a no-brainer to add - I'll probably merge this after work :)
Sorry for the delay - thank you for the PR!
No problem! Thanks for merging