diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f074cb83..6057296b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ * Fixed wrong units in VehiclePhysicsControl's center of mass * Several optimizations to the RPC server, now supports a bigger load of async messages * Exposed 'is_invincible' for pedestrians - * Added sidewalks and improved lane markings in `no_rendering_mode.py` + * Fixed bug related with Pygame error of surface too large, added sidewalks and improved lane markings in `no_rendering_mode.py` ## CARLA 0.9.5 diff --git a/PythonAPI/examples/no_rendering_mode.py b/PythonAPI/examples/no_rendering_mode.py index 3144fd13f..b3cc85cdc 100755 --- a/PythonAPI/examples/no_rendering_mode.py +++ b/PythonAPI/examples/no_rendering_mode.py @@ -449,6 +449,15 @@ class MapImage(object): self.width = max(max_x - min_x, max_y - min_y) self._world_offset = (min_x, min_y) + # Maximum size of a Pygame surface + width_in_pixels = (1 << 14) - 1 + + # Adapt Pixels per meter to make world fit in surface + surface_pixel_per_meter = int(width_in_pixels / self.width) + if surface_pixel_per_meter > PIXELS_PER_METER: + surface_pixel_per_meter = PIXELS_PER_METER + + self._pixels_per_meter = surface_pixel_per_meter width_in_pixels = int(self._pixels_per_meter * self.width) self.big_map_surface = pygame.Surface((width_in_pixels, width_in_pixels)).convert()