Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
igl::opengl::MeshGL Class Reference

#include <src/libigl/igl/opengl/MeshGL.h>

+ Collaboration diagram for igl::opengl::MeshGL:

Public Types

enum  DirtyFlags {
  DIRTY_NONE = 0x0000 , DIRTY_POSITION = 0x0001 , DIRTY_UV = 0x0002 , DIRTY_NORMAL = 0x0004 ,
  DIRTY_AMBIENT = 0x0008 , DIRTY_DIFFUSE = 0x0010 , DIRTY_SPECULAR = 0x0020 , DIRTY_TEXTURE = 0x0040 ,
  DIRTY_FACE = 0x0080 , DIRTY_MESH = 0x00FF , DIRTY_OVERLAY_LINES = 0x0100 , DIRTY_OVERLAY_POINTS = 0x0200 ,
  DIRTY_ALL = 0x03FF
}
 
typedef unsigned int GLuint
 
typedef Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajorRowMatrixXf
 

Public Member Functions

IGL_INLINE void init ()
 
IGL_INLINE void free ()
 
IGL_INLINE void init_buffers ()
 
IGL_INLINE void bind_mesh ()
 
IGL_INLINE void draw_mesh (bool solid)
 Draw the currently buffered mesh (either solid or wireframe)
 
IGL_INLINE void bind_overlay_lines ()
 
IGL_INLINE void draw_overlay_lines ()
 Draw the currently buffered line overlay.
 
IGL_INLINE void bind_overlay_points ()
 
IGL_INLINE void draw_overlay_points ()
 Draw the currently buffered point overlay.
 
IGL_INLINE void free_buffers ()
 

Public Attributes

bool is_initialized = false
 
GLuint vao_mesh
 
GLuint vao_overlay_lines
 
GLuint vao_overlay_points
 
GLuint shader_mesh
 
GLuint shader_overlay_lines
 
GLuint shader_overlay_points
 
GLuint vbo_V
 
GLuint vbo_V_uv
 
GLuint vbo_V_normals
 
GLuint vbo_V_ambient
 
GLuint vbo_V_diffuse
 
GLuint vbo_V_specular
 
GLuint vbo_F
 
GLuint vbo_tex
 
GLuint vbo_lines_F
 
GLuint vbo_lines_V
 
GLuint vbo_lines_V_colors
 
GLuint vbo_points_F
 
GLuint vbo_points_V
 
GLuint vbo_points_V_colors
 
RowMatrixXf V_vbo
 
RowMatrixXf V_normals_vbo
 
RowMatrixXf V_ambient_vbo
 
RowMatrixXf V_diffuse_vbo
 
RowMatrixXf V_specular_vbo
 
RowMatrixXf V_uv_vbo
 
RowMatrixXf lines_V_vbo
 
RowMatrixXf lines_V_colors_vbo
 
RowMatrixXf points_V_vbo
 
RowMatrixXf points_V_colors_vbo
 
int tex_u
 
int tex_v
 
Eigen::Matrix< char, Eigen::Dynamic, 1 > tex
 
Eigen::Matrix< unsigned, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajorF_vbo
 
Eigen::Matrix< unsigned, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajorlines_F_vbo
 
Eigen::Matrix< unsigned, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajorpoints_F_vbo
 
uint32_t dirty
 

Detailed Description

Member Typedef Documentation

◆ GLuint

typedef unsigned int igl::opengl::MeshGL::GLuint

◆ RowMatrixXf

Member Enumeration Documentation

◆ DirtyFlags

Enumerator
DIRTY_NONE 
DIRTY_POSITION 
DIRTY_UV 
DIRTY_NORMAL 
DIRTY_AMBIENT 
DIRTY_DIFFUSE 
DIRTY_SPECULAR 
DIRTY_TEXTURE 
DIRTY_FACE 
DIRTY_MESH 
DIRTY_OVERLAY_LINES 
DIRTY_OVERLAY_POINTS 
DIRTY_ALL 
29 {
30 DIRTY_NONE = 0x0000,
31 DIRTY_POSITION = 0x0001,
32 DIRTY_UV = 0x0002,
33 DIRTY_NORMAL = 0x0004,
34 DIRTY_AMBIENT = 0x0008,
35 DIRTY_DIFFUSE = 0x0010,
36 DIRTY_SPECULAR = 0x0020,
37 DIRTY_TEXTURE = 0x0040,
38 DIRTY_FACE = 0x0080,
39 DIRTY_MESH = 0x00FF,
40 DIRTY_OVERLAY_LINES = 0x0100,
41 DIRTY_OVERLAY_POINTS = 0x0200,
42 DIRTY_ALL = 0x03FF
43 };
@ DIRTY_FACE
Definition MeshGL.h:38
@ DIRTY_NORMAL
Definition MeshGL.h:33
@ DIRTY_UV
Definition MeshGL.h:32
@ DIRTY_POSITION
Definition MeshGL.h:31
@ DIRTY_ALL
Definition MeshGL.h:42
@ DIRTY_SPECULAR
Definition MeshGL.h:36
@ DIRTY_MESH
Definition MeshGL.h:39
@ DIRTY_AMBIENT
Definition MeshGL.h:34
@ DIRTY_NONE
Definition MeshGL.h:30
@ DIRTY_TEXTURE
Definition MeshGL.h:37
@ DIRTY_OVERLAY_LINES
Definition MeshGL.h:40
@ DIRTY_DIFFUSE
Definition MeshGL.h:35
@ DIRTY_OVERLAY_POINTS
Definition MeshGL.h:41

Member Function Documentation

◆ bind_mesh()

IGL_INLINE void igl::opengl::MeshGL::bind_mesh ( )
73{
74 glBindVertexArray(vao_mesh);
75 glUseProgram(shader_mesh);
82
83 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo_F);
85 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned)*F_vbo.size(), F_vbo.data(), GL_DYNAMIC_DRAW);
86
87 glActiveTexture(GL_TEXTURE0);
88 glBindTexture(GL_TEXTURE_2D, vbo_tex);
90 {
91 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
92 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
93 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
94 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
95 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
96 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex_u, tex_v, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex.data());
97 }
98 glUniform1i(glGetUniformLocation(shader_mesh,"tex"), 0);
99 dirty &= ~MeshGL::DIRTY_MESH;
100}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Definition PlainObjectBase.h:255
GLuint vbo_tex
Definition MeshGL.h:61
RowMatrixXf V_normals_vbo
Definition MeshGL.h:73
Eigen::Matrix< unsigned, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > F_vbo
Definition MeshGL.h:87
GLuint vbo_V_uv
Definition MeshGL.h:54
GLuint vbo_V_normals
Definition MeshGL.h:55
uint32_t dirty
Definition MeshGL.h:92
Eigen::Matrix< char, Eigen::Dynamic, 1 > tex
Definition MeshGL.h:85
RowMatrixXf V_uv_vbo
Definition MeshGL.h:77
RowMatrixXf V_diffuse_vbo
Definition MeshGL.h:75
int tex_v
Definition MeshGL.h:84
GLuint vao_mesh
Definition MeshGL.h:46
GLuint vbo_V
Definition MeshGL.h:53
RowMatrixXf V_ambient_vbo
Definition MeshGL.h:74
GLuint vbo_V_specular
Definition MeshGL.h:58
GLuint vbo_F
Definition MeshGL.h:60
RowMatrixXf V_vbo
Definition MeshGL.h:72
GLuint vbo_V_ambient
Definition MeshGL.h:56
GLuint vbo_V_diffuse
Definition MeshGL.h:57
GLuint shader_mesh
Definition MeshGL.h:49
RowMatrixXf V_specular_vbo
Definition MeshGL.h:76
int tex_u
Definition MeshGL.h:83
IGL_INLINE GLint bind_vertex_attrib_array(const GLuint program_shader, const std::string &name, GLuint bufferID, const Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > &M, bool refresh)
Definition bind_vertex_attrib_array.cpp:3

References igl::opengl::bind_vertex_attrib_array(), DIRTY_AMBIENT, DIRTY_DIFFUSE, DIRTY_FACE, DIRTY_NORMAL, DIRTY_POSITION, DIRTY_SPECULAR, DIRTY_TEXTURE, and DIRTY_UV.

+ Here is the call graph for this function:

◆ bind_overlay_lines()

IGL_INLINE void igl::opengl::MeshGL::bind_overlay_lines ( )
103{
104 bool is_dirty = dirty & MeshGL::DIRTY_OVERLAY_LINES;
105
106 glBindVertexArray(vao_overlay_lines);
107 glUseProgram(shader_overlay_lines);
110
111 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo_lines_F);
112 if (is_dirty)
113 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned)*lines_F_vbo.size(), lines_F_vbo.data(), GL_DYNAMIC_DRAW);
114
116}
GLuint vbo_lines_F
Definition MeshGL.h:63
RowMatrixXf lines_V_colors_vbo
Definition MeshGL.h:79
GLuint vbo_lines_V_colors
Definition MeshGL.h:65
Eigen::Matrix< unsigned, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > lines_F_vbo
Definition MeshGL.h:88
GLuint vbo_lines_V
Definition MeshGL.h:64
GLuint shader_overlay_lines
Definition MeshGL.h:50
RowMatrixXf lines_V_vbo
Definition MeshGL.h:78
GLuint vao_overlay_lines
Definition MeshGL.h:47

References igl::opengl::bind_vertex_attrib_array(), and DIRTY_OVERLAY_LINES.

+ Here is the call graph for this function:

◆ bind_overlay_points()

IGL_INLINE void igl::opengl::MeshGL::bind_overlay_points ( )
119{
120 bool is_dirty = dirty & MeshGL::DIRTY_OVERLAY_POINTS;
121
122 glBindVertexArray(vao_overlay_points);
123 glUseProgram(shader_overlay_points);
126
127 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo_points_F);
128 if (is_dirty)
129 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned)*points_F_vbo.size(), points_F_vbo.data(), GL_DYNAMIC_DRAW);
130
132}
GLuint vbo_points_V_colors
Definition MeshGL.h:68
GLuint vao_overlay_points
Definition MeshGL.h:48
GLuint shader_overlay_points
Definition MeshGL.h:51
Eigen::Matrix< unsigned, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > points_F_vbo
Definition MeshGL.h:89
RowMatrixXf points_V_vbo
Definition MeshGL.h:80
GLuint vbo_points_V
Definition MeshGL.h:67
GLuint vbo_points_F
Definition MeshGL.h:66
RowMatrixXf points_V_colors_vbo
Definition MeshGL.h:81

References igl::opengl::bind_vertex_attrib_array(), and DIRTY_OVERLAY_POINTS.

+ Here is the call graph for this function:

◆ draw_mesh()

IGL_INLINE void igl::opengl::MeshGL::draw_mesh ( bool  solid)

Draw the currently buffered mesh (either solid or wireframe)

135{
136 glPolygonMode(GL_FRONT_AND_BACK, solid ? GL_FILL : GL_LINE);
137
138 /* Avoid Z-buffer fighting between filled triangles & wireframe lines */
139 if (solid)
140 {
141 glEnable(GL_POLYGON_OFFSET_FILL);
142 glPolygonOffset(1.0, 1.0);
143 }
144 glDrawElements(GL_TRIANGLES, 3*F_vbo.rows(), GL_UNSIGNED_INT, 0);
145
146 glDisable(GL_POLYGON_OFFSET_FILL);
147 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
148}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rows() const
Definition PlainObjectBase.h:151
#define GL_TRIANGLES
Definition glu-libtess.h:75

References GL_TRIANGLES.

◆ draw_overlay_lines()

IGL_INLINE void igl::opengl::MeshGL::draw_overlay_lines ( )

Draw the currently buffered line overlay.

151{
152 glDrawElements(GL_LINES, lines_F_vbo.rows(), GL_UNSIGNED_INT, 0);
153}

◆ draw_overlay_points()

IGL_INLINE void igl::opengl::MeshGL::draw_overlay_points ( )

Draw the currently buffered point overlay.

156{
157 glDrawElements(GL_POINTS, points_F_vbo.rows(), GL_UNSIGNED_INT, 0);
158}

◆ free()

IGL_INLINE void igl::opengl::MeshGL::free ( )

Referenced by igl::opengl::glfw::Viewer::launch_shut().

+ Here is the caller graph for this function:

◆ free_buffers()

IGL_INLINE void igl::opengl::MeshGL::free_buffers ( )
47{
49 {
50 glDeleteVertexArrays(1, &vao_mesh);
51 glDeleteVertexArrays(1, &vao_overlay_lines);
52 glDeleteVertexArrays(1, &vao_overlay_points);
53
54 glDeleteBuffers(1, &vbo_V);
55 glDeleteBuffers(1, &vbo_V_normals);
56 glDeleteBuffers(1, &vbo_V_ambient);
57 glDeleteBuffers(1, &vbo_V_diffuse);
58 glDeleteBuffers(1, &vbo_V_specular);
59 glDeleteBuffers(1, &vbo_V_uv);
60 glDeleteBuffers(1, &vbo_F);
61 glDeleteBuffers(1, &vbo_lines_F);
62 glDeleteBuffers(1, &vbo_lines_V);
63 glDeleteBuffers(1, &vbo_lines_V_colors);
64 glDeleteBuffers(1, &vbo_points_F);
65 glDeleteBuffers(1, &vbo_points_V);
66 glDeleteBuffers(1, &vbo_points_V_colors);
67
68 glDeleteTextures(1, &vbo_tex);
69 }
70}
bool is_initialized
Definition MeshGL.h:45

◆ init()

IGL_INLINE void igl::opengl::MeshGL::init ( )
161{
163 {
164 return;
165 }
166 is_initialized = true;
167 std::string mesh_vertex_shader_string =
168R"(#version 150
169 uniform mat4 view;
170 uniform mat4 proj;
171 uniform mat4 normal_matrix;
172 in vec3 position;
173 in vec3 normal;
174 out vec3 position_eye;
175 out vec3 normal_eye;
176 in vec4 Ka;
177 in vec4 Kd;
178 in vec4 Ks;
179 in vec2 texcoord;
180 out vec2 texcoordi;
181 out vec4 Kai;
182 out vec4 Kdi;
183 out vec4 Ksi;
184
185 void main()
186 {
187 position_eye = vec3 (view * vec4 (position, 1.0));
188 normal_eye = vec3 (normal_matrix * vec4 (normal, 0.0));
189 normal_eye = normalize(normal_eye);
190 gl_Position = proj * vec4 (position_eye, 1.0); //proj * view * vec4(position, 1.0);"
191 Kai = Ka;
192 Kdi = Kd;
193 Ksi = Ks;
194 texcoordi = texcoord;
195 }
196)";
197
198 std::string mesh_fragment_shader_string =

Referenced by igl::opengl::ViewerData::updateGL().

+ Here is the caller graph for this function:

◆ init_buffers()

IGL_INLINE void igl::opengl::MeshGL::init_buffers ( )
16{
17 // Mesh: Vertex Array Object & Buffer objects
18 glGenVertexArrays(1, &vao_mesh);
19 glBindVertexArray(vao_mesh);
20 glGenBuffers(1, &vbo_V);
21 glGenBuffers(1, &vbo_V_normals);
22 glGenBuffers(1, &vbo_V_ambient);
23 glGenBuffers(1, &vbo_V_diffuse);
24 glGenBuffers(1, &vbo_V_specular);
25 glGenBuffers(1, &vbo_V_uv);
26 glGenBuffers(1, &vbo_F);
27 glGenTextures(1, &vbo_tex);
28
29 // Line overlay
30 glGenVertexArrays(1, &vao_overlay_lines);
31 glBindVertexArray(vao_overlay_lines);
32 glGenBuffers(1, &vbo_lines_F);
33 glGenBuffers(1, &vbo_lines_V);
34 glGenBuffers(1, &vbo_lines_V_colors);
35
36 // Point overlay
37 glGenVertexArrays(1, &vao_overlay_points);
38 glBindVertexArray(vao_overlay_points);
39 glGenBuffers(1, &vbo_points_F);
40 glGenBuffers(1, &vbo_points_V);
41 glGenBuffers(1, &vbo_points_V_colors);
42
44}

References dirty, DIRTY_ALL, vao_mesh, vao_overlay_lines, vao_overlay_points, vbo_F, vbo_lines_F, vbo_lines_V, vbo_lines_V_colors, vbo_points_F, vbo_points_V, vbo_points_V_colors, vbo_tex, vbo_V, vbo_V_ambient, vbo_V_diffuse, vbo_V_normals, vbo_V_specular, and vbo_V_uv.

Member Data Documentation

◆ dirty

uint32_t igl::opengl::MeshGL::dirty

◆ F_vbo

Eigen::Matrix<unsigned, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> igl::opengl::MeshGL::F_vbo

◆ is_initialized

bool igl::opengl::MeshGL::is_initialized = false

◆ lines_F_vbo

Eigen::Matrix<unsigned, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> igl::opengl::MeshGL::lines_F_vbo

◆ lines_V_colors_vbo

RowMatrixXf igl::opengl::MeshGL::lines_V_colors_vbo

◆ lines_V_vbo

RowMatrixXf igl::opengl::MeshGL::lines_V_vbo

◆ points_F_vbo

Eigen::Matrix<unsigned, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> igl::opengl::MeshGL::points_F_vbo

◆ points_V_colors_vbo

RowMatrixXf igl::opengl::MeshGL::points_V_colors_vbo

◆ points_V_vbo

RowMatrixXf igl::opengl::MeshGL::points_V_vbo

◆ shader_mesh

GLuint igl::opengl::MeshGL::shader_mesh

◆ shader_overlay_lines

GLuint igl::opengl::MeshGL::shader_overlay_lines

◆ shader_overlay_points

GLuint igl::opengl::MeshGL::shader_overlay_points

◆ tex

Eigen::Matrix<char,Eigen::Dynamic,1> igl::opengl::MeshGL::tex

◆ tex_u

int igl::opengl::MeshGL::tex_u

◆ tex_v

int igl::opengl::MeshGL::tex_v

◆ V_ambient_vbo

RowMatrixXf igl::opengl::MeshGL::V_ambient_vbo

◆ V_diffuse_vbo

RowMatrixXf igl::opengl::MeshGL::V_diffuse_vbo

◆ V_normals_vbo

RowMatrixXf igl::opengl::MeshGL::V_normals_vbo

◆ V_specular_vbo

RowMatrixXf igl::opengl::MeshGL::V_specular_vbo

◆ V_uv_vbo

RowMatrixXf igl::opengl::MeshGL::V_uv_vbo

◆ V_vbo

RowMatrixXf igl::opengl::MeshGL::V_vbo

◆ vao_mesh

GLuint igl::opengl::MeshGL::vao_mesh

Referenced by init_buffers().

◆ vao_overlay_lines

GLuint igl::opengl::MeshGL::vao_overlay_lines

Referenced by init_buffers().

◆ vao_overlay_points

GLuint igl::opengl::MeshGL::vao_overlay_points

Referenced by init_buffers().

◆ vbo_F

GLuint igl::opengl::MeshGL::vbo_F

Referenced by init_buffers().

◆ vbo_lines_F

GLuint igl::opengl::MeshGL::vbo_lines_F

Referenced by init_buffers().

◆ vbo_lines_V

GLuint igl::opengl::MeshGL::vbo_lines_V

Referenced by init_buffers().

◆ vbo_lines_V_colors

GLuint igl::opengl::MeshGL::vbo_lines_V_colors

Referenced by init_buffers().

◆ vbo_points_F

GLuint igl::opengl::MeshGL::vbo_points_F

Referenced by init_buffers().

◆ vbo_points_V

GLuint igl::opengl::MeshGL::vbo_points_V

Referenced by init_buffers().

◆ vbo_points_V_colors

GLuint igl::opengl::MeshGL::vbo_points_V_colors

Referenced by init_buffers().

◆ vbo_tex

GLuint igl::opengl::MeshGL::vbo_tex

Referenced by init_buffers().

◆ vbo_V

GLuint igl::opengl::MeshGL::vbo_V

Referenced by init_buffers().

◆ vbo_V_ambient

GLuint igl::opengl::MeshGL::vbo_V_ambient

Referenced by init_buffers().

◆ vbo_V_diffuse

GLuint igl::opengl::MeshGL::vbo_V_diffuse

Referenced by init_buffers().

◆ vbo_V_normals

GLuint igl::opengl::MeshGL::vbo_V_normals

Referenced by init_buffers().

◆ vbo_V_specular

GLuint igl::opengl::MeshGL::vbo_V_specular

Referenced by init_buffers().

◆ vbo_V_uv

GLuint igl::opengl::MeshGL::vbo_V_uv

Referenced by init_buffers().


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