BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GUI::RealSpace::Buffer Class Referencefinal

Description

GL buffer.

Definition at line 28 of file buffer.h.

Inheritance diagram for GUI::RealSpace::Buffer:
[legend]
Collaboration diagram for GUI::RealSpace::Buffer:
[legend]

Public Member Functions

 Buffer (Geometry const &)
 
void draw ()
 

Private Attributes

QOpenGLBuffer m_glBuffer
 
QOpenGLVertexArrayObject m_vao
 
int m_vertexCount
 

Constructor & Destructor Documentation

◆ Buffer()

GUI::RealSpace::Buffer::Buffer ( Geometry const &  geometry)

Definition at line 27 of file buffer.cpp.

28 {
29  initializeOpenGLFunctions();
30 
31  const auto& mesh = geometry.m_mesh;
32  m_vertexCount = mesh.count();
33 
34  QOpenGLVertexArrayObject::Binder dummy(&m_vao);
35 
36  m_glBuffer.create();
37  m_glBuffer.bind();
38  m_glBuffer.allocate(mesh.constData(), m_vertexCount * int(sizeof(Geometry::Vert_Normal)));
39 
40  glEnableVertexAttribArray(0); // vertices
41  glEnableVertexAttribArray(1); // normals
42 
43  glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 2 * sizeof(Vector3D), nullptr);
44  glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 2 * sizeof(Vector3D),
45  reinterpret_cast<void*>(sizeof(Vector3D)));
46 }
QOpenGLVertexArrayObject m_vao
Definition: buffer.h:35
QOpenGLBuffer m_glBuffer
Definition: buffer.h:36

References m_glBuffer, GUI::RealSpace::Geometry::m_mesh, m_vao, and m_vertexCount.

Member Function Documentation

◆ draw()

void GUI::RealSpace::Buffer::draw ( )

Definition at line 48 of file buffer.cpp.

49 {
50  QOpenGLVertexArrayObject::Binder dummy(&m_vao);
51  glDrawArrays(GL_TRIANGLES, 0, m_vertexCount);
52 }

References m_vao, and m_vertexCount.

Referenced by GUI::RealSpace::Canvas::draw().

Member Data Documentation

◆ m_glBuffer

QOpenGLBuffer GUI::RealSpace::Buffer::m_glBuffer
private

Definition at line 36 of file buffer.h.

Referenced by Buffer().

◆ m_vao

QOpenGLVertexArrayObject GUI::RealSpace::Buffer::m_vao
private

Definition at line 35 of file buffer.h.

Referenced by Buffer(), and draw().

◆ m_vertexCount

int GUI::RealSpace::Buffer::m_vertexCount
private

Definition at line 34 of file buffer.h.

Referenced by Buffer(), and draw().


The documentation for this class was generated from the following files: