-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor on Single_vertex: position is held inside this class now (no…
… need for the application to keep track of it)
- Loading branch information
1 parent
a323352
commit 96145bf
Showing
5 changed files
with
34 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,10 @@ | |
// | ||
// Author(s): Engin Deniz Diktas <[email protected]> | ||
|
||
#include "SingleVertex.h" | ||
#include "Single_vertex.h" | ||
|
||
|
||
SingleVertex::SingleVertex(const QVector3D& pos) | ||
Single_vertex::Single_vertex(const QVector3D& pos) | ||
{ | ||
initializeOpenGLFunctions(); | ||
|
||
|
@@ -47,35 +47,40 @@ SingleVertex::SingleVertex(const QVector3D& pos) | |
} | ||
|
||
|
||
void SingleVertex::set_visible(bool flag) | ||
void Single_vertex::set_visible(bool flag) | ||
{ | ||
m_visible = flag; | ||
} | ||
void SingleVertex::set_pos(const QVector3D& pos) | ||
void Single_vertex::set_pos(const QVector3D& pos) | ||
{ | ||
m_pos = pos; | ||
glBindBuffer(GL_ARRAY_BUFFER, m_vbo); | ||
auto vertex_buffer_size = sizeof(m_pos); | ||
auto vertex_buffer_data = reinterpret_cast<const void*>(&m_pos); | ||
auto offset = 0; | ||
glBufferSubData(GL_ARRAY_BUFFER, | ||
offset, | ||
vertex_buffer_size, | ||
vertex_buffer_data); | ||
m_update = true; | ||
} | ||
const QVector3D& SingleVertex::get_pos() const | ||
const QVector3D& Single_vertex::get_pos() const | ||
{ | ||
return m_pos; | ||
} | ||
|
||
|
||
void SingleVertex::draw() | ||
void Single_vertex::draw() | ||
{ | ||
if (m_visible) | ||
{ | ||
if (m_update) | ||
{ | ||
glBindBuffer(GL_ARRAY_BUFFER, m_vbo); | ||
auto vertex_buffer_size = sizeof(m_pos); | ||
auto vertex_buffer_data = reinterpret_cast<const void*>(&m_pos); | ||
auto offset = 0; | ||
glBufferSubData(GL_ARRAY_BUFFER, | ||
offset, | ||
vertex_buffer_size, | ||
vertex_buffer_data); | ||
m_update = false; | ||
} | ||
|
||
glBindVertexArray(m_vao); | ||
glDrawArrays(GL_POINTS, 0, 1); | ||
glBindVertexArray(0); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters