Skip to content

Commit 1146c2b

Browse files
committed
use fbo instead of active_framebuffer, and explicitly get fbo width/height
1 parent 78c12cd commit 1146c2b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

arcade/camera/default.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,15 @@ def update_viewport(self):
5151
setting the viewport to match the size of the active
5252
framebuffer sets the viewport to None.
5353
"""
54+
# If another camera is active then the viewport was probably set
55+
# by camera.use()
5456
if self._ctx.current_camera != self or self._updating:
5557
return
5658
self._updating = True
5759

58-
if self._ctx.viewport[2] != self.width or self._ctx.viewport[3] != self.height:
60+
self._ctx.viewport[2] != self._ctx.fbo.width
61+
or self._ctx.viewport[3] != self._ctx.fbo.height
62+
):
5963
self.viewport = LBWH(*self._ctx.viewport)
6064
else:
6165
self.viewport = None
@@ -96,18 +100,19 @@ def scissor(self) -> None:
96100
def width(self) -> int:
97101
if self._viewport is not None:
98102
return int(self._viewport.width)
99-
return self._ctx.active_framebuffer.width
103+
return self._ctx.fbo.width
100104

101105
@property
102106
def height(self) -> int:
103107
if self._viewport is not None:
104108
return int(self._viewport.height)
105109
return self._ctx.active_framebuffer.height
110+
return self._ctx.fbo.height
106111

107112
def get_current_viewport(self) -> tuple[int, int, int, int]:
108113
if self._viewport is not None:
109114
return self._viewport.lbwh_int
110-
return (0, 0, self._ctx.active_framebuffer.width, self._ctx.active_framebuffer.width)
115+
return (0, 0, self._ctx.fbo.width, self._ctx.fbo.height)
111116

112117
def use(self) -> None:
113118
"""
@@ -117,7 +122,8 @@ def use(self) -> None:
117122
viewport = self.get_current_viewport()
118123

119124
self._ctx.current_camera = self
120-
self._ctx.viewport = viewport
125+
if self._ctx.viewport != viewport:
126+
self._ctx.viewport = viewport
121127
self._ctx.scissor = None if self._scissor is None else self._scissor.lbwh_int
122128

123129
self._ctx.view_matrix = Mat4()

0 commit comments

Comments
 (0)