Exemplo n.º 1
0
Arquivo: Display.py Projeto: bpow/pi3d
  def _loop_begin(self):
    # TODO(rec):  check if the window was resized and resize it, removing
    # code from MegaStation to here.
    if pi3d.USE_PYGAME:
      import pygame # although done in __init__ ...python namespaces aarg!!!
      if pygame.event.get(pygame.QUIT):
        self.destroy()
    elif pi3d.PLATFORM != pi3d.PLATFORM_PI and pi3d.PLATFORM != pi3d.PLATFORM_ANDROID:
      n = xlib.XEventsQueued(self.opengl.d, xlib.QueuedAfterFlush)
      for i in range(n):
        if xlib.XCheckMaskEvent(self.opengl.d, KeyPressMask, self.ev):
          self.event_list.append(self.ev)
        else:
          xlib.XNextEvent(self.opengl.d, self.ev)
          if self.ev.type == ClientMessage:
            if (self.ev.xclient.data.l[0] == self.opengl.WM_DELETE_WINDOW.value):
              self.destroy()
    self.clear()
    with self.lock:
      self.sprites_to_load, to_load = set(), self.sprites_to_load
      self.sprites.extend(to_load)
    self._for_each_sprite(lambda s: s.load_opengl(), to_load)

    if MARK_CAMERA_CLEAN_ON_EACH_LOOP:
      from pi3d.Camera import Camera
      camera = Camera.instance()
      if camera is not None:
        camera.was_moved = False

    if self.tidy_needed:
      self._tidy()
Exemplo n.º 2
0
    def _loop_begin(self):
        # TODO(rec):  check if the window was resized and resize it, removing
        # code from MegaStation to here.
        if not ON_PI:
            n = xlib.XEventsQueued(self.opengl.d, xlib.QueuedAfterFlush)
            for i in range(n):
                if xlib.XCheckMaskEvent(self.opengl.d, KeyPressMask, self.ev):
                    self.event_list.append(self.ev)
                else:
                    xlib.XNextEvent(self.opengl.d, self.ev)
                    if self.ev.type == ClientMessage:
                        if (self.ev.xclient.data.l[0] ==
                                self.opengl.WM_DELETE_WINDOW.value):
                            self.destroy()
        self.clear()
        with self.lock:
            self.sprites_to_load, to_load = set(), self.sprites_to_load
            self.sprites.extend(to_load)
        self._for_each_sprite(lambda s: s.load_opengl(), to_load)

        if MARK_CAMERA_CLEAN_ON_EACH_LOOP:
            from pi3d.Camera import Camera
            camera = Camera.instance()
            if camera:
                camera.was_moved = False

        if self.tidy_needed:
            self._tidy()