Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2019-02-27 17:19:03 +0300
committerEnrico Turri <enricoturri@seznam.cz>2019-02-27 17:19:03 +0300
commit68805fc63a07c709f0ce59c7fac0c3cecefa2ed7 (patch)
tree9a097a283769896421cf95c83951bfadcea648ec /src/slic3r/GUI/3DBed.cpp
parent6e9c030f173c9efa72ec07287ff9489e18328df5 (diff)
Small refactoring in Bed3D and GLShader
Diffstat (limited to 'src/slic3r/GUI/3DBed.cpp')
-rw-r--r--src/slic3r/GUI/3DBed.cpp79
1 files changed, 37 insertions, 42 deletions
diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp
index b67bf9eaf..f271f9738 100644
--- a/src/slic3r/GUI/3DBed.cpp
+++ b/src/slic3r/GUI/3DBed.cpp
@@ -516,9 +516,9 @@ void Bed3D::render_prusa(const std::string &key, bool bottom) const
if (max_anisotropy > 0.0f)
{
- ::glBindTexture(GL_TEXTURE_2D, m_texture.get_id());
- ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy);
- ::glBindTexture(GL_TEXTURE_2D, 0);
+ glsafe(::glBindTexture(GL_TEXTURE_2D, m_texture.get_id()));
+ glsafe(::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy));
+ glsafe(::glBindTexture(GL_TEXTURE_2D, 0));
}
}
@@ -542,9 +542,9 @@ void Bed3D::render_prusa(const std::string &key, bool bottom) const
if (!m_model.get_filename().empty())
{
- ::glEnable(GL_LIGHTING);
+ glsafe(::glEnable(GL_LIGHTING));
m_model.render();
- ::glDisable(GL_LIGHTING);
+ glsafe(::glDisable(GL_LIGHTING));
}
}
@@ -553,41 +553,40 @@ void Bed3D::render_prusa(const std::string &key, bool bottom) const
{
if (m_vbo_id == 0)
{
- ::glGenBuffers(1, &m_vbo_id);
- ::glBindBuffer(GL_ARRAY_BUFFER, m_vbo_id);
- ::glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)m_triangles.get_vertices_data_size(), (const GLvoid*)m_triangles.get_vertices_data(), GL_STATIC_DRAW);
-//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-// ::glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, m_triangles.get_vertex_data_size(), (GLvoid*)m_triangles.get_position_offset());
-// ::glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, m_triangles.get_vertex_data_size(), (GLvoid*)m_triangles.get_tex_coords_offset());
-//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- ::glBindBuffer(GL_ARRAY_BUFFER, 0);
+ unsigned int stride = m_triangles.get_vertex_data_size();
+ glsafe(::glGenBuffers(1, &m_vbo_id));
+ glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_vbo_id));
+ glsafe(::glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)m_triangles.get_vertices_data_size(), (const GLvoid*)m_triangles.get_vertices_data(), GL_STATIC_DRAW));
+ glsafe(::glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)m_triangles.get_position_offset()));
+ glsafe(::glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*)m_triangles.get_tex_coords_offset()));
+ glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
}
- ::glEnable(GL_DEPTH_TEST);
- ::glDepthMask(GL_FALSE);
+ glsafe(::glEnable(GL_DEPTH_TEST));
+ glsafe(::glDepthMask(GL_FALSE));
- ::glEnable(GL_BLEND);
- ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glsafe(::glEnable(GL_BLEND));
+ glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
- ::glEnable(GL_TEXTURE_2D);
- ::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+// glsafe(::glEnable(GL_TEXTURE_2D));
+// glsafe(::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE));
if (bottom)
- ::glFrontFace(GL_CW);
+ glsafe(::glFrontFace(GL_CW));
- render_prusa_shader(triangles_vcount, bottom);
+ render_prusa_shader(bottom);
if (bottom)
- ::glFrontFace(GL_CCW);
+ glsafe(::glFrontFace(GL_CCW));
- ::glDisable(GL_TEXTURE_2D);
+// glsafe(::glDisable(GL_TEXTURE_2D));
- ::glDisable(GL_BLEND);
- ::glDepthMask(GL_TRUE);
+ glsafe(::glDisable(GL_BLEND));
+ glsafe(::glDepthMask(GL_TRUE));
}
}
-void Bed3D::render_prusa_shader(unsigned int vertices_count, bool transparent) const
+void Bed3D::render_prusa_shader(bool transparent) const
{
if (m_shader.get_shader_program_id() == 0)
m_shader.init("printbed.vs", "printbed.fs");
@@ -597,19 +596,15 @@ void Bed3D::render_prusa_shader(unsigned int vertices_count, bool transparent) c
m_shader.start_using();
m_shader.set_uniform("transparent_background", transparent);
- ::glBindTexture(GL_TEXTURE_2D, (GLuint)m_texture.get_id());
- ::glBindBuffer(GL_ARRAY_BUFFER, m_vbo_id);
-//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- ::glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, m_triangles.get_vertex_data_size(), (GLvoid*)m_triangles.get_position_offset());
- ::glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, m_triangles.get_vertex_data_size(), (GLvoid*)m_triangles.get_tex_coords_offset());
-//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- ::glEnableVertexAttribArray(0);
- ::glEnableVertexAttribArray(1);
- ::glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices_count);
- ::glDisableVertexAttribArray(1);
- ::glDisableVertexAttribArray(0);
- ::glBindBuffer(GL_ARRAY_BUFFER, 0);
- ::glBindTexture(GL_TEXTURE_2D, 0);
+ glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)m_texture.get_id()));
+ glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_vbo_id));
+ glsafe(::glEnableVertexAttribArray(0));
+ glsafe(::glEnableVertexAttribArray(1));
+ glsafe(::glDrawArrays(GL_TRIANGLES, 0, (GLsizei)m_triangles.get_vertices_count()));
+ glsafe(::glDisableVertexAttribArray(1));
+ glsafe(::glDisableVertexAttribArray(0));
+ glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
+ glsafe(::glBindTexture(GL_TEXTURE_2D, 0));
m_shader.stop_using();
}
@@ -760,7 +755,7 @@ void Bed3D::render_custom() const
glsafe(::glColor4f(0.35f, 0.35f, 0.35f, 0.4f));
glsafe(::glNormal3d(0.0f, 0.0f, 1.0f));
#if ENABLE_TEXTURES_FROM_SVG
- ::glVertexPointer(3, GL_FLOAT, m_triangles.get_vertex_data_size(), (GLvoid*)m_triangles.get_vertices_data());
+ glsafe(::glVertexPointer(3, GL_FLOAT, m_triangles.get_vertex_data_size(), (GLvoid*)m_triangles.get_vertices_data()));
#else
glsafe(::glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)m_triangles.get_vertices()));
#endif // ENABLE_TEXTURES_FROM_SVG
@@ -774,7 +769,7 @@ void Bed3D::render_custom() const
glsafe(::glLineWidth(3.0f * m_scale_factor));
glsafe(::glColor4f(0.2f, 0.2f, 0.2f, 0.4f));
#if ENABLE_TEXTURES_FROM_SVG
- ::glVertexPointer(3, GL_FLOAT, m_triangles.get_vertex_data_size(), (GLvoid*)m_gridlines.get_vertices_data());
+ glsafe(::glVertexPointer(3, GL_FLOAT, m_triangles.get_vertex_data_size(), (GLvoid*)m_gridlines.get_vertices_data()));
#else
glsafe(::glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)m_gridlines.get_vertices()));
#endif // ENABLE_TEXTURES_FROM_SVG
@@ -792,7 +787,7 @@ void Bed3D::reset()
{
if (m_vbo_id > 0)
{
- ::glDeleteBuffers(1, &m_vbo_id);
+ glsafe(::glDeleteBuffers(1, &m_vbo_id));
m_vbo_id = 0;
}
}