Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions arcade/gl/backends/webgl/framebuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,21 +256,15 @@ def __init__(self, ctx: WebGLContext):

@DefaultFrameBuffer.viewport.setter
def viewport(self, value: tuple[int, int, int, int]):
# This is the exact same as the WebGLFramebuffer setter
# This is very similar to the OpenGL backend setter
# WebGL backend doesn't need to handle pixel scaling for the
# default framebuffer like desktop does, the browser does that
# for us. However we need a separate implementation for the
# function because of ABC
if not isinstance(value, tuple) or len(value) != 4:
raise ValueError("viewport shouldbe a 4-component tuple")

ratio = self.ctx.window.get_pixel_ratio()
self._viewport = (
int(value[0] * ratio),
int(value[1] * ratio),
int(value[2] * ratio),
int(value[3] * ratio),
)
self._viewport = value

if self._ctx.active_framebuffer == self:
self._ctx._gl.viewport(*self._viewport)
Expand All @@ -281,23 +275,11 @@ def viewport(self, value: tuple[int, int, int, int]):

@DefaultFrameBuffer.scissor.setter
def scissor(self, value):
# This is the exact same as the WebGLFramebuffer setter
# WebGL backend doesn't need to handle pixel scaling for the
# default framebuffer like desktop does, the browser does that
# for us. However we need a separate implementation for the
# function because of ABC
if value is None:
self._scissor = None
if self._ctx.active_framebuffer == self:
self._ctx._gl.scissor(*self._viewport)
else:
ratio = self.ctx.window.get_pixel_ratio()
self._scissor = (
int(value[0] * ratio),
int(value[1] * ratio),
int(value[2] * ratio),
int(value[3] * ratio),
)

self._scissor = value
if self._ctx.active_framebuffer == self:
self._ctx._gl.scissor(*self._scissor)
Loading