Пример #1
0
    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 PLATFORM != PLATFORM_PI and PLATFORM != PLATFORM_ANDROID:
            n = xlib.XEventsQueued(self.opengl.d, xlib.QueuedAfterFlush)
            for _ in range(n):
                xlib.XNextEvent(self.opengl.d, self.ev)
                if self.ev.type == KeyPress or self.ev.type == KeyRelease:
                    self.event_list.append(self.ev)
                elif 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
            cameras = Camera.all_instances()
            if cameras is not None:
                for camera in cameras:
                    camera.was_moved = False

        if self.tidy_needed:
            self._tidy()
Пример #2
0
    def _loop_begin(self):
        # TODO(rec):  check if the window was resized and resize it, removing
        # code from MegaStation to here.
        if PLATFORM == PLATFORM_WINDOWS:
            if pygame.event.get(pygame.QUIT):
                self.destroy()
        elif PLATFORM != PLATFORM_PI and PLATFORM != 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()