1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Img3D/Plot/BodyPlotter.cpp
//! @brief Implements class BodyPlotter.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "Img3D/Plot/BodyPlotter.h"
#include "Img3D/Model/Geometry.h"
namespace Img3D {
BodyPlotter::BodyPlotter(Geometry const& geometry)
{
initializeOpenGLFunctions();
const QVector<Geometry::VertexAndNormal>& mesh = geometry.mesh();
m_vertex_count = mesh.count();
QOpenGLVertexArrayObject::Binder dummy(&m_vao);
m_gl_buffer.create();
m_gl_buffer.bind();
m_gl_buffer.allocate(mesh.constData(), m_vertex_count * int(sizeof(Geometry::VertexAndNormal)));
glEnableVertexAttribArray(0); // vertices
glEnableVertexAttribArray(1); // normals
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 2 * sizeof(F3), nullptr);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 2 * sizeof(F3),
reinterpret_cast<void*>(sizeof(F3)));
}
void BodyPlotter::draw()
{
QOpenGLVertexArrayObject::Binder dummy(&m_vao);
glDrawArrays(GL_TRIANGLES, 0, m_vertex_count);
}
} // namespace Img3D
|