Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
fslpy
Commits
61f6b3d6
Commit
61f6b3d6
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
GLModel updated to use glsl/program module.
parent
6ada26d3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fsl/fsleyes/gl/gl21/glmodel_funcs.py
+18
-16
18 additions, 16 deletions
fsl/fsleyes/gl/gl21/glmodel_funcs.py
fsl/fsleyes/gl/glmodel.py
+1
-0
1 addition, 0 deletions
fsl/fsleyes/gl/glmodel.py
fsl/fsleyes/gl/glsl/program.py
+1
-1
1 addition, 1 deletion
fsl/fsleyes/gl/glsl/program.py
with
20 additions
and
17 deletions
fsl/fsleyes/gl/gl21/glmodel_funcs.py
+
18
−
16
View file @
61f6b3d6
...
@@ -8,10 +8,9 @@
...
@@ -8,10 +8,9 @@
class to render :class:`.Model` overlays in an OpenGL 2.1 compatible manner.
class to render :class:`.Model` overlays in an OpenGL 2.1 compatible manner.
"""
"""
import
numpy
as
np
import
OpenGL.GL
as
gl
import
fsl.fsleyes.gl.shaders
as
shaders
import
fsl.fsleyes.gl.shaders
as
shaders
import
fsl.fsleyes.gl.glsl.program
as
glslprogram
def
compileShaders
(
self
):
def
compileShaders
(
self
):
...
@@ -19,19 +18,22 @@ def compileShaders(self):
...
@@ -19,19 +18,22 @@ def compileShaders(self):
instance. The shaders, and locations of uniform variables, are added
instance. The shaders, and locations of uniform variables, are added
as attributes of the instance.
as attributes of the instance.
"""
"""
vertShaderSrc
=
shaders
.
getVertexShader
(
self
)
fragShaderSrc
=
shaders
.
getFragmentShader
(
self
)
self
.
shaders
=
shaders
.
compileShaders
(
vertShaderSrc
,
fragShaderSrc
)
self
.
texPos
=
gl
.
glGetUniformLocation
(
self
.
shaders
,
'
tex
'
)
if
self
.
shader
is
not
None
:
self
.
offsetPos
=
gl
.
glGetUniformLocation
(
self
.
shaders
,
'
offsets
'
)
self
.
shader
.
delete
()
vertSrc
=
shaders
.
getVertexShader
(
self
)
fragSrc
=
shaders
.
getFragmentShader
(
self
)
self
.
shader
=
glslprogram
.
ShaderProgram
(
vertSrc
,
fragSrc
)
def
destroy
(
self
):
def
destroy
(
self
):
"""
Deletes the vertex/fragment shaders that were compiled by
"""
Deletes the vertex/fragment shaders that were compiled by
:func:`compileShaders`.
:func:`compileShaders`.
"""
"""
gl
.
glDeleteProgram
(
self
.
shaders
)
self
.
shader
.
delete
()
self
.
shader
=
None
def
updateShaders
(
self
):
def
updateShaders
(
self
):
...
@@ -48,19 +50,19 @@ def updateShaders(self):
...
@@ -48,19 +50,19 @@ def updateShaders(self):
# width/height (whichever is smaller)
# width/height (whichever is smaller)
outlineWidth
*=
10
outlineWidth
*=
10
offsets
=
2
*
[
min
(
outlineWidth
/
width
,
outlineWidth
/
height
)]
offsets
=
2
*
[
min
(
outlineWidth
/
width
,
outlineWidth
/
height
)]
offsets
=
np
.
array
(
offsets
,
dtype
=
np
.
float32
)
gl
.
glUseProgram
(
self
.
shader
s
)
self
.
shader
.
load
(
)
gl
.
glUniform1i
(
self
.
texPos
,
0
)
self
.
shader
.
set
(
'
tex
'
,
0
)
gl
.
glUniform2fv
(
self
.
offsetPos
,
1
,
offsets
)
self
.
shader
.
set
(
'
offsets
'
,
offsets
)
gl
.
glUseProgram
(
0
)
self
.
shader
.
unload
(
)
def
loadShaders
(
self
):
def
loadShaders
(
self
):
"""
Loads the :class:`.GLModel` vertex/fragment shaders.
"""
"""
Loads the :class:`.GLModel` vertex/fragment shaders.
"""
gl
.
glUseProgram
(
self
.
shaders
)
self
.
shader
.
load
()
def
unloadShaders
(
self
):
def
unloadShaders
(
self
):
"""
Un-loads the :class:`.GLModel` vertex/fragment shaders.
"""
"""
Un-loads the :class:`.GLModel` vertex/fragment shaders.
"""
gl
.
glUseProgram
(
0
)
self
.
shader
.
unload
(
)
This diff is collapsed.
Click to expand it.
fsl/fsleyes/gl/glmodel.py
+
1
−
0
View file @
61f6b3d6
...
@@ -76,6 +76,7 @@ class GLModel(globject.GLObject):
...
@@ -76,6 +76,7 @@ class GLModel(globject.GLObject):
globject
.
GLObject
.
__init__
(
self
)
globject
.
GLObject
.
__init__
(
self
)
self
.
shader
=
None
self
.
overlay
=
overlay
self
.
overlay
=
overlay
self
.
display
=
display
self
.
display
=
display
self
.
opts
=
display
.
getDisplayOpts
()
self
.
opts
=
display
.
getDisplayOpts
()
...
...
This diff is collapsed.
Click to expand it.
fsl/fsleyes/gl/glsl/program.py
+
1
−
1
View file @
61f6b3d6
...
@@ -315,7 +315,7 @@ class ShaderProgram(object):
...
@@ -315,7 +315,7 @@ class ShaderProgram(object):
def
_uniform_vec2
(
self
,
pos
,
val
):
def
_uniform_vec2
(
self
,
pos
,
val
):
gl
.
glUniform2fv
(
pos
,
np
.
array
(
val
,
dtype
=
np
.
float32
))
gl
.
glUniform2fv
(
pos
,
1
,
np
.
array
(
val
,
dtype
=
np
.
float32
))
def
_uniform_vec3
(
self
,
pos
,
val
):
def
_uniform_vec3
(
self
,
pos
,
val
):
...
...
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