-
-
Notifications
You must be signed in to change notification settings - Fork 321
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
camera viewport DOES affect camera space #732
Comments
What does work though to get something like a functioning viewport is using the clipping functionality in macroquad: const WORLD_WIDTH: f32 = 200.;
const WORLD_HEIGHT: f32 = 200.;
let mut cam = Camera2D::from_display_rect(Rect::new(0., 0., WORLD_WIDTH, WORLD_HEIGHT));
cam.zoom = Vec2::new(cam.zoom.x, -cam.zoom.y); // workaround for https:/not-fl3/macroquad/issues/171
set_camera(&cam);
unsafe {
window::get_internal_gl().quad_gl.scissor(Some((0, 0, WORLD_WIDTH as i32, WORLD_HEIGHT as i32)));
}
// ... draw sprites
unsafe {
window::get_internal_gl().quad_gl.scissor(None);
}
set_default_camera(); Now I even get the camera space that I asked for! :D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is on
master
at 4e27d18Slightly related to #171
expected behavior
The docs state that
observed behavior
I modified the rustaceanmark example minimally to try out the macroquad camera. During this I stumbled upon the fact that specifying a viewport does alter your cameras space. As you can see here specifying a viewport has the effect of zooming in:
native (Ubuntu 23.10, Nvidia GTX 1060):
wasm (Firefox and Chromium):
Code:
experiment with
from_display_rect
camera configurationI can get the right space back though, if I also set the zoom and target accordingly by using
from_display_rect
with the same dimensions as the viewport:native (and wasm looks the same):
Code:
experiments with multiple cameras
If we try to go one step further and restore the default camera (using
set_default_camera
) after drawing the sprites but before drawing the text we get this:As you can see, now the text is being scaled down.
If we do something like this instead:
we get no text drawn at all (or probably somewhere we can't see):
The text was updated successfully, but these errors were encountered: