Make threaded WorldView buffer swaps optional
This commit is contained in:
parent
2ec18c1e9b
commit
35cf39d9c3
@ -70,6 +70,7 @@ def anglesToVector(yaw, pitch):
|
|||||||
dz = math.cos(math.radians(yaw)) * math.cos(math.radians(pitch))
|
dz = math.cos(math.radians(yaw)) * math.cos(math.radians(pitch))
|
||||||
return Vector(*map(nanzero, [dx, dy, dz]))
|
return Vector(*map(nanzero, [dx, dy, dz]))
|
||||||
|
|
||||||
|
THREADED_BUFFER_SWAP = True
|
||||||
|
|
||||||
class BufferSwapper(QtCore.QObject):
|
class BufferSwapper(QtCore.QObject):
|
||||||
def __init__(self, view):
|
def __init__(self, view):
|
||||||
@ -136,9 +137,11 @@ class WorldView(QGLWidget):
|
|||||||
|
|
||||||
validateWidgetQGLContext(self)
|
validateWidgetQGLContext(self)
|
||||||
|
|
||||||
self.setAutoBufferSwap(False)
|
|
||||||
|
|
||||||
self.bufferSwapDone = True
|
self.bufferSwapDone = True
|
||||||
|
|
||||||
|
if THREADED_BUFFER_SWAP:
|
||||||
|
self.setAutoBufferSwap(False)
|
||||||
self.bufferSwapThread = QtCore.QThread()
|
self.bufferSwapThread = QtCore.QThread()
|
||||||
self.bufferSwapper = BufferSwapper(self)
|
self.bufferSwapper = BufferSwapper(self)
|
||||||
self.bufferSwapper.moveToThread(self.bufferSwapThread)
|
self.bufferSwapper.moveToThread(self.bufferSwapThread)
|
||||||
@ -195,6 +198,7 @@ class WorldView(QGLWidget):
|
|||||||
|
|
||||||
def dealloc(self):
|
def dealloc(self):
|
||||||
log.info("Deallocating GL resources for worldview %s", self)
|
log.info("Deallocating GL resources for worldview %s", self)
|
||||||
|
if THREADED_BUFFER_SWAP:
|
||||||
self.waitForSwapThread()
|
self.waitForSwapThread()
|
||||||
self.bufferSwapThread.quit()
|
self.bufferSwapThread.quit()
|
||||||
self.makeCurrent()
|
self.makeCurrent()
|
||||||
@ -573,6 +577,7 @@ class WorldView(QGLWidget):
|
|||||||
super(WorldView, self).glDraw(*args, **kwargs)
|
super(WorldView, self).glDraw(*args, **kwargs)
|
||||||
|
|
||||||
shouldRender = True
|
shouldRender = True
|
||||||
|
|
||||||
def paintGL(self):
|
def paintGL(self):
|
||||||
if not self.shouldRender:
|
if not self.shouldRender:
|
||||||
return
|
return
|
||||||
@ -585,6 +590,7 @@ class WorldView(QGLWidget):
|
|||||||
with profiler.context("renderScene"):
|
with profiler.context("renderScene"):
|
||||||
rendernode.renderScene(self.renderGraph)
|
rendernode.renderScene(self.renderGraph)
|
||||||
|
|
||||||
|
if THREADED_BUFFER_SWAP:
|
||||||
self.doneCurrent()
|
self.doneCurrent()
|
||||||
self.bufferSwapDone = False
|
self.bufferSwapDone = False
|
||||||
self.doSwapBuffers.emit()
|
self.doSwapBuffers.emit()
|
||||||
|
Reference in New Issue
Block a user