Skip to content

Add camera stack for better context switching and safer draw loops #2230

@DragonMoffon

Description

@DragonMoffon

Currently, only the currently active camera is stored. It would be ideal if more information were stored about every camera activation during a draw loop.

An example of the kind of issue the camera stack fixes:
Window draw call

  self.clear()
  self.camera_b.position = self.center
  self.camera_b.use()
  arcade.draw_rect_filled(self.rectangle, (255, 0, 0, 125), self.angle)

  with self.camera_a.activate():
      self.camera_b.position = 100, 100
      arcade.draw_rect_filled(self.rectangle, (255, 0, 0, 255), self.angle)

  arcade.draw_rect_filled(self.rectangle, (255, 0, 0, 125), self.angle)

Current technically correct behaviour

20240703-0506-31.2243384.mp4

Improved behaviour post-stack implimentation

20240703-0507-24.0007072.mp4

It also allows for better camera context mangers i.e.

with self.camera:
   ...

rather than

with self.camera.activate():
   ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions