-
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.
started working on sphere-line intersection in GUI
- Loading branch information
1 parent
3b8aa1d
commit b028dca
Showing
6 changed files
with
214 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright(c) 2012, 2020 Tel - Aviv University(Israel). | ||
// All rights reserved. | ||
// | ||
// This file is part of CGAL (www.cgal.org). | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial | ||
// | ||
// Author(s): Engin Deniz Diktas <[email protected]> | ||
|
||
#include "SingleVertex.h" | ||
|
||
|
||
SingleVertex::SingleVertex(const QVector3D& pos) | ||
{ | ||
initializeOpenGLFunctions(); | ||
|
||
m_pos = pos; | ||
m_visible = true; | ||
|
||
// 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(m_pos); | ||
auto vertex_buffer_data = reinterpret_cast<const void*>(&m_pos); | ||
glBufferData(GL_ARRAY_BUFFER, | ||
vertex_buffer_size, | ||
vertex_buffer_data, | ||
GL_DYNAMIC_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 SingleVertex::set_visible(bool flag) | ||
{ | ||
m_visible = flag; | ||
} | ||
void SingleVertex::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); | ||
} | ||
const QVector3D& SingleVertex::get_pos() const | ||
{ | ||
return m_pos; | ||
} | ||
|
||
|
||
void SingleVertex::draw() | ||
{ | ||
if (m_visible) | ||
{ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright(c) 2012, 2020 Tel - Aviv University(Israel). | ||
// All rights reserved. | ||
// | ||
// This file is part of CGAL (www.cgal.org). | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial | ||
// | ||
// Author(s): Engin Deniz Diktas <[email protected]> | ||
|
||
#ifndef SINGLE_VERTEX_H | ||
#define SINGLE_VERTEX_H | ||
|
||
#include <vector> | ||
#include <qvector3d.h> | ||
#include "Common_defs.h" | ||
|
||
|
||
class SingleVertex : protected OpenGLFunctionsBase | ||
{ | ||
public: | ||
SingleVertex(const QVector3D& pos); | ||
|
||
void set_visible(bool flag); | ||
void set_pos(const QVector3D& pos); | ||
const QVector3D& get_pos() const; | ||
|
||
void draw(); | ||
|
||
private: | ||
bool m_visible; | ||
GLuint m_vao, m_vbo; | ||
QVector3D m_pos; | ||
}; | ||
|
||
|
||
#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