Skip to content

Commit

Permalink
pyglet 1.4 compatibility (openai#1771)
Browse files Browse the repository at this point in the history
* pyglet 1.4 compatibility

* change pyglet version in setup.py
  • Loading branch information
pzhokhov authored Feb 3, 2020
1 parent 2d247dc commit eeb1f97
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gym/envs/box2d/car_racing.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def render(self, mode='human'):
return self.viewer.isopen

image_data = pyglet.image.get_buffer_manager().get_color_buffer().get_image_data()
arr = np.fromstring(image_data.data, dtype=np.uint8, sep='')
arr = np.fromstring(image_data.get_data(), dtype=np.uint8, sep='')
arr = arr.reshape(VP_H, VP_W, 4)
arr = arr[::-1, :, 0:3]

Expand Down
4 changes: 2 additions & 2 deletions gym/envs/classic_control/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def render(self, return_rgb_array=False):
if return_rgb_array:
buffer = pyglet.image.get_buffer_manager().get_color_buffer()
image_data = buffer.get_image_data()
arr = np.frombuffer(image_data.data, dtype=np.uint8)
arr = np.frombuffer(image_data.get_data(), dtype=np.uint8)
# In https://github.com/openai/gym-http-api/issues/2, we
# discovered that someone using Xmonad on Arch was having
# a window of size 598 x 398, though a 600 x 400 window
Expand Down Expand Up @@ -144,7 +144,7 @@ def get_array(self):
self.window.flip()
image_data = pyglet.image.get_buffer_manager().get_color_buffer().get_image_data()
self.window.flip()
arr = np.fromstring(image_data.data, dtype=np.uint8, sep='')
arr = np.fromstring(image_data.get_data(), dtype=np.uint8, sep='')
arr = arr.reshape(self.height, self.width, 4)
return arr[::-1,:,0:3]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
if package.startswith('gym')],
zip_safe=False,
install_requires=[
'scipy', 'numpy>=1.10.4', 'six', 'pyglet>=1.2.0,<=1.3.2', 'cloudpickle~=1.2.0',
'scipy', 'numpy>=1.10.4', 'six', 'pyglet>=1.4.0,<=1.5.0', 'cloudpickle~=1.2.0',
'enum34~=1.1.6;python_version<"3.4"',
],
extras_require=extras,
Expand Down

0 comments on commit eeb1f97

Please sign in to comment.