Skip to content

Commit

Permalink
Merge #274
Browse files Browse the repository at this point in the history
274: Update the camera before PreRender fires r=pathunstrom a=astronouth7303

The camera isn't updated by the renderer until its `Render` handler, which is after everything has done their `PreRender` activities.

Change this to update the camera before `PreRender` fires, so that all rendering-related activities have the correct information.

Co-authored-by: Jamie Bliss <jamie@ivyleav.es>
  • Loading branch information
bors[bot] and AstraLuma committed May 19, 2019
2 parents d580339 + 1f95909 commit 929f58a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ppb/systems/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ def __exit__(self, exc_type, exc_val, exc_tb):
def on_idle(self, idle_event: events.Idle, signal):
self.render_clock += idle_event.time_delta
if self.render_clock > self.target_count:
self.pre_render_updates(idle_event.scene)
signal(events.PreRender())
signal(events.Render())
self.render_clock = 0

def on_render(self, render_event, signal):
self.render_background(render_event.scene)
camera = render_event.scene.main_camera
camera.viewport_width, camera.viewport_height = self.resolution
self.pixel_ratio = camera.pixel_ratio
self.render_background(render_event.scene)

self.old_resized_images = self.resized_images
self.resized_images = {}
Expand All @@ -70,6 +69,11 @@ def on_render(self, render_event, signal):
self.window.blit(resource, rectangle)
pygame.display.update()

def pre_render_updates(self, scene):
camera = scene.main_camera
camera.viewport_width, camera.viewport_height = self.resolution
self.pixel_ratio = camera.pixel_ratio

def render_background(self, scene):
self.window.fill(scene.background_color)

Expand Down

0 comments on commit 929f58a

Please sign in to comment.