gpt4 book ai didi

python - 找不到匹配的 GLX 视觉

转载 作者:太空宇宙 更新时间:2023-11-03 21:19:44 26 4
gpt4 key购买 nike

我正在努力使用 pygame 初始化 OpenGL 显示。和pyopengl .

import pygame
pygame.init()
pygame.display.set_mode((1920, 1080), pygame.OPENGL)

给出错误:

pygame.error: Couldn't find matching GLX visual

If I don't specify pygame.OPENGL I get a properly initialised display and a pygame window.

  • I'm using python 3 (Python 3.6.2 :: Anaconda custom (64-bit))
  • I'm on Manjaro Linux, running i3 windows manager
  • I'm on a Dell XPS laptop, which has both Intel and Nvidia graphics adapters and I'm using optirun to use the Nvidia hardware, but I get the same effect regardless of which graphics adapter I use
  • glxgears and optirun glxgears both work fine, so I believe that OpenGL is available on the machine and working fine
  • optirun glxinfo https://pastebin.com/v6VjZgBZ

In an attempt to find a suitable set of display parameters, I ran:

import pygame
from pygame.locals import *
pygame.init()
print(pygame.display.Info())
print(pygame.display.list_modes(32, pygame.FULLSCREEN))
print(pygame.display.mode_ok((1920, 1080)))
print(pygame.display.mode_ok((1920, 1080), pygame.OPENGL))

输出如下:

VideoInfo(hw = 0, wm = 1,video_mem = 0
blit_hw = 0, blit_hw_CC = 0, blit_hw_A = 0,
blit_sw = 0, blit_sw_CC = 0, blit_sw_A = 0,
bitsize = 32, bytesize = 4,
masks = (16711680, 65280, 255, 0),
shifts = (16, 8, 0, 0),
losses = (0, 0, 0, 8),
current_w = 3200, current_h = 1800

[(3200, 1800), (2880, 1620), (2560, 1600), (2560, 1440), (2048, 1536), (2048, 1152), (1920, 1440), (1920, 1200), (1920, 1080), (1856, 1392), (1792, 1344), (1680, 1050), (1600, 1200), (1600, 900), (1400, 1050), (1400, 900), (1368, 768), (1280, 1024), (1280, 960), (1280, 800), (1280, 720), (1024, 768), (1024, 576), (960, 540), (864, 486), (800, 600), (720, 405), (640, 480), (640, 360)]
32
32

以下是 optirun glxinfo 的摘录,即glxinfo对于 Nvidia 适配器,显示了几个 GLX 视觉效果(完整输出 https://pastebin.com/v6VjZgBZ ):

70 GLX Visuals
visual x bf lv rg d st colorbuffer sr ax dp st accumbuffer ms cav
id dep cl sp sz l ci b ro r g b a F gb bf th cl r g b a ns b eat
----------------------------------------------------------------------------
0x020 24 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x021 24 dc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0ce 24 tc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0cf 24 tc 0 32 0 r . . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0d0 24 tc 0 32 0 r . . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0d1 24 tc 0 24 0 r y . 8 8 8 0 . . 0 0 0 0 0 0 0 0 0 None
0x0d2 24 tc 0 24 0 r . . 8 8 8 0 . . 0 0 0 0 0 0 0 0 0 None
0x0d3 24 tc 0 24 0 r y . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x0d4 24 tc 0 24 0 r . . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x0d5 24 tc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0d6 24 tc 0 32 0 r . . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0d7 24 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0d8 24 tc 0 32 0 r . . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0d9 24 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0da 24 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 16 16 16 16 0 0 None
0x0db 24 tc 0 24 0 r y . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x0dc 24 tc 0 24 0 r y . 8 8 8 0 . . 0 24 8 16 16 16 0 0 0 None
0x0dd 24 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0de 24 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 16 16 16 16 0 0 None
0x0df 24 tc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0e0 24 tc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0e1 24 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0e2 24 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0e3 24 tc 0 24 0 r y . 8 8 8 0 . . 0 0 0 0 0 0 0 0 0 None
0x0e4 24 tc 0 24 0 r y . 8 8 8 0 . . 0 0 0 0 0 0 0 0 0 None
0x0e5 24 tc 0 24 0 r y . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x0e6 24 tc 0 24 0 r y . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x0e7 24 tc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0e8 24 tc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0e9 24 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0ea 24 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0eb 24 dc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0ec 24 dc 0 32 0 r . . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0ed 24 dc 0 32 0 r . . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0ee 24 dc 0 24 0 r y . 8 8 8 0 . . 0 0 0 0 0 0 0 0 0 None
0x0ef 24 dc 0 24 0 r . . 8 8 8 0 . . 0 0 0 0 0 0 0 0 0 None
0x0f0 24 dc 0 24 0 r y . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x0f1 24 dc 0 24 0 r . . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x0f2 24 dc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0f3 24 dc 0 32 0 r . . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0f4 24 dc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0f5 24 dc 0 32 0 r . . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0f6 24 dc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0f7 24 dc 0 32 0 r y . 8 8 8 8 . . 0 24 8 16 16 16 16 0 0 None
0x0f8 24 dc 0 24 0 r y . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x0f9 24 dc 0 24 0 r y . 8 8 8 0 . . 0 24 8 16 16 16 0 0 0 None
0x0fa 24 dc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0fb 24 dc 0 32 0 r y . 8 8 8 8 . . 0 24 8 16 16 16 16 0 0 None
0x0fc 24 dc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0fd 24 dc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x0fe 24 dc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x0ff 24 dc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x100 24 dc 0 24 0 r y . 8 8 8 0 . . 0 0 0 0 0 0 0 0 0 None
0x101 24 dc 0 24 0 r y . 8 8 8 0 . . 0 0 0 0 0 0 0 0 0 None
0x102 24 dc 0 24 0 r y . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x103 24 dc 0 24 0 r y . 8 8 8 0 . . 0 24 8 0 0 0 0 0 0 None
0x104 24 dc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x105 24 dc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x106 24 dc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x107 24 dc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x06f 32 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x108 32 tc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x109 32 tc 0 32 0 r . . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x10a 32 tc 0 32 0 r . . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x10b 32 tc 0 32 0 r y . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x10c 32 tc 0 32 0 r . . 8 8 8 8 . . 0 0 0 0 0 0 0 0 0 None
0x10d 32 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x10e 32 tc 0 32 0 r . . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x10f 32 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
0x110 32 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None

请帮助我诊断问题并让启用 OpenGL 的 pygame 窗口运行。

更新20190131我试过ipython (python 3.6.2)按照@hidefromkgb的建议设置24位颜色模式,但我遇到了同样的问题(我之前尝试过):

In [1]: import pygame

In [2]: pygame.init()
Out[2]: (6, 0)

In [3]: pygame.display.set_mode((1920, 1080), pygame.OPENGL, 24)
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-3-b9c85baaf5fe> in <module>()
----> 1 pygame.display.set_mode((1920, 1080), pygame.OPENGL, 24)

error: Couldn't find matching GLX visual

我能够使用 GLUT 从 C++ 中让 OpenGL 正常工作,没有任何问题。

更新 #2 20190131

我现在有两个最小的程序( pythonc++ )以及附带的 strace 输出(请参阅 https://paste.ee/p/ah1nq )。

这个python程序失败并出现 GLX Visuals 错误:

import pygame
pygame.init()
pygame.display.set_mode((1920, 1080), pygame.OPENGL)

这个c++程序成功创建窗口:

#include <GL/glut.h>

void display(void) {
}

int
main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("window initialisation test");
return 0;
}

c++程序是用 g++ test.cpp -lGL -lglut -o test 编译的.

我查看了 strace输出,但无法弄清楚它的正反面。

更新 #3 20190131

我跑了ltrace对以上两个程序进行分析,得到

python

$ ltrace python test.py
__libc_start_main(0x400ab0, 2, 0x7ffe171cfb58, 0x400cc0 <unfinished ...>
_PyMem_SetupAllocators(0x400da8, 0x7ffe171cfb58, 0x7ffe171cfb70, 0x7f82b2fd4578) = 0
PyMem_RawMalloc(24, 0x400daf, 0x7ffe171cfb70, 6) = 0xf8d260
PyMem_RawMalloc(24, 0xf8d270, 0xf8d260, 0xf8d260) = 0xf8d280
setlocale(LC_ALL, nil) = "C"
_PyMem_RawStrdup(0x7f82b2f9c007, 0, 0, 0xf8d280) = 0xf8d2a0
setlocale(LC_ALL, "") = "LC_CTYPE=en_AU.utf8;LC_NUMERIC=e"...
Py_DecodeLocale(0x7ffe171d1310, 0, 0, 0) = 0xf90710
Py_DecodeLocale(0x7ffe171d1317, 0, 0xf90728, 0) = 0xf90740
setlocale(LC_ALL, "C") = "C"
PyMem_RawFree(0xf8d2a0, 16, 0, 0) = 0
Py_Main(2, 0xf8d260, 0, 0xf8e260Traceback (most recent call last):
File "test.py", line 4, in <module>
pygame.display.set_mode((1920, 1080), pygame.OPENGL)
pygame.error: Couldn't find matching GLX visual
) = 1
_PyMem_SetupAllocators(0x400da8, 0x7f82b2fd6710, 0, 2880) = 0
PyMem_RawFree(0xf90710, 0x400daf, 0, 6) = 0
PyMem_RawFree(0xf90740, 0xf90760, 0, 0xf90760) = 0
PyMem_RawFree(0xf8d260, 0xf90700, 0, 0xf90700) = 0
PyMem_RawFree(0xf8d280, 0xf8f310, 0, 0xf8f310) = 0
+++ exited (status 1) +++

c++

$ ltrace ./test
glutInit(0x7ffd507caccc, 0x7ffd507cadb8, 0x7ffd507cadb8, 128) = 0
glutInitDisplayMode(18, 1, 0x7fb32b5c44e0, 32) = 0x7fb32b7d70e0
glutCreateWindow(0x562359efe004, 1, 0x7fb32b5c44e0, 32) = 1
--- SIGWINCH (Window changed) ---
+++ exited (status 0) +++

更新 #4 20190213

感谢您的意见,@hidefromkgb。

我尝试使用pygame.OPENGL | pygame.DOUBLEBUF也只是路过 18 ,但得到了相同的结果。

import pygame
from pygame.locals import *

pygame.init()
pygame.display.set_mode((1920, 1080), pygame.OPENGL | pygame.DOUBLEBUF)

---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-11-59807ce30659> in <module>()
3
4 pygame.init()
----> 5 pygame.display.set_mode((1920, 1080), pygame.OPENGL | pygame.DOUBLEBUF)

error: Couldn't find matching GLX visual
print(pygame.OPENGL)
print(pygame.DOUBLEBUF)

2
1073741824

最佳答案

Sorry for the late answer, haven`t seen your edit before. In the future, please call people by nicknames in comments if you need to have their attention.

ltrace似乎已经把问题说得更清楚了。第一个参数为glutInitDisplayMode等于 18,这意味着 GLUT_DOUBLE | GLUT_DEPTH ,对于GLUT_DOUBLE = 2, GLUT_DEPTH = 16。

反过来,pygame.display.set_mode GL 初始化期间调用缺少这两个标志。

尝试使用pygame.OPENGL | pygame.DOUBLEBUF而不仅仅是 pygame.OPENGL .

关于python - 找不到匹配的 GLX 视觉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54395678/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com