You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While trying to render the current view with GLViewWidget.renderToArray that contains a GLScatterPlotItem the following error is thrown:
Traceback (most recent call last):
File "", line 15, in
File "C:\Python27\lib\site-packages\pyqtgraph\opengl\GLViewWidget.py", line 451, in renderToArray
data = np.fromstring(data, dtype=np.ubyte).reshape(texwidth,texwidth,4).transpose(1,0,2)[:, ::-1]
ValueError: total size of new array must be unchanged
Heres a test code to reproduce the error:
from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph.opengl as gl
import numpy
app = QtGui.QApplication([])
win = gl.GLViewWidget()
win.show()
s = gl.GLScatterPlotItem(pos = numpy.random.random((10,3)))
win.addItem(s)
m = gl.GLMeshItem(vertexes = numpy.random.random((10,3,3)))
win.addItem(m)
a = win.renderToArray((800,600))
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
If you comment out the scatter plot part it runs just fine. Looking at source of GLViewWidget.renderToArray at the errors location:
self.paintGL(region=(x, h-y-h2, w2, h2), viewport=(0, 0, w2, h2)) # only render sub-region
## read texture back to array
data = glGetTexImage(GL_TEXTURE_2D, 0, format, type)
data = np.fromstring(data, dtype=np.ubyte).reshape(texwidth,texwidth,4).transp....
It looks like glGetTexImage returns too small of a string to be reshaped to the given size.
By trial and error i found out that the returned string can be reshaped to a 64x64x4 image that shows a circle (hint: its GLScatterPlotItem.pointTexture). It seems that the texture bindings change and the scatter plots texture is rendered instead. Calling glGetIntegerv(GL_TEXTURE_BINDING_2D) showed that before calling glGetTexImage the bound texture is the scatter plots texture and before self.paintGL the bound texture is the correct texture.
By repainting with self.paintGL the scatter plots paint function is called, which changes the bound texture, after the call the bound texture should be reset to tex right after self.paintGL by simply adding: glBindTexture(GL_TEXTURE_2D, tex)
The text was updated successfully, but these errors were encountered:
While trying to render the current view with GLViewWidget.renderToArray that contains a GLScatterPlotItem the following error is thrown:
Heres a test code to reproduce the error:
If you comment out the scatter plot part it runs just fine. Looking at source of GLViewWidget.renderToArray at the errors location:
It looks like
glGetTexImage
returns too small of a string to be reshaped to the given size.By trial and error i found out that the returned string can be reshaped to a 64x64x4 image that shows a circle (hint: its
GLScatterPlotItem.pointTexture
). It seems that the texture bindings change and the scatter plots texture is rendered instead. CallingglGetIntegerv(GL_TEXTURE_BINDING_2D)
showed that before callingglGetTexImage
the bound texture is the scatter plots texture and beforeself.paintGL
the bound texture is the correct texture.By repainting with
self.paintGL
the scatter plots paint function is called, which changes the bound texture, after the call the bound texture should be reset totex
right afterself.paintGL
by simply adding:glBindTexture(GL_TEXTURE_2D, tex)
The text was updated successfully, but these errors were encountered: