Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Evan Edmond
fslpy
Commits
ea86c585
Commit
ea86c585
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Fixed canvas refresh issue on certain OpenGL implementations. Added GL
stuff to fsl.utils.platform
parent
1a5cff85
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fsl/fsleyes/gl/__init__.py
+45
-5
45 additions, 5 deletions
fsl/fsleyes/gl/__init__.py
fsl/fsleyes/gl/slicecanvas.py
+7
-7
7 additions, 7 deletions
fsl/fsleyes/gl/slicecanvas.py
fsl/utils/platform.py
+38
-0
38 additions, 0 deletions
fsl/utils/platform.py
with
90 additions
and
12 deletions
fsl/fsleyes/gl/__init__.py
+
45
−
5
View file @
ea86c585
...
@@ -187,9 +187,14 @@ package also contains the following:
...
@@ -187,9 +187,14 @@ package also contains the following:
~fsl.fsleyes.gl.shaders
~fsl.fsleyes.gl.shaders
"""
"""
import
logging
import
logging
import
platform
import
os
import
os
import
fsl.utils.async
as
async
import
fsl.utils.platform
as
fslplatform
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -251,6 +256,9 @@ def bootstrap(glVersion=None):
...
@@ -251,6 +256,9 @@ def bootstrap(glVersion=None):
``GL_VERSION`` A string containing the target OpenGL version, in
``GL_VERSION`` A string containing the target OpenGL version, in
the format ``major.minor``, e.g. ``2.1``.
the format ``major.minor``, e.g. ``2.1``.
``GL_RENDERER`` A string containing the name of the OpenGL renderer.
``glvolume_funcs`` The version-specific module containing functions for
``glvolume_funcs`` The version-specific module containing functions for
rendering :class:`.GLVolume` instances.
rendering :class:`.GLVolume` instances.
...
@@ -269,6 +277,11 @@ def bootstrap(glVersion=None):
...
@@ -269,6 +277,11 @@ def bootstrap(glVersion=None):
``gltensor_funcs`` The version-specific module containing functions for
``gltensor_funcs`` The version-specific module containing functions for
rendering :class:`.GLTensor` instances.
rendering :class:`.GLTensor` instances.
====================== ====================================================
====================== ====================================================
This function also sets the :attr:`.Platform.glVersion` and
:attr:`.Platform.glRenderer` properties of the
:attr:`fsl.utils.platform.platform` instance.
:arg glVersion: A tuple containing the desired (major, minor) OpenGL API
:arg glVersion: A tuple containing the desired (major, minor) OpenGL API
...
@@ -308,7 +321,6 @@ def bootstrap(glVersion=None):
...
@@ -308,7 +321,6 @@ def bootstrap(glVersion=None):
# fall back to the gl14 implementation
# fall back to the gl14 implementation
if
glpkg
==
gl21
:
if
glpkg
==
gl21
:
# List any GL21 extensions here
# List any GL21 extensions here
exts
=
[
'
GL_EXT_framebuffer_object
'
,
exts
=
[
'
GL_EXT_framebuffer_object
'
,
'
GL_ARB_instanced_arrays
'
,
'
GL_ARB_instanced_arrays
'
,
...
@@ -380,6 +392,7 @@ def bootstrap(glVersion=None):
...
@@ -380,6 +392,7 @@ def bootstrap(glVersion=None):
except
ValueError
:
pass
except
ValueError
:
pass
thismod
.
GL_VERSION
=
verstr
thismod
.
GL_VERSION
=
verstr
thismod
.
GL_RENDERER
=
renderer
thismod
.
glvolume_funcs
=
glpkg
.
glvolume_funcs
thismod
.
glvolume_funcs
=
glpkg
.
glvolume_funcs
thismod
.
glrgbvector_funcs
=
glpkg
.
glrgbvector_funcs
thismod
.
glrgbvector_funcs
=
glpkg
.
glrgbvector_funcs
thismod
.
gllinevector_funcs
=
glpkg
.
gllinevector_funcs
thismod
.
gllinevector_funcs
=
glpkg
.
gllinevector_funcs
...
@@ -387,6 +400,9 @@ def bootstrap(glVersion=None):
...
@@ -387,6 +400,9 @@ def bootstrap(glVersion=None):
thismod
.
gllabel_funcs
=
glpkg
.
gllabel_funcs
thismod
.
gllabel_funcs
=
glpkg
.
gllabel_funcs
thismod
.
gltensor_funcs
=
glpkg
.
gltensor_funcs
thismod
.
gltensor_funcs
=
glpkg
.
gltensor_funcs
thismod
.
_bootstrapped
=
True
thismod
.
_bootstrapped
=
True
fslplatform
.
glVersion
=
thismod
.
GL_VERSION
fslplatform
.
glRenderer
=
thismod
.
GL_RENDERER
def
getWXGLContext
(
parent
=
None
):
def
getWXGLContext
(
parent
=
None
):
...
@@ -612,6 +628,25 @@ class WXGLCanvasTarget(object):
...
@@ -612,6 +628,25 @@ class WXGLCanvasTarget(object):
self
.
_glReady
=
False
self
.
_glReady
=
False
self
.
Bind
(
wx
.
EVT_PAINT
,
self
.
_mainDraw
)
self
.
Bind
(
wx
.
EVT_PAINT
,
self
.
_mainDraw
)
# Using the Apple software renderer under OSX,
# we need to call refresh on the idle loop,
# otherwise refresh of multiple canvases (i.e.
# the OrthoPanel). gets all screwed up. Don't
# know why.
if
platform
.
system
()
==
'
Darwin
'
and
\
'
software
'
in
fslplatform
.
glRenderer
.
lower
():
def
refresh
(
*
a
):
async
.
idle
(
self
.
Refresh
)
# On other platforms/renderers,
# we can call Refresh directly
else
:
def
refresh
(
*
a
):
self
.
Refresh
()
self
.
_refresh
=
refresh
def
_initGL
(
self
):
def
_initGL
(
self
):
...
@@ -622,8 +657,12 @@ class WXGLCanvasTarget(object):
...
@@ -622,8 +657,12 @@ class WXGLCanvasTarget(object):
def
_draw
(
self
,
*
a
):
def
_draw
(
self
,
*
a
):
"""
This method should implement the OpenGL drawing logic
. M
ust be
"""
This method should implement the OpenGL drawing logic
- it m
ust be
implemented by subclasses.
implemented by subclasses.
.. note:: When runing with an on-screen display, this method should
never be called directly - call the :meth:`_refresh` method
instead.
"""
"""
raise
NotImplementedError
()
raise
NotImplementedError
()
...
@@ -670,9 +709,10 @@ class WXGLCanvasTarget(object):
...
@@ -670,9 +709,10 @@ class WXGLCanvasTarget(object):
def
_refresh
(
self
,
*
a
):
def
_refresh
(
self
,
*
a
):
"""
Triggers a redraw via the :meth:`_draw` method.
"""
"""
Triggers a redraw via the :meth:`_draw` method.
self
.
Refresh
()
.. note:: This method is dynamically assigned in :meth:`__init__`.
"""
def
_postDraw
(
self
):
def
_postDraw
(
self
):
"""
Called after the scene has been rendered. Swaps the front/back
"""
Called after the scene has been rendered. Swaps the front/back
...
...
This diff is collapsed.
Click to expand it.
fsl/fsleyes/gl/slicecanvas.py
+
7
−
7
View file @
ea86c585
...
@@ -208,13 +208,13 @@ class SliceCanvas(props.HasProperties):
...
@@ -208,13 +208,13 @@ class SliceCanvas(props.HasProperties):
# when any of the properties of this
# when any of the properties of this
# canvas change, we need to redraw
# canvas change, we need to redraw
self
.
addListener
(
'
zax
'
,
self
.
name
,
self
.
_zAxisChanged
)
self
.
addListener
(
'
zax
'
,
self
.
name
,
self
.
_zAxisChanged
)
self
.
addListener
(
'
pos
'
,
self
.
name
,
self
.
_
draw
)
self
.
addListener
(
'
pos
'
,
self
.
name
,
self
.
_
refresh
)
self
.
addListener
(
'
displayBounds
'
,
self
.
name
,
self
.
_
draw
)
self
.
addListener
(
'
displayBounds
'
,
self
.
name
,
self
.
_
refresh
)
self
.
addListener
(
'
bgColour
'
,
self
.
name
,
self
.
_
draw
)
self
.
addListener
(
'
bgColour
'
,
self
.
name
,
self
.
_
refresh
)
self
.
addListener
(
'
cursorColour
'
,
self
.
name
,
self
.
_
draw
)
self
.
addListener
(
'
cursorColour
'
,
self
.
name
,
self
.
_
refresh
)
self
.
addListener
(
'
showCursor
'
,
self
.
name
,
self
.
_
draw
)
self
.
addListener
(
'
showCursor
'
,
self
.
name
,
self
.
_
refresh
)
self
.
addListener
(
'
invertX
'
,
self
.
name
,
self
.
_
draw
)
self
.
addListener
(
'
invertX
'
,
self
.
name
,
self
.
_
refresh
)
self
.
addListener
(
'
invertY
'
,
self
.
name
,
self
.
_
draw
)
self
.
addListener
(
'
invertY
'
,
self
.
name
,
self
.
_
refresh
)
self
.
addListener
(
'
zoom
'
,
self
.
name
,
self
.
_zoomChanged
)
self
.
addListener
(
'
zoom
'
,
self
.
name
,
self
.
_zoomChanged
)
self
.
addListener
(
'
renderMode
'
,
self
.
name
,
self
.
_renderModeChange
)
self
.
addListener
(
'
renderMode
'
,
self
.
name
,
self
.
_renderModeChange
)
self
.
addListener
(
'
resolutionLimit
'
,
self
.
addListener
(
'
resolutionLimit
'
,
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/platform.py
+
38
−
0
View file @
ea86c585
...
@@ -60,12 +60,20 @@ class Platform(notifier.Notifier):
...
@@ -60,12 +60,20 @@ class Platform(notifier.Notifier):
"""
The ``Platform`` class contains a handful of properties which contain
"""
The ``Platform`` class contains a handful of properties which contain
information about the platform we are running on.
information about the platform we are running on.
.. note:: The values of the :attr:`glVersion` and :attr:`glRenderer`
properties are not automatically set - they will only contain
a value if one is assigned to them. The
:func:`fsl.fsleyes.gl.bootstrap` function does this when it is
first called.
.. autosummary::
.. autosummary::
fsldir
fsldir
haveGui
haveGui
wxBuild
wxBuild
wxFlavour
wxFlavour
glVersion
glRenderer
"""
"""
...
@@ -77,6 +85,8 @@ class Platform(notifier.Notifier):
...
@@ -77,6 +85,8 @@ class Platform(notifier.Notifier):
self
.
__haveGui
=
False
self
.
__haveGui
=
False
self
.
__wxFlavour
=
None
self
.
__wxFlavour
=
None
self
.
__wxPlatform
=
None
self
.
__wxPlatform
=
None
self
.
__glVersion
=
None
self
.
__glRenderer
=
None
try
:
try
:
import
wx
import
wx
...
@@ -151,6 +161,34 @@ class Platform(notifier.Notifier):
...
@@ -151,6 +161,34 @@ class Platform(notifier.Notifier):
self
.
__fsldir
=
value
self
.
__fsldir
=
value
self
.
notify
()
self
.
notify
()
@property
def
glVersion
(
self
):
"""
Returns the available OpenGL version, or ``None`` if it has not
been set.
"""
return
self
.
__glVersion
@glVersion.setter
def
glVersion
(
self
,
value
):
"""
Set the available OpenGL version.
"""
self
.
__glVersion
=
value
@property
def
glRenderer
(
self
):
"""
Returns the available OpenGL renderer, or ``None`` if it has not
been set.
"""
return
self
.
__glRenderer
@glRenderer.setter
def
glRenderer
(
self
,
value
):
"""
Set the available OpenGL renderer.
"""
self
.
__glRenderer
=
value
platform
=
Platform
()
platform
=
Platform
()
"""
An instance of the :class:`Platform` class. Feel free to create your own
"""
An instance of the :class:`Platform` class. Feel free to create your own
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment