OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
libvgcode::SegmentTemplate Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libvgcode/src/SegmentTemplate.hpp>

Public Member Functions

 SegmentTemplate ()=default
 ~SegmentTemplate ()
 SegmentTemplate (const SegmentTemplate &other)=delete
 SegmentTemplate (SegmentTemplate &&other)=delete
SegmentTemplate & operator= (const SegmentTemplate &other)=delete
SegmentTemplate & operator= (SegmentTemplate &&other)=delete
void init ()
void shutdown ()
void render (size_t count)
size_t size_in_bytes_gpu () const

Private Attributes

unsigned int m_vao_id { 0 }
unsigned int m_vbo_id { 0 }
unsigned int m_ibo_id { 0 }
size_t m_size_in_bytes_gpu { 0 }

Detailed Description

Constructor & Destructor Documentation

◆ SegmentTemplate() [1/3]

libvgcode::SegmentTemplate::SegmentTemplate ( )
default

Referenced by SegmentTemplate(), SegmentTemplate(), operator=(), and operator=().

Here is the caller graph for this function:

◆ ~SegmentTemplate()

libvgcode::SegmentTemplate::~SegmentTemplate ( )
inline
16{ shutdown(); }
void shutdown()
Definition SegmentTemplate.cpp:74

References shutdown().

Here is the call graph for this function:

◆ SegmentTemplate() [2/3]

libvgcode::SegmentTemplate::SegmentTemplate ( const SegmentTemplate & other)
delete

References SegmentTemplate().

Here is the call graph for this function:

◆ SegmentTemplate() [3/3]

libvgcode::SegmentTemplate::SegmentTemplate ( SegmentTemplate && other)
delete

References SegmentTemplate().

Here is the call graph for this function:

Member Function Documentation

◆ init()

void libvgcode::SegmentTemplate::init ( )
40{
41 if (m_vao_id != 0)
42 return;
43
44 m_size_in_bytes_gpu += VERTEX_DATA.size() * sizeof(uint32_t) + INDEX_DATA.size() * sizeof(uint16_t);
45
46 int curr_vertex_array;
47 glsafe(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &curr_vertex_array));
48 int curr_array_buffer;
49 glsafe(glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &curr_array_buffer));
50
53
56 glsafe(glBufferData(GL_ARRAY_BUFFER, VERTEX_DATA.size() * sizeof(uint32_t), VERTEX_DATA.data(), GL_STATIC_DRAW));
58#ifdef ENABLE_OPENGL_ES
59 glsafe(glVertexAttribPointer(0, 1, GL_UNSIGNED_INT, GL_FALSE, 0, (const void*)0));
60#else
61 glsafe(glVertexAttribIPointer(0, 1, GL_UNSIGNED_INT, 0, (const void*)0));
62#endif // ENABLE_OPENGL_ES
63
64 // The element buffer binding is part of the vao state, so it is left bound here
65 // and restored together with the vao.
69
70 glsafe(glBindBuffer(GL_ARRAY_BUFFER, curr_array_buffer));
71 glsafe(glBindVertexArray(curr_vertex_array));
72}
#define glsafe(cmd)
Definition OpenGLUtils.hpp:25
unsigned int m_vao_id
Definition SegmentTemplate.hpp:41
size_t m_size_in_bytes_gpu
Definition SegmentTemplate.hpp:47
unsigned int m_vbo_id
Definition SegmentTemplate.hpp:42
unsigned int m_ibo_id
Definition SegmentTemplate.hpp:43
#define glGenBuffers
Definition gl.h:3769
#define glBindBuffer
Definition gl.h:3267
#define glBindVertexArray
Definition gl.h:3307
#define glVertexAttribIPointer
Definition gl.h:5277
#define GL_ARRAY_BUFFER_BINDING
Definition gl.h:239
#define GL_UNSIGNED_INT
Definition gl.h:1940
#define glEnableVertexAttribArray
Definition gl.h:3673
#define glGetIntegerv
Definition gl.h:3873
#define GL_ARRAY_BUFFER
Definition gl.h:238
#define glGenVertexArrays
Definition gl.h:3791
#define glVertexAttribPointer
Definition gl.h:5315
#define glBufferData
Definition gl.h:3339
#define GL_STATIC_DRAW
Definition gl.h:1633
#define GL_FALSE
Definition gl.h:648
#define GL_ELEMENT_ARRAY_BUFFER
Definition gl.h:636
#define GL_VERTEX_ARRAY_BINDING
Definition gl.h:1989
static constexpr const std::array< uint32_t, 8 > VERTEX_DATA
Definition SegmentTemplate.cpp:24
static constexpr const std::array< uint16_t, 24 > INDEX_DATA
Definition SegmentTemplate.cpp:28

References GL_ARRAY_BUFFER, GL_ARRAY_BUFFER_BINDING, GL_ELEMENT_ARRAY_BUFFER, GL_FALSE, GL_STATIC_DRAW, GL_UNSIGNED_INT, GL_VERTEX_ARRAY_BINDING, glBindBuffer, glBindVertexArray, glBufferData, glEnableVertexAttribArray, glGenBuffers, glGenVertexArrays, glGetIntegerv, glsafe, glVertexAttribIPointer, glVertexAttribPointer, libvgcode::INDEX_DATA, m_ibo_id, m_size_in_bytes_gpu, m_vao_id, m_vbo_id, and libvgcode::VERTEX_DATA.

◆ operator=() [1/2]

SegmentTemplate & libvgcode::SegmentTemplate::operator= ( const SegmentTemplate & other)
delete

References SegmentTemplate().

Here is the call graph for this function:

◆ operator=() [2/2]

SegmentTemplate & libvgcode::SegmentTemplate::operator= ( SegmentTemplate && other)
delete

References SegmentTemplate(), and count.

Here is the call graph for this function:

◆ render()

void libvgcode::SegmentTemplate::render ( size_t count)
93{
94 if (m_vao_id == 0 || m_vbo_id == 0 || m_ibo_id == 0 || count == 0)
95 return;
96
97 int curr_vertex_array;
98 glsafe(glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &curr_vertex_array));
99
102 nullptr, static_cast<GLsizei>(count)));
103 glsafe(glBindVertexArray(curr_vertex_array));
104}
static unsigned int count
Definition AuxiliaryDataViewModel.cpp:246
#define GL_UNSIGNED_SHORT
Definition gl.h:1975
#define GL_TRIANGLES
Definition gl.h:1887
int GLsizei
Definition gl.h:2065
#define glDrawElementsInstanced
Definition gl.h:3639

References count, GL_TRIANGLES, GL_UNSIGNED_SHORT, GL_VERTEX_ARRAY_BINDING, glBindVertexArray, glDrawElementsInstanced, glGetIntegerv, glsafe, libvgcode::INDEX_DATA, m_ibo_id, m_vao_id, and m_vbo_id.

◆ shutdown()

void libvgcode::SegmentTemplate::shutdown ( )
75{
76 if (m_ibo_id != 0) {
78 m_ibo_id = 0;
79 }
80 if (m_vbo_id != 0) {
82 m_vbo_id = 0;
83 }
84 if (m_vao_id != 0) {
86 m_vao_id = 0;
87 }
88
90}
#define glDeleteVertexArrays
Definition gl.h:3591
#define glDeleteBuffers
Definition gl.h:3563

References glDeleteBuffers, glDeleteVertexArrays, glsafe, m_ibo_id, m_size_in_bytes_gpu, m_vao_id, and m_vbo_id.

Referenced by ~SegmentTemplate().

Here is the caller graph for this function:

◆ size_in_bytes_gpu()

size_t libvgcode::SegmentTemplate::size_in_bytes_gpu ( ) const
inline
35{ return m_size_in_bytes_gpu; }

References m_size_in_bytes_gpu.

Member Data Documentation

◆ m_ibo_id

unsigned int libvgcode::SegmentTemplate::m_ibo_id { 0 }
private
43{ 0 };

Referenced by init(), render(), and shutdown().

◆ m_size_in_bytes_gpu

size_t libvgcode::SegmentTemplate::m_size_in_bytes_gpu { 0 }
private
47{ 0 };

Referenced by init(), shutdown(), and size_in_bytes_gpu().

◆ m_vao_id

unsigned int libvgcode::SegmentTemplate::m_vao_id { 0 }
private
41{ 0 };

Referenced by init(), render(), and shutdown().

◆ m_vbo_id

unsigned int libvgcode::SegmentTemplate::m_vbo_id { 0 }
private
42{ 0 };

Referenced by init(), render(), and shutdown().


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