Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when setting opengl mode: "pygame.error: Couldn't find matching GLX visual" #3243

Closed
nacho692 opened this issue Nov 25, 2024 · 2 comments
Labels
bug Not working as intended

Comments

@nacho692
Copy link

nacho692 commented Nov 25, 2024

Environment:

pygame-ce 2.5.3.dev1 (SDL 2.30.7, Python 3.12.0)
Platform:               Linux-6.6.54-2-MANJARO-x86_64-with-glibc2.40
System:                 Linux
System Version:         #1 SMP PREEMPT_DYNAMIC Tue Oct  8 03:11:08 UTC 2024
Processor:                      SSE2: Yes       AVX2: Yes       NEON: No
Architecture:           Bits: 64bit     Linkage: ELF

Python:                 CPython 3.12.0 | packaged by Anaconda, Inc. | (main, Oct  2 2023, 17:29:18) [GCC 11.2.0]
pygame version:         2.5.3.dev1
SDL versions:           Linked: 2.30.7  Compiled: 2.30.7
SDL Mixer versions:     Linked: 2.8.0   Compiled: 2.8.0
SDL Font versions:      Linked: 2.22.0  Compiled: 2.22.0
SDL Image versions:     Linked: None    Compiled: None
Freetype versions:      Linked: 2.13.3  Compiled: 2.13.3

Display Driver:         x11 ( xwayland == False )
Mixer Driver:           pulseaudio

Other environment details, not included in print_debug_info(), that might help:

$ glxinfo -B
name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Intel (0x8086)
    Device: Mesa Intel(R) UHD Graphics (CML GT2) (0x9bc4)
    Version: 24.2.4
    Accelerated: yes
    Video memory: 15850MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.6
    Max compat profile version: 4.6
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) UHD Graphics (CML GT2)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 24.2.4-arch1.0.1
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.6 (Compatibility Profile) Mesa 24.2.4-arch1.0.1
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 24.2.4-arch1.0.1
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
$ glxinfo | grep Visuals
336 GLX Visuals
  • Relevant hardware

Video Card: Intel Corporation CometLake-H GT2 [UHD Graphics]

Current behavior:

Trying to enable openGL support on pygame errors out with pygame.error: Couldn't find matching GLX visual

Expected behavior:

A window with opengl support should be created

Steps to reproduce:

import pygame


def main():
    pygame.init()
    pygame.display.set_mode((640, 480), flags=pygame.OPENGL)


main()

Stack trace/error output/other error logs

pygame 2.6.1 (SDL 2.28.4, Python 3.12.0)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "/home/nacho692/repos/pyenstein/pygame_opengl.py", line 9, in <module>
    main()
  File "/home/nacho692/repos/pyenstein/pygame_opengl.py", line 6, in main
    pygame.display.set_mode((640, 480), flags=pygame.OPENGL)
pygame.error: Couldn't find matching GLX visual

What I tried, extra information

  • glxgears and openGL games work
  • Ran strace on the python script, it looks like it's loading libraries correctly:
$> strace python pygame_opengl.py | grep 'GLX'
[pid 582905] openat(AT_FDCWD, "/home/nacho692/miniconda3/envs/pygame/bin/../lib/libGLX.so.0", O_RDONLY|O_CLOEXEC <unfinished ...>
[pid 582905] openat(AT_FDCWD, "/usr/lib/libGLX.so.0", O_RDONLY|O_CLOEXEC <unfinished ...>
[pid 582905] writev(5, [{iov_base="b0\3\0\3\0\0\0", iov_len=8}, {iov_base="GLX", iov_len=3}, {iov_base="\0", iov_len=1}], 3) = 12
[pid 582905] writev(5, [{iov_base="b0\3\0\3\0\0\0", iov_len=8}, {iov_base="GLX", iov_len=3}, {iov_base="\0", iov_len=1}], 3) = 12
[pid 582905] openat(AT_FDCWD, "/home/nacho692/miniconda3/envs/pygame/bin/../lib/libGLX_mesa.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 582905] openat(AT_FDCWD, "/usr/lib/libGLX_mesa.so.0", O_RDONLY|O_CLOEXEC) = 19
[pid 582905] openat(AT_FDCWD, "/home/nacho692/miniconda3/envs/pygame/bin/../lib/libGLX_indirect.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 582905] openat(AT_FDCWD, "/usr/lib/glibc-hwcaps/x86-64-v3/libGLX_indirect.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 582905] openat(AT_FDCWD, "/usr/lib/glibc-hwcaps/x86-64-v2/libGLX_indirect.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 582905] openat(AT_FDCWD, "/usr/lib/libGLX_indirect.so.0", O_RDONLY|O_CLOEXEC) = 19
[pid 582905] openat(AT_FDCWD, "/home/nacho692/miniconda3/envs/pygame/bin/../lib/libGLX_mesa.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 582905] openat(AT_FDCWD, "/usr/lib/libGLX_mesa.so.0", O_RDONLY|O_CLOEXEC) = 19
[pid 582905] openat(AT_FDCWD, "/home/nacho692/miniconda3/envs/pygame/bin/../lib/libGLX_indirect.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 582905] openat(AT_FDCWD, "/usr/lib/libGLX_indirect.so.0", O_RDONLY|O_CLOEXEC) = 19
[pid 582905] openat(AT_FDCWD, "/home/nacho692/miniconda3/envs/pygame/bin/../lib/libGLX_mesa.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 582905] openat(AT_FDCWD, "/usr/lib/libGLX_mesa.so.0", O_RDONLY|O_CLOEXEC) = 19
[pid 582905] openat(AT_FDCWD, "/home/nacho692/miniconda3/envs/pygame/bin/../lib/libGLX_indirect.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 582905] openat(AT_FDCWD, "/usr/lib/libGLX_indirect.so.0", O_RDONLY|O_CLOEXEC) = 19
[pid 582905] write(2, "pygame.error: Couldn't find matc"..., 48pygame.error: Couldn't find matching GLX visual
  • Used SDL2 manually to create an openGL environment: works ok
#include <SDL2/SDL_syswm.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_video.h>

int main(int argc, char **argv)
{
    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
        SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize SDL: %s\n", SDL_GetError());
        return 1;
    }

    // Use OpenGL 4.3 core profile
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
    
    // Turn on double buffering with a 24bit Z buffer
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

         
    // Declare window variables
    int g_iWindowWidth = 800;
    int g_iWindowHeight = 600;
    bool g_bWindowFullscreen = false;

    // Create a SDL window
    SDL_Window * Window = SDL_CreateWindow("Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, g_iWindowWidth, g_iWindowHeight, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | (g_bWindowFullscreen * SDL_WINDOW_FULLSCREEN));
    if (Window == NULL) {
        SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Failed to create OpenGL window: %s\n", SDL_GetError());
        SDL_Quit();
        return 1;
    }

    // Create a OpenGL Context
    SDL_GLContext Context = SDL_GL_CreateContext(Window);
    if (Context == NULL) {
        SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Failed to create OpenGL context: %s\n", SDL_GetError());
        SDL_DestroyWindow(Window);
        SDL_Quit();
        return 1;
    }
    return 0;
}
  • Checked flags used for creating window
            if (!win) {
                /*open window*/
                if (hwnd != 0) {
                    win = SDL_CreateWindowFrom((void *)hwnd);
                }
                else {
                    char sdl_flags_str[255];
                    snprintf(sdl_flags_str, sizeof(sdl_flags_str), "Start: SDL_CreateWindow with flags: %u", sdl_flags);
                    PyErr_WarnEx(PyExc_Warning, sdl_flags_str,1);
                    win = SDL_CreateWindow(title, x, y, w_1, h_1, sdl_flags);
                    w_actual = w_1;
                    h_actual = h_1;
                }
                if (!win)
                    return RAISE(pgExc_SDLError, SDL_GetError());
                PyErr_WarnEx(PyExc_Warning, "Done: SDL_CreateWindow",1);

            }
$ python pygame_opengl.py
pygame-ce 2.5.3.dev1 (SDL 2.30.7, Python 3.12.0)
/home/nacho692/repos/pyenstein/pygame_opengl.py:6: Warning: Start: SDL_CreateWindow with flags: 6
  pygame.display.set_mode((640, 480), pygame.OPENGL | pygame.DOUBLEBUF)
Traceback (most recent call last):
  File "/home/nacho692/repos/pyenstein/pygame_opengl.py", line 9, in <module>
    main()
  File "/home/nacho692/repos/pyenstein/pygame_opengl.py", line 6, in main
    pygame.display.set_mode((640, 480), pygame.OPENGL | pygame.DOUBLEBUF)
pygame.error: Couldn't find matching GLX visual

Tried using the flag "6" on my own .cpp sdl program and it still works.

Found the error string itself on SDL: https://github.com/libsdl-org/SDL/blob/e9fdcf6c603f4e7776c7083b631aa6f8775566c5/src/video/x11/SDL_x11opengl.c#L708

Is there any way to debug what's going on in this method?

@nacho692 nacho692 added the bug Not working as intended label Nov 25, 2024
@nacho692
Copy link
Author

Update:

Error is only reproduced on conda managed python, it works on system python

@nacho692
Copy link
Author

nacho692 commented Nov 27, 2024

Fixed by installing pygame using conda dependency installer instead of pip, so might be an issue with conda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended
Projects
None yet
Development

No branches or pull requests

1 participant