-
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: separated Geodesic arcs and their representation into diffe…
…rent classes
- Loading branch information
1 parent
d68e430
commit f9c98fe
Showing
8 changed files
with
108 additions
and
70 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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
#include "Line_strips.h" | ||
|
||
|
||
Line_strips::Line_strips(Line_strip_approx& lsa) | ||
{ | ||
initializeOpenGLFunctions(); | ||
|
||
const auto& vertex_data = lsa.points; | ||
m_offsets = lsa.offsets; | ||
|
||
// DEFINE OPENGL BUFFERS | ||
glGenVertexArrays(1, &m_vao); | ||
glBindVertexArray(m_vao); | ||
|
||
|
||
// Vertex Buffer | ||
glGenBuffers(1, &m_vbo); | ||
glBindBuffer(GL_ARRAY_BUFFER, m_vbo); | ||
auto vertex_buffer_size = sizeof(QVector3D) * vertex_data.size(); | ||
auto vertex_buffer_data = reinterpret_cast<const void*>(vertex_data.data()); | ||
glBufferData(GL_ARRAY_BUFFER, | ||
vertex_buffer_size, | ||
vertex_buffer_data, | ||
GL_STATIC_DRAW); | ||
|
||
// Position Vertex-Attribute | ||
GLint position_attrib_index = 0; | ||
const void* position_offset = 0; | ||
GLsizei stride = 0; | ||
glVertexAttribPointer(position_attrib_index, | ||
3, | ||
GL_FLOAT, GL_FALSE, | ||
stride, | ||
position_offset); | ||
glEnableVertexAttribArray(position_attrib_index); | ||
|
||
glBindBuffer(GL_ARRAY_BUFFER, 0); | ||
glBindVertexArray(0); | ||
} | ||
|
||
void Line_strips::draw() | ||
{ | ||
glBindVertexArray(m_vao); | ||
{ | ||
for (int i = 1; i < m_offsets.size(); i++) | ||
{ | ||
const auto first = m_offsets[i - 1]; | ||
const auto count = m_offsets[i] - first; | ||
glDrawArrays(GL_LINE_STRIP, first, count); | ||
} | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
#ifndef LINE_STRIPS_H | ||
#define LINE_STRIPS_H | ||
|
||
#include <vector> | ||
#include "Common_defs.h" | ||
|
||
|
||
class Line_strips : protected OpenGLFunctionsBase | ||
{ | ||
public: | ||
Line_strips(Line_strip_approx& lsa); | ||
|
||
void draw(); | ||
|
||
private: | ||
GLuint m_vao, m_vbo; | ||
std::vector<GLuint> m_offsets; | ||
}; | ||
|
||
|
||
#endif |
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