From 3aceecf6e711c48244dbbfca85e9a3f5f7baeb91 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Wed, 15 Jul 2015 08:45:00 +0100 Subject: [PATCH] Bit of a bug fix - when softwareMode is changed, GLObjects are potentially drawn again before they get a chance to recompile their shader programs. So any logic based on display.softwareMode is to be considered slightly dubious. --- fsl/fslview/controls/locationpanel.py | 4 +++- fsl/fslview/gl/gl21/glvolume_funcs.py | 14 +++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fsl/fslview/controls/locationpanel.py b/fsl/fslview/controls/locationpanel.py index 7fa3d5530..255ce56c3 100644 --- a/fsl/fslview/controls/locationpanel.py +++ b/fsl/fslview/controls/locationpanel.py @@ -209,7 +209,9 @@ class LocationPanel(fslpanel.FSLViewPanel): return # Register a listener on the DisplayOpts - # instance of the currently selected overlay + # instance of the currently selected overlay, + # so we can update the location if the + # overlay transforms/reference image change overlay = self._displayCtx.getSelectedOverlay() for ovl in self._overlayList: display = self._displayCtx.getDisplay(ovl) diff --git a/fsl/fslview/gl/gl21/glvolume_funcs.py b/fsl/fslview/gl/gl21/glvolume_funcs.py index 28e90ece3..e99987dff 100644 --- a/fsl/fslview/gl/gl21/glvolume_funcs.py +++ b/fsl/fslview/gl/gl21/glvolume_funcs.py @@ -186,10 +186,12 @@ def _prepareVertexAttributes(self, vertices, voxCoords, texCoords): gl.glVertexAttribPointer( texPos, 3, gl.GL_FLOAT, gl.GL_FALSE, 36, ctypes.c_void_p(24)) - # The fast shader does not use voxel coordinates - # so, on some GL drivers, attempting to bind it - # will cause an error - if not self.display.softwareMode: + # The sw shader does not use voxel coordinates + # so attempting to binding would raise an error. + # So we only attempt to bind if softwareMode is + # false, and there is a shader uniform position + # for the voxel coordinates available. + if not self.display.softwareMode and voxPos != -1: gl.glVertexAttribPointer( voxPos, 3, gl.GL_FLOAT, gl.GL_FALSE, 36, ctypes.c_void_p(12)) gl.glEnableVertexAttribArray(self.voxCoordPos) @@ -245,7 +247,9 @@ def postDraw(self): gl.glDisableVertexAttribArray(self.vertexPos) gl.glDisableVertexAttribArray(self.texCoordPos) - if not self.display.softwareMode: + # See comments in _prepareVertexAttributes + # about softwareMode/voxel coordinates + if not self.display.softwareMode and self.voxCoordPos != -1: gl.glDisableVertexAttribArray(self.voxCoordPos) gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0) -- GitLab