Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
plugin-GUI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
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
yehaojie
plugin-GUI
Commits
3e1bab6d
Commit
3e1bab6d
authored
13 years ago
by
Stuart Layton
Browse files
Options
Downloads
Plain Diff
Merge branch 'spikevis' of github.com:open-ephys/GUI into spikevis
parents
40d39b0d
b19c24d5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Source/Processors/Visualization/SpikePlotting/ProjectionAxes.cpp
+28
-18
28 additions, 18 deletions
...Processors/Visualization/SpikePlotting/ProjectionAxes.cpp
with
28 additions
and
18 deletions
Source/Processors/Visualization/SpikePlotting/ProjectionAxes.cpp
+
28
−
18
View file @
3e1bab6d
...
...
@@ -173,6 +173,7 @@ void ProjectionAxes::setPosition(int x, int y, int w, int h){
// only invalidate the texture if its size has actually changed
if
(
w
!=
GenericAxes
::
width
||
h
!=
GenericAxes
::
height
)
invalidateTexture
();
GenericAxes
::
setPosition
(
x
,
y
,
w
,
h
);
}
...
...
@@ -194,15 +195,20 @@ void ProjectionAxes::createTexture(){
texHeight
=
BaseUIElement
::
height
;
std
::
cout
<<
"Creating a new texture of size:"
<<
texWidth
<<
"x"
<<
texHeight
<<
std
::
endl
;
// Delete the old texture
glDeleteTextures
(
1
,
&
textureId
);
// Generate a new texture
glGenTextures
(
1
,
&
textureId
);
// Bind the texture, and set the appropriate parameters
glBindTexture
(
GL_TEXTURE_2D
,
textureId
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_GENERATE_MIPMAP
,
GL_TRUE
);
// automatic mipmap generation included in OpenGL v1.4
glTexParameteri
(
GL_TEXTURE_2D
,
GL_GENERATE_MIPMAP
,
GL_TRUE
);
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA8
,
texWidth
,
texHeight
,
0
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
0
);
// generate a new FrameBufferObject
createFBO
();
// the texture should now be valid, set the flag appropriately
isTextureValid
=
true
;
createFBO
();
}
void
ProjectionAxes
::
createFBO
(){
...
...
@@ -210,26 +216,28 @@ void ProjectionAxes::createFBO(){
// if (!isTextureValid)
// createTexture();
// Delete the old frame buffer, render buffer
glDeleteFramebuffers
(
1
,
&
fboId
);
glDeleteRenderbuffers
(
1
,
&
rboId
);
glGenFramebuffersEXT
(
1
,
&
fboId
);
// Generate and Bind the frame buffer
glGenFramebuffersEXT
(
1
,
&
fboId
);
glBindFramebufferEXT
(
GL_FRAMEBUFFER_EXT
,
fboId
);
// Generate and bind the new Render Buffer
glGenRenderbuffersEXT
(
1
,
&
rboId
);
glBindRenderbufferEXT
(
GL_RENDERBUFFER_EXT
,
rboId
);
glRenderbufferStorageEXT
(
GL_RENDERBUFFER_EXT
,
GL_DEPTH_COMPONENT
,
texWidth
,
texHeight
);
glBindRenderbufferEXT
(
GL_RENDERBUFFER_EXT
,
0
);
// Attach the texture to the framebuffer
glFramebufferTexture2DEXT
(
GL_FRAMEBUFFER_EXT
,
GL_COLOR_ATTACHMENT0_EXT
,
GL_TEXTURE_2D
,
textureId
,
0
);
glFramebufferRenderbufferEXT
(
GL_FRAMEBUFFER_EXT
,
GL_DEPTH_ATTACHMENT_EXT
,
GL_RENDERBUFFER_EXT
,
rboId
);
bool
status
=
check
Frame
b
uffer
Status
();
if
(
!
status
){
std
::
cout
<<
"FrameBufferObject
not created
! Quitting!"
<<
std
::
endl
;
// If the
Frame
B
uffer
wasn't created then we have a bigger problem. Abort the program.
if
(
!
checkFramebufferStatus
()){
std
::
cout
<<
"FrameBufferObject not created! Are you running the newest version of OpenGL?"
<<
std
::
endl
;
std
::
cout
<<
"FrameBufferObject
s are REQUIRED
! Quitting!"
<<
std
::
endl
;
exit
(
1
);
}
...
...
@@ -265,8 +273,6 @@ void ProjectionAxes::drawSpikesToTexture(bool allSpikes){
// bind the original FrameBuffer
glBindFramebufferEXT
(
GL_FRAMEBUFFER_EXT
,
0
);
// Did something fail? If so invalidate and re-render the texture
}
void
ProjectionAxes
::
invalidateTexture
(){
...
...
@@ -275,15 +281,17 @@ void ProjectionAxes::invalidateTexture(){
void
ProjectionAxes
::
drawTexturedQuad
(){
//glViewport(BaseUIElement::xpos, BaseUIElement::ypos + BaseUIElement::height, texWidth, texHeight);
BaseUIElement
::
setGlViewport
();
// We need to scale the viewport in this case because we want to fill it with a quad.
// if we load identity then we can use a quad bound by (-1, 1);
glLoadIdentity
();
// Bind the texture to render
glBindTexture
(
GL_TEXTURE_2D
,
textureId
);
// Build the quad
int
size
=
1
;
int
texS
=
1
;
glBegin
(
GL_QUADS
);
glColor4f
(
1
,
1
,
1
,
1
);
glTexCoord2f
(
texS
,
texS
);
glVertex3f
(
size
,
size
,
0
);
...
...
@@ -292,27 +300,29 @@ void ProjectionAxes::drawTexturedQuad(){
glTexCoord2f
(
texS
,
0
);
glVertex3f
(
size
,
-
1
*
size
,
0
);
glEnd
();
// Unbind the texture
glBindTexture
(
GL_TEXTURE_2D
,
0
);
}
void
ProjectionAxes
::
clear
(){
//reset buffIDx and totalSpikes
buffIdx
=
0
;
totalSpikes
=
0
;
// set flag to clear on next draw
clearOnNextDraw
=
true
;
}
void
ProjectionAxes
::
clearTexture
(){
std
::
cout
<<
"ProjectinAxes::clearTexture() --> Clearing the Texture!"
<<
std
::
endl
;
glViewport
(
0
,
0
,
texWidth
,
texHeight
);
glLoadIdentity
();
setViewportRange
(
xlims
[
0
],
ylims
[
0
],
xlims
[
1
],
ylims
[
1
]);
// set the rendering destination to FBO
glBindFramebufferEXT
(
GL_FRAMEBUFFER_EXT
,
fboId
);
//
plot to the texture
//
Clear the framebufferObject
glClearColor
(
0
,
0
,
0
,
1
);
glClear
(
GL_COLOR_BUFFER_BIT
);
glBindFramebufferEXT
(
GL_FRAMEBUFFER_EXT
,
0
);
...
...
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