請教各位大神,我在使用pyqtgraph和GLViewWidget畫3D散點圖時遇到了openGL error, 代碼如下:
g = gl.GLGridItem()
self.guiplot.addItem(g)
pos = np.random.random(size=(100000, 3))
pos *= [10, -10, 10]
pos[0] = (0, 0, 0)
color = np.ones((pos.shape[0], 4))
d2 = (pos ** 2).sum(axis=1) ** 0.5
size = np.random.random(size=pos.shape[0]) * 10
sp2 = gl.GLScatterPlotItem(pos=pos, color=(1, 1, 1, 1), size=size)
self.guiplot.addItem(sp2)
屏蔽掉sp2時,可以正常運行并顯示出網格g。但當addItem(sp2)時,就會報如下錯誤:
Traceback (most recent call last):
File "E:\PycharmProject\testPjt\venv\lib\site-packages\OpenGL\latebind.py", line 43, in __call__
return self._finalCall( *args, **named )
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\PycharmProject\testPjt\venv\lib\site-packages\pyqtgraph\opengl\GLViewWidget.py", line 112, in addItem
item.initializeGL()
File "E:\PycharmProject\testPjt\venv\lib\site-packages\pyqtgraph\opengl\items\GLScatterPlotItem.py", line 74, in initializeGL
self.pointTexture = glGenTextures(1)
File "E:\PycharmProject\testPjt\venv\lib\site-packages\OpenGL\latebind.py", line 47, in __call__
return self._finalCall( *args, **named )
File "E:\PycharmProject\testPjt\venv\lib\site-packages\OpenGL\wrapper.py", line 678, in wrapperCall
raise err
File "E:\PycharmProject\testPjt\venv\lib\site-packages\OpenGL\wrapper.py", line 671, in wrapperCall
result = wrappedOperation( *cArguments )
File "E:\PycharmProject\testPjt\venv\lib\site-packages\OpenGL\platform\baseplatform.py", line 415, in __call__
return self( *args, **named )
File "E:\PycharmProject\testPjt\venv\lib\site-packages\OpenGL\error.py", line 230, in glCheckError
raise self._errorClass(
OpenGL.error.GLError: GLError(
err = 1282,
description = b'\xce\xde\xd0\xa7\xb2\xd9\xd7\xf7',
baseOperation = glGenTextures,
pyArgs = (
1,
<object object at 0x000001A96BF5B5D0>,
),
cArgs = (1, array([0], dtype=uint32)),
cArguments = (1, array([0], dtype=uint32))
)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\PycharmProject\testPjt\gui.py", line 165, in OnClickAction
self.runPlotWindow()
File "E:\PycharmProject\testPjt\gui.py", line 160, in runPlotWindow
self.ChildUI_NodeStatus = ChildWinNodeStatus()
File "E:\PycharmProject\testPjt\ChildWinNodeStatus.py", line 73, in __init__
self.guiplot.addItem(sp2)
File "E:\PycharmProject\testPjt\venv\lib\site-packages\pyqtgraph\opengl\GLViewWidget.py", line 114, in addItem
self.checkOpenGLVersion('Error while adding item %s to GLViewWidget.' % str(item))
File "E:\PycharmProject\testPjt\venv\lib\site-packages\pyqtgraph\opengl\GLViewWidget.py", line 535, in checkOpenGLVersion
verString = glGetString(GL_VERSION)
File "E:\PycharmProject\testPjt\venv\lib\site-packages\OpenGL\platform\baseplatform.py", line 415, in __call__
return self( *args, **named )
File "E:\PycharmProject\testPjt\venv\lib\site-packages\OpenGL\error.py", line 230, in glCheckError
raise self._errorClass(
OpenGL.error.GLError: GLError(
err = 1282,
description = b'\xce\xde\xd0\xa7\xb2\xd9\xd7\xf7',
baseOperation = glGetString,
cArguments = (GL_VERSION,)
)
看起來是addItem(sp2)時,initializeGL出問題了
if hasattr(item, 'initializeGL'):
self.makeCurrent()
try:
item.initializeGL()
except:
self.checkOpenGLVersion('Error while adding item %s to GLViewWidget.' % str(item))
求教各位大神有沒有遇到過類似問題,如何解決? 謝謝!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/270304.html
