-1

I’m trying to run the OpenGL cube demo from pygame using:

$ python -m pygame.examples.glcube

My setup:

  • OS: Ubuntu 24.04.3
  • Python: 3.12.11 (installed via Miniconda)
  • pygame: 2.6.1
  • GPU:
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.181 Driver Version: 570.181 CUDA Version: 12.8 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce GTX 1650 Off | 00000000:01:00.0 Off | N/A |
| N/A 51C P8 3W / 50W | 3MiB / 4096MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+

But I get this error:

pygame 2.6.1 (SDL 2.28.4, Python 3.12.11)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
 File "<frozen runpy>", line 198, in _run_module_as_main
 File "<frozen runpy>", line 88, in _run_code
 File "~/miniconda3/envs/myenv/lib/python3.12/site-packages/pygame/examples/glcube.py", line 591, in <module>
 main()
 File "~/miniconda3/envs/myenv/lib/python3.12/site-packages/pygame/examples/glcube.py", line 541, in main
 pg.display.set_mode(display_size, pg.OPENGL | pg.DOUBLEBUF | pg.RESIZABLE)
pygame.error: Could not get EGL display

What I tried

  • Verified pygame is installed correctly (python -m pygame.examples.aliens works).
  • Checked if EGL is pointing to the NVIDIA driver
$ ldconfig -p | grep EGL
libEGL_nvidia.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libEGL_nvidia.so.0
ibEGL_nvidia.so.0 (libc6) => /lib/i386-linux-gnu/libEGL_nvidia.so.0
libEGL_mesa.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libEGL_mesa.so.0
libEGL.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libEGL.so.1
libEGL.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libEGL.so
  • Installed mesa-utils and confirmed OpenGL works with glxinfo and glxgears.
  • Tried setting SDL_VIDEODRIVER=x11 but still got the same error.

Question

What does pygame.error: Could not get EGL display mean in this context, and how can I fix it so I can run the glcube OpenGL demo?

Is this a problem with my SDL/pygame installation, my GPU drivers, or the way I’m invoking the example?

Any help or workaround would be appreciated. Thank you in advance.

asked Sep 21 at 19:25
2
  • Is there the same issue if you try pygame-ce instead? That's the only thing I can think of. Commented Sep 21 at 19:41
  • @Starbuck5 Thanks for the suggestion. I tried with pygame-ce as well, but I’m still getting the same Could not get EGL display error. It seems like EGL is not communicating properly inside my conda environment. For context, I originally ran into this issue while trying to use genesis-world visualization, and I tested with the pygame OpenGL example to confirm. Commented Sep 22 at 19:49

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.