Added GLImageItem.setData()

This commit is contained in:
Luke Campagnola 2014-07-06 11:44:26 -04:00
parent ee40f57c88
commit 8268ccfa65

View File

@ -25,13 +25,21 @@ class GLImageItem(GLGraphicsItem):
"""
self.smooth = smooth
self.data = data
self._needUpdate = False
GLGraphicsItem.__init__(self)
self.setData(data)
self.setGLOptions(glOptions)
def initializeGL(self):
glEnable(GL_TEXTURE_2D)
self.texture = glGenTextures(1)
def setData(self, data):
self.data = data
self._needUpdate = True
self.update()
def _updateTexture(self):
glBindTexture(GL_TEXTURE_2D, self.texture)
if self.smooth:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
@ -63,7 +71,8 @@ class GLImageItem(GLGraphicsItem):
def paint(self):
if self._needUpdate:
self._updateTexture()
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, self.texture)