AliceLR / megazeux

Official MegaZeux git repository
https://www.digitalmzx.com/
GNU General Public License v2.0
126 stars 21 forks source link

Merge/cleanup renderer viewport calculation code. #496

Closed AliceLR closed 1 month ago

AliceLR commented 1 month ago

This fixes numerous comments complaining about fix_viewport_ratio being used in render functions by instead calculating the viewport whenever the window is resized with a new, similar function in graphics.c. Doing this also allows the integer scaling state to be precalculated for all scaling renderers, which helps mainly opengl2 right now (but could be extended to opengl1 and glsl). The longstanding "FIXME" about the ratio being calculated using floats has also been resolved.

There are two places where this couldn't be fully fixed: opengl2 and glsl using the viewport variables in render_layer to set the viewport every time a layer is rendered. Doing this correctly requires a new start of frame callback, which would be a good idea for other reasons (charset and palette update).