Python pygame.DOUBLEBUF Examples

The following are 30 code examples of pygame.DOUBLEBUF(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pygame , or try the search function .
Example #1
Source File: display_test.py    From fxxkpython with GNU General Public License v3.0 6 votes vote down vote up
def todo_test_flip(self):

        # __doc__ (as of 2008-08-02) for pygame.display.flip:

          # pygame.display.flip(): return None
          # update the full display Surface to the screen
          #
          # This will update the contents of the entire display. If your display
          # mode is using the flags pygame.HWSURFACE and pygame.DOUBLEBUF, this
          # will wait for a vertical retrace and swap the surfaces. If you are
          # using a different type of display mode, it will simply update the
          # entire contents of the surface.
          #
          # When using an pygame.OPENGL display mode this will perform a gl buffer swap.

        self.fail() 
Example #2
Source File: display_test.py    From fxxkpython with GNU General Public License v3.0 6 votes vote down vote up
def todo_test_flip(self):

        # __doc__ (as of 2008-08-02) for pygame.display.flip:

          # pygame.display.flip(): return None
          # update the full display Surface to the screen
          #
          # This will update the contents of the entire display. If your display
          # mode is using the flags pygame.HWSURFACE and pygame.DOUBLEBUF, this
          # will wait for a vertical retrace and swap the surfaces. If you are
          # using a different type of display mode, it will simply update the
          # entire contents of the surface.
          #
          # When using an pygame.OPENGL display mode this will perform a gl buffer swap.

        self.fail() 
Example #3
Source File: integrations_all_in_one.py    From pyimgui with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def main_pygame():
    pygame.init()
    size = 800, 600
    pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL)
    io = imgui.get_io()
    io.fonts.add_font_default()
    io.display_size = size
    renderer = PygameRenderer()
    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
            renderer.process_event(event)
        imgui.new_frame()
        on_frame()
        # note: cannot use screen.fill((1, 1, 1)) because pygame's screen
        #       does not support fill() on OpenGL sufraces
        gl.glClearColor(1, 1, 1, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        imgui.render()
        pygame.display.flip() 
Example #4
Source File: display_test.py    From fxxkpython with GNU General Public License v3.0 6 votes vote down vote up
def todo_test_flip(self):

        # __doc__ (as of 2008-08-02) for pygame.display.flip:

          # pygame.display.flip(): return None
          # update the full display Surface to the screen
          #
          # This will update the contents of the entire display. If your display
          # mode is using the flags pygame.HWSURFACE and pygame.DOUBLEBUF, this
          # will wait for a vertical retrace and swap the surfaces. If you are
          # using a different type of display mode, it will simply update the
          # entire contents of the surface.
          #
          # When using an pygame.OPENGL display mode this will perform a gl buffer swap.

        self.fail() 
Example #5
Source File: carla_env.py    From gym-carla with MIT License 6 votes vote down vote up
def _init_renderer(self):
    """Initialize the birdeye view renderer.
    """
    pygame.init()
    self.display = pygame.display.set_mode(
    (self.display_size * 3, self.display_size),
    pygame.HWSURFACE | pygame.DOUBLEBUF)

    pixels_per_meter = self.display_size / self.obs_range
    pixels_ahead_vehicle = (self.obs_range/2 - self.d_behind) * pixels_per_meter
    birdeye_params = {
      'screen_size': [self.display_size, self.display_size],
      'pixels_per_meter': pixels_per_meter,
      'pixels_ahead_vehicle': pixels_ahead_vehicle
    }
    self.birdeye_render = BirdeyeRender(self.world, birdeye_params) 
Example #6
Source File: screen_manager.py    From coiltraine with MIT License 6 votes vote down vote up
def start_screen(self, resolution, aspect_ratio, scale=1):

        self._resolution = resolution

        self._aspect_ratio = aspect_ratio
        self._scale = scale

        size = (resolution[0] * aspect_ratio[0], resolution[1] * aspect_ratio[1])

        self._screen = pygame.display.set_mode((size[0] * scale, size[1] * scale), pygame.DOUBLEBUF)

        # self._screen.set_alpha(None)

        pygame.display.set_caption("Human/Machine - Driving Software")

        self._camera_surfaces = []

        for i in range(aspect_ratio[0] * aspect_ratio[1]):
            camera_surface = pygame.surface.Surface(resolution, 0, 24).convert()

            self._camera_surfaces.append(camera_surface) 
Example #7
Source File: dash.py    From gamedev with MIT License 5 votes vote down vote up
def __init__(self):
        # initialize game settings
        # os.environ['SDL_VIDEO_CENTERED'] = '1'
        # os.environ['SDL_VIDEO_WINDOW_POS'] = '0,0'
        pygame.init()
        # pygame.mixer.init()
        flags = pygame.DOUBLEBUF | pygame.HWSURFACE  # | pygame.FULLSCREEN
        self.screen = pygame.display.set_mode((WIDTH, HEIGHT), flags)
        pygame.display.set_caption("My Game")
        self.clock = pygame.time.Clock()
        self.load_data()
        font = pygame.font.match_font("Ubuntu Mono")
        self.menu = GameMenu(self, "Dash!", ["Play", "Options", "Quit"], font=font, font_size=30,
                             padding=20) 
Example #8
Source File: render.py    From macad-gym with MIT License 5 votes vote down vote up
def multi_view_render(images, unit_dimension, actor_configs):
    """Render images based on pygame > 1.9.4

    Args:
        images (dict):
        unit_dimension (list): window size, e.g., [84, 84]
        actor_configs (dict): configs of actors

    Returns:
        N/A.
    """
    global i
    pygame.init()
    surface_seq = ()
    poses, window_dim = get_surface_poses(
        len(images), unit_dimension, images.keys())

    # Get all surfaces.
    for actor_id, im in images.items():
        if not actor_configs[actor_id]["render"]:
            continue
        surface = pygame.surfarray.make_surface(im.swapaxes(0, 1) * 128 + 128)
        surface_seq += ((surface, (poses[actor_id][1], poses[actor_id][0])), )

    display = pygame.display.set_mode((window_dim[0], window_dim[1]),
                                      pygame.HWSURFACE | pygame.DOUBLEBUF)
    display.blits(blit_sequence=surface_seq, doreturn=1)
    pygame.display.flip()
    # save to disk
    # pygame.image.save(display,
    #                   "/mnt/DATADRIVE1/pygame_surfs/" + str(i) + ".jpeg")
    i += 1 
Example #9
Source File: window.py    From moderngl-window with MIT License 5 votes vote down vote up
def __init__(self, **kwargs):
        super().__init__(**kwargs)

        pygame.display.init()

        pygame.display.gl_set_attribute(pygame.GL_CONTEXT_MAJOR_VERSION, self.gl_version[0])
        pygame.display.gl_set_attribute(pygame.GL_CONTEXT_MINOR_VERSION, self.gl_version[1])
        pygame.display.gl_set_attribute(pygame.GL_CONTEXT_PROFILE_MASK, pygame.GL_CONTEXT_PROFILE_CORE)
        pygame.display.gl_set_attribute(pygame.GL_CONTEXT_FORWARD_COMPATIBLE_FLAG, 1)
        pygame.display.gl_set_attribute(pygame.GL_DOUBLEBUFFER, 1)
        pygame.display.gl_set_attribute(pygame.GL_DEPTH_SIZE, 24)

        if self.samples > 1:
            pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 1)
            pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, self.samples)

        self._depth = 24
        self._flags = pygame.OPENGL | pygame.DOUBLEBUF
        if self.fullscreen:
            self._flags |= pygame.FULLSCREEN

            info = pygame.display.Info()
            desktop_size = info.current_w, info.current_h
            self._width, self._height = desktop_size
            self._buffer_width, self._buffer_height = self._width, self._height
        else:
            if self.resizable:
                self._flags |= pygame.RESIZABLE

        self._set_mode()
        self.title = self._title
        self.cursor = self._cursor
        self.init_mgl_context()
        self.set_default_viewport() 
Example #10
Source File: doomwrapper.py    From humanRL_prior_games with MIT License 5 votes vote down vote up
def __init__(self, width, height):
        self.width = width
        self.height = height

        pygame.init()
        self.window = pygame.display.set_mode( (self.width, self.height), pygame.DOUBLEBUF, 24 )
        pygame.display.set_caption("PLE ViZDoom") 
Example #11
Source File: carla_manual_control.py    From ros-bridge with MIT License 5 votes vote down vote up
def main():
    """
    main function
    """
    rospy.init_node('carla_manual_control', anonymous=True)

    role_name = rospy.get_param("~role_name", "ego_vehicle")

    # resolution should be similar to spawned camera with role-name 'view'
    resolution = {"width": 800, "height": 600}

    pygame.init()
    pygame.font.init()
    pygame.display.set_caption("CARLA ROS manual control")
    world = None
    try:
        display = pygame.display.set_mode(
            (resolution['width'], resolution['height']),
            pygame.HWSURFACE | pygame.DOUBLEBUF)

        hud = HUD(role_name, resolution['width'], resolution['height'])
        world = World(role_name, hud)
        controller = KeyboardControl(role_name, hud)

        clock = pygame.time.Clock()

        while not rospy.core.is_shutdown():
            clock.tick_busy_loop(60)
            if controller.parse_events(clock):
                return
            hud.tick(clock)
            world.render(display)
            pygame.display.flip()

    finally:
        if world is not None:
            world.destroy()
        pygame.quit() 
Example #12
Source File: war.py    From gamedev with MIT License 5 votes vote down vote up
def __init__(self):
        pygame.init()
        # pygame.mixer.init()
        flags = pygame.DOUBLEBUF | pygame.HWSURFACE  # | pygame.FULLSCREEN
        self.screen = pygame.display.set_mode((WIDTH, HEIGHT), flags)
        pygame.display.set_caption(TITLE)
        self.clock = pygame.time.Clock()
        self.OFFSET = OFFSET
        self.load_data() 
Example #13
Source File: part_test2.py    From gamedev with MIT License 5 votes vote down vote up
def __init__(self):
        pygame.init()
        flags = pygame.DOUBLEBUF  # | pygame.HWSURFACE | pygame.FULLSCREEN
        self.screen = pygame.display.set_mode((WIDTH, HEIGHT), flags)
        self.clock = pygame.time.Clock()
        self.new() 
Example #14
Source File: part_test_ship.py    From gamedev with MIT License 5 votes vote down vote up
def __init__(self):
        pygame.init()
        flags = pygame.DOUBLEBUF  # | pygame.HWSURFACE | pygame.FULLSCREEN
        self.screen = pygame.display.set_mode((WIDTH, HEIGHT), flags)
        self.clock = pygame.time.Clock()
        self.new() 
Example #15
Source File: manual_control.py    From scenario_runner with MIT License 5 votes vote down vote up
def game_loop(args):
    pygame.init()
    pygame.font.init()
    world = None

    try:
        client = carla.Client(args.host, args.port)
        client.set_timeout(2.0)

        display = pygame.display.set_mode(
            (args.width, args.height),
            pygame.HWSURFACE | pygame.DOUBLEBUF)

        hud = HUD(args.width, args.height)
        world = WorldSR(client.get_world(), hud, args)
        controller = KeyboardControl(world, args.autopilot)

        clock = pygame.time.Clock()
        while True:
            clock.tick_busy_loop(60)
            if controller.parse_events(client, world, clock):
                return
            if not world.tick(clock):
                return
            world.render(display)
            pygame.display.flip()

    finally:

        if (world and world.recording_enabled):
            client.stop_recorder()

        if world is not None:
            world.destroy()

        pygame.quit()


# ==============================================================================
# -- main() --------------------------------------------------------------------
# ============================================================================== 
Example #16
Source File: map_test.py    From gamedev with MIT License 5 votes vote down vote up
def __init__(self):
        pygame.init()
        os.environ['SDL_VIDEODRIVER'] = 'fbcon'
        flags = pygame.DOUBLEBUF | pygame.HWSURFACE  # | pygame.FULLSCREEN
        self.screen = pygame.display.set_mode((WIDTH, HEIGHT), flags)
        self.screen_rect = self.screen.get_rect()
        pygame.display.set_caption("Map Test")
        self.clock = pygame.time.Clock()
        self.load_data() 
Example #17
Source File: display_test.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def todo_test_flip(self):

        # __doc__ (as of 2008-08-02) for pygame.display.flip:

          # pygame.display.flip(): return None
          # update the full display Surface to the screen
          #
          # This will update the contents of the entire display. If your display
          # mode is using the flags pygame.HWSURFACE and pygame.DOUBLEBUF, this
          # will wait for a vertical retrace and swap the surfaces. If you are
          # using a different type of display mode, it will simply update the
          # entire contents of the surface.
          #
          # When using an pygame.OPENGL display mode this will perform a gl buffer swap.

        self.fail() 
Example #18
Source File: manual_control.py    From macad-gym with MIT License 5 votes vote down vote up
def game_loop(args):
    pygame.init()
    pygame.font.init()
    world = None

    try:
        client = carla.Client(args.host, args.port)
        client.set_timeout(2.0)

        display = pygame.display.set_mode(
            (args.width, args.height),
            pygame.HWSURFACE | pygame.DOUBLEBUF)

        hud = HUD(args.width, args.height)
        world = World(client.get_world(), hud)
        controller = KeyboardControl(world, args.autopilot)

        clock = pygame.time.Clock()
        while True:
            clock.tick_busy_loop(60)
            if controller.parse_events(world, clock):
                return
            world.tick(clock)
            world.render(display)
            pygame.display.flip()

    finally:

        if world is not None:
            world.destroy()

        pygame.quit()


# ==============================================================================
# -- main() --------------------------------------------------------------------
# ============================================================================== 
Example #19
Source File: Base.py    From three.py with MIT License 5 votes vote down vote up
def setWindowSize(self, width, height):
        self.screenSize = (width, height)
        self.displayFlags = pygame.DOUBLEBUF | pygame.OPENGL | pygame.RESIZABLE
        self.screen = pygame.display.set_mode( self.screenSize, self.displayFlags )
        
    # implement by extending class 
Example #20
Source File: doomwrapper.py    From mlclass with MIT License 5 votes vote down vote up
def __init__(self, width, height):
        self.width = width
        self.height = height

        pygame.init()
        self.window = pygame.display.set_mode( (self.width, self.height), pygame.DOUBLEBUF, 24 )
        pygame.display.set_caption("PLE ViZDoom") 
Example #21
Source File: scene.py    From wasabi2d with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _make_context(self, width, height):
        """Create the ModernGL context."""
        glconfig = {
            'GL_CONTEXT_MAJOR_VERSION': 4,
            'GL_CONTEXT_PROFILE_MASK': pygame.GL_CONTEXT_PROFILE_CORE,
        }

        for k, v in glconfig.items():
            k = getattr(pygame, k)
            pygame.display.gl_set_attribute(k, v)

        dims = width, height
        flags = pygame.OPENGL | pygame.DOUBLEBUF

        if self.fullscreen:
            # SDL's detection for "legacy" fullscreen seems to fail on
            # Ubuntu 16.04 at least. Set an environment variable so that it
            # asks the Window Manager for full screen mode instead.
            # https://github.com/spurious/SDL-mirror/blob/c8b01e282dfd49ea8bbf1faec7fd65d869ea547f/src/video/x11/SDL_x11window.c#L1468
            os.environ['SDL_VIDEO_X11_LEGACY_FULLSCREEN'] = "0"

            flags |= pygame.FULLSCREEN
            if not self._scaler:
                self._scaler = 'linear'
            dims = 0, 0
        elif self._scaler:
            flags |= pygame.SCALED

        pygame.display.set_mode(
            dims,
            flags=flags,
            depth=24
        )
        ctx = moderngl.create_context(require=410)

        self._real_size = pygame.display.get_window_size()
        if self._real_size != (width, height):
            self.drawer = self._make_scaler(ctx, (width, height))
        return ctx 
Example #22
Source File: game_items.py    From alien-invasion-game with MIT License 5 votes vote down vote up
def __init__(self, ai_settings: Settings, stats: GameStats, **kwargs: game_items_types):
        """Initialize with default items unless specified in kwargs."""

        # Default initializations for game items.
        # Initialize screen.
        flags = pygame.HWSURFACE | pygame.DOUBLEBUF    # | pygame.FULLSCREEN
        self.screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height), flags)
        pygame.display.set_caption("Alien Invasion Game")

        # Initialize ship.
        self.ship = Ship(ai_settings, self.screen)

        # Initialize aliens group.
        self.aliens = Group()

        # Initialize bullets group.
        self.bullets = Group()

        # Initialize buttons.
        self.play_button = Button(self.screen, "Play!")

        # TODO implement Restart and Cancel buttons.
        # self.restart_button = Button(self.screen, "Restart")
        # self.cancel_button = Button(self.screen, "Cancel", (255, 0, 0, 80))
        # self.set_button_pos()

        # Initialize scorecard.
        self.sb = Scorecard(ai_settings, stats, self.screen)

        # Set the game items for those default values are given.
        for game_item in kwargs:
            if game_item in self.acceptable_game_items:
                self.__setattr__(game_item, kwargs[game_item]) 
Example #23
Source File: env_utils.py    From tensorforce with Apache License 2.0 5 votes vote down vote up
def get_display(window_size, mode=pygame.HWSURFACE | pygame.DOUBLEBUF):
    """Returns a display used to render images and text.
        :param window_size: a tuple (width: int, height: int)
        :param mode: pygame rendering mode. Default: pygame.HWSURFACE | pygame.DOUBLEBUF
        :return: a pygame.display instance.
    """
    return pygame.display.set_mode(window_size, mode) 
Example #24
Source File: carla_task.py    From VerifAI with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def run_task(self, sample):
        try:
            pygame.init()
            pygame.font.init()
            self.hud = HUD(*self.display_dim)
            self.display = pygame.display.set_mode(
                self.display_dim,
                pygame.HWSURFACE | pygame.DOUBLEBUF
            )
            # print("[carla_task] Setting up world.")
            if self.client.get_world().get_map().name == self.world_map:
                self.world = World(self.client.get_world(), self.hud, 
                        cam_transform=self.cam_transform)
            else:
                self.world = World(self.client.load_world(self.world_map), 
                        self.hud, cam_transform=self.cam_transform)
            # print("[carla_task] World setup complete.")
            self.use_sample(sample)
            self.world.restart()
            self.timestep = 0
            while self.timestep < self.n_sim_steps:
                self.step_world()
                self.timestep += 1
            traj = self.trajectory_definition()
        finally:
            self.world.destroy()
            pygame.quit()
        return traj 
Example #25
Source File: doomwrapper.py    From PyGame-Learning-Environment with MIT License 5 votes vote down vote up
def __init__(self, width, height):
        self.width = width
        self.height = height

        pygame.init()
        self.window = pygame.display.set_mode( (self.width, self.height), pygame.DOUBLEBUF, 24 )
        pygame.display.set_caption("PLE ViZDoom") 
Example #26
Source File: human_agent.py    From scenario_runner with MIT License 5 votes vote down vote up
def __init__(self, parent):
        self.quit = False
        self._parent = parent
        self._width = 800
        self._height = 600
        self._throttle_delta = 0.05
        self._steering_delta = 0.01
        self._surface = None

        pygame.init()
        pygame.font.init()
        self._clock = pygame.time.Clock()
        self._display = pygame.display.set_mode((self._width, self._height), pygame.HWSURFACE | pygame.DOUBLEBUF)
        pygame.display.set_caption("Human Agent") 
Example #27
Source File: no_rendering_mode.py    From scenario_runner with MIT License 5 votes vote down vote up
def game_loop(args):
    try:
        # Init Pygame
        pygame.init()
        display = pygame.display.set_mode(
            (args.width, args.height),
            pygame.HWSURFACE | pygame.DOUBLEBUF)
        pygame.display.set_caption(args.description)

        font = pygame.font.Font(pygame.font.get_default_font(), 20)
        text_surface = font.render('Rendering map...', True, COLOR_WHITE)
        display.blit(text_surface, text_surface.get_rect(center=(args.width / 2, args.height / 2)))
        pygame.display.flip()

        # Init modules
        input_module = ModuleInput(MODULE_INPUT)
        hud_module = ModuleHUD(MODULE_HUD, args.width, args.height)
        world_module = ModuleWorld(MODULE_WORLD, args, timeout=2.0)

        # Register Modules
        module_manager.register_module(world_module)
        module_manager.register_module(hud_module)
        module_manager.register_module(input_module)

        module_manager.start_modules()

        clock = pygame.time.Clock()
        while True:
            clock.tick_busy_loop(60)

            module_manager.tick(clock)
            module_manager.render(display)

            pygame.display.flip()

    except KeyboardInterrupt:
        print('\nCancelled by user. Bye!')

    finally:
        if world_module is not None:
            world_module.destroy() 
Example #28
Source File: spawn_control.py    From macad-gym with MIT License 4 votes vote down vote up
def game_loop(args):
    pygame.init()
    pygame.font.init()
    world = None
    all_done = False
    step = 0
    try:
        client = carla.Client(args.host, args.port)
        client.set_timeout(2.0)

        display = pygame.display.set_mode((args.width, args.height),
                                          pygame.HWSURFACE | pygame.DOUBLEBUF)

        hud = HUD(args.width, args.height)
        world = World(client.get_world(), hud)
        # lights = TrafficLight(world._vehicle)
        # traffic_light_state = lights._test_for_traffic_light(world._vehicle)
        # print(traffic_light_state)
        controller = KeyboardControl(world, args.autopilot)

        #        fast_scenario =  FastScenario(world)
        #        fast_scenario.execute()

        clock = pygame.time.Clock()
        while not all_done:
            step += 1
            clock.tick_busy_loop(60)
            curr, done = world.update_measurements(step)
            if False not in done:
                all_done = True
                print("all scenario done!")
            if step % 21 == 0 or all_done:
                print(curr, file=open("spawn_measurement.txt", "a"))
                world.current_vechicle_waypoints_tracking()
#                print("computing reward ...")
#                print(done)

            if controller.parse_events(world, clock):
                return
            world.tick(clock)
            world.render(display, world.camera_index)
            pygame.display.flip()

    finally:

        if world is not None:
            world.destroy()

        pygame.quit()


# ==============================================================================
# -- main() --------------------------------------------------------------------
# ============================================================================== 
Example #29
Source File: vehicle_manager.py    From macad-gym with MIT License 4 votes vote down vote up
def apply_control(self, ctrl_args):
        """Apply control to current vehicle.

        Args:
            ctrl_args(list): send control infor, e.g., throttle.

        Returns:
            N/A.

        """
        config = self._config
        if config['manual_control']:
            clock = pygame.time.Clock()
            # pygame
            self._display = pygame.display.set_mode(
                (800, 600), pygame.HWSURFACE | pygame.DOUBLEBUF)
            logging.debug('pygame started')
            controller = KeyboardControl(self._world, False)
            controller.actor_id = ctrl_args[5]  # only in manual_control mode
            controller.parse_events(self, clock)
            self._on_render()
        elif config["auto_control"]:
            self._vehicle.set_autopilot()
        else:
            # TODO: Planner based on waypoints.
            # cur_location = self._vehicle.get_location()
            # dst_location = carla.Location(
            #   x = self.end_pos[i][0],
            #   y = self.end_pos[i][1],
            #   z = self.end_pos[i][2])
            # cur_map = self.world.get_map()
            # next_point_transform =
            #   get_transform_from_nearest_way_point(
            #       cur_map, cur_location, dst_location)
            # next_point_transform.location.z = 40
            # self.actor_list[i].set_transform(next_point_transform)
            self._vehicle.apply_control(
                carla.VehicleControl(
                    throttle=ctrl_args[0],
                    steer=ctrl_args[1],
                    brake=ctrl_args[2],
                    hand_brake=ctrl_args[3],
                    reverse=ctrl_args[4]))

    # TODO: use the render in cam_manager instead of this. 
Example #30
Source File: main.py    From python-examples with MIT License 4 votes vote down vote up
def display_cube():
    WINDOW_WIDTH = 800
    WINDOW_HEIGHT = 600

    pygame.init()
    pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT), pygame.DOUBLEBUF | pygame.OPENGL)
    
    OpenGL.GLU.gluPerspective(45, (WINDOW_WIDTH/WINDOW_HEIGHT), 0.1, 50.0)
    OpenGL.GL.glTranslatef(0.0, 0.0, -10)
    
    show_cube_1 = True
    show_cube_2 = True
    show_lines = True
    
    running = True
    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    running = False
                elif event.key == pygame.K_1:
                    show_cube_1 = not show_cube_1
                elif event.key == pygame.K_2:
                    show_cube_2 = not show_cube_2
                elif event.key == pygame.K_0:
                    show_lines = not show_lines
                    
                    
        OpenGL.GL.glRotate(1, 3, 10, 10) # (angle,x,y,z)
        OpenGL.GL.glClear(OpenGL.GL.GL_COLOR_BUFFER_BIT | OpenGL.GL.GL_DEPTH_BUFFER_BIT)

        if show_cube_1:
            cube(vertices1, edges) # large cube
        if show_cube_2:
            cube(vertices2, edges) # small cube
        if show_lines:
            lines(vertices1, vertices2)
        
        pygame.display.flip()
        pygame.time.wait(10)

    pygame.quit()

# ---