opengl: padding is done via ortho matrix rather than viewport

This commit is contained in:
Mitchell Hashimoto
2022-11-14 13:13:50 -08:00
parent 4cab24a3da
commit 184b43ebd6

View File

@ -975,10 +975,10 @@ fn setScreenSize(self: *OpenGL, dim: renderer.ScreenSize) !void {
// Update our viewport for this context to be the entire window. // Update our viewport for this context to be the entire window.
// OpenGL works in pixels, so we have to use the pixel size. // OpenGL works in pixels, so we have to use the pixel size.
try gl.viewport( try gl.viewport(
@floatToInt(i32, padding.left), 0,
@floatToInt(i32, padding.bottom), 0,
@intCast(i32, padded_dim.width), @intCast(i32, dim.width),
@intCast(i32, padded_dim.height), @intCast(i32, dim.height),
); );
// Update the projection uniform within our shader // Update the projection uniform within our shader
@ -990,10 +990,10 @@ fn setScreenSize(self: *OpenGL, dim: renderer.ScreenSize) !void {
// 2D orthographic projection with the full w/h // 2D orthographic projection with the full w/h
math.ortho2d( math.ortho2d(
0, -1 * padding.left,
@intToFloat(f32, padded_dim.width), @intToFloat(f32, padded_dim.width),
@intToFloat(f32, padded_dim.height), @intToFloat(f32, padded_dim.height),
0, -1 * padding.top,
), ),
); );
} }