[Solved] Weird camera zoom on fullscreen

So I know there is a similar issue before, when this was posted. But try as I might, I wasn’t able to work through the issue.

The camera works fine in windowed mode, but when fullscreening, it focuses on the bottom left corner and zooms in, meaning it’s not possible to just move the camera over or zoom out to fix the issue (an attempt was made for that, and that only resulted in focusing on the center of the screen (which is great!) but cutting off all the edges (which is not so great!)). Trying to scale up the quad when fullscreening doesn’t work either. It’s also not the GUI getting in the way because I’ve tried disabling the rendering for that already. Attempting to recreate the render targets on window size change (as shown in the post above) wasn’t working either.


(^How it would normally look)


(^Attempt to scale up the quad, move the camera, etc.)

Is this because I was trying to write something for blending by rendering stuff onto a quad?
Maybe something to do with setting viewports / views?
I’m still not very familiar with how the rendering stuff works, so please explain things I might be missing.

Nevermind, figured it out

Just had to dynamically adjust zoom and camera offset for different screen sizes!

For those in the future who run into a similar problem, hopefully this solution will save you a few hours of headache:

For the camera zooming:
[Original zoom] * ([Original window height]/[Current window height])
For the camera positioning:
X offset: ([Current window width]-[Original window width]) / (2 * [Original zoom])
Y offset: ([Current window height-[Original window height]) / (2 * [Original zoom])

If using a render target and rendering onto a quad, quad scaling:
[Current window height]/[Original window height]

These formulas assume that your camera is positioned at the center of your screen.
I find DefOS will help tremendously here because it can easily get you the window position and dimensions with x,y,w,h = defos.get_window_size().

3 Likes