Fix y inversion on examples
When building project with current macroquad version I'd found issue with camera. When a camera is set, the screen got inverted y.
After that I've found #618 and checked other examples. I've found that not only platformer has inverted y, but also tree and arkanoid. This examples use Camera2D just like the platfornmer example. I've checked Camera2D code and found this inversion if not drawn on render target.
Am I right to remove inversion or this issues should be fixed other way?
Hi, thanks for PR, camera's Y sure is messed up! Tho I am not quite sure if the proposed fix is really the solution: there are quite a few related problems https://github.com/not-fl3/macroquad/issues/171
Okay, I'll look on related issues
I've done some research and found 3 issues related to this problem: #171, #578 and #618.
After reading code of the examples that use Camera2D I've found that in the letterbox example there is a flipping y axis with comment that render_target drawn upside down.
Also, the second issue gave me thought about fixing problem. So now all this issues can be fixed using this PR.
Although, I think that drawing into camera has issue on miniquad side when render_target is not set (that's why the if before setting zoom camera is present).
After looking at code of triangle example in miniquad I've found that in miniquad higher values of y means higher position on screen, whereas in macroquad higher values of y means lower position in screen. So we need to flip y axis to do correct drawing. For the default camera it is done by pixel_perfect_projection_matrix function.
The only problem for now is that if we want to draw on render target it's drawn upside down.
Currently this PR fixes issues #171, #578, #618: default camera is correct, examples drawn correctly. Also, zoom for camera can be set intuitively without rotating y (zoom: vec2(1, 1))
@not-fl3 I suppose this PR should be merged as is, I'll continue to work on render target issue on the miniquad side.
So, I'm aware this was supposed to fix Y inversion but it used to work for me with zero issues. I'm now running the platformer example (copied into my own project with now changes) and it's inverted...
In the past when I ran this example (quite a while ago) things were fine. But I've noticed that it's upside down for me now.
NOTE: I'm on Fedora 38, BSPWM, X11, Nvidia drivers.
In the past when I ran this example (quite a while ago) things were fine. But I've noticed that it's upside down for me now.
@BenMcAvoy Thanks for the running. So as I understood, if you run platformer example on the master branch you'll have correct y rotation, and on the current branch - inverted, right?
Can you also try letterbox example? It's doing both drawing onto render target and on the screen, so would be valuable info
In the master branch, the platformer example is flipped. The letterbox example is not flipped.
In the master branch, the
platformerexample is flipped. Theletterboxexample is not flipped.
Well, that's strange that with master and fix_y_inversion branches you have identical results as in new branch I've flipped results.
NOTE: I've noticed that you've said
copied into my own project with now changes
... but there is no changes to platformer example, I've changed macroquad's camera logic.
Ah, sorry. I pulled changes and everything is working great! Platformer example isn't flipped and neither is letterbox on your branch (fix_y_inversion). Seems to work great, well done!
Could this get merged? The current flip is quite confusing and this fix seems sound.
This could be merged, but I am a little confused on how those axises should behave myself and where it is supposed to be up or down.
I want to collect all the questionable cases somewhere (maybe here? https://github.com/not-fl3/quadtest) before merging this.
but I am super slow with that :|