Refactoring into rendering pipeline

This commit is contained in:
Enrico Turri 2019-07-26 09:45:22 +02:00
parent 9bcdb2ebd0
commit 77857f7292
4 changed files with 11 additions and 30 deletions

View file

@ -266,6 +266,8 @@ void Bed3D::render(GLCanvas3D& canvas, float theta, float scale_factor) const
{
m_scale_factor = scale_factor;
render_axes();
switch (m_type)
{
case MK2:
@ -292,12 +294,6 @@ void Bed3D::render(GLCanvas3D& canvas, float theta, float scale_factor) const
}
}
void Bed3D::render_axes() const
{
if (!m_shape.empty())
m_axes.render();
}
void Bed3D::calc_bounding_boxes() const
{
m_bounding_box = BoundingBoxf3();
@ -393,6 +389,12 @@ Bed3D::EType Bed3D::detect_type(const Pointfs& shape) const
return type;
}
void Bed3D::render_axes() const
{
if (!m_shape.empty())
m_axes.render();
}
void Bed3D::render_prusa(GLCanvas3D& canvas, const std::string& key, bool bottom) const
{
if (!bottom)
@ -598,9 +600,7 @@ void Bed3D::render_default(bool bottom) const
{
bool has_model = !m_model.get_filename().empty();
glsafe(::glEnable(GL_LIGHTING));
glsafe(::glDisable(GL_DEPTH_TEST));
glsafe(::glEnable(GL_DEPTH_TEST));
glsafe(::glEnable(GL_BLEND));
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
@ -615,11 +615,7 @@ void Bed3D::render_default(bool bottom) const
glsafe(::glDrawArrays(GL_TRIANGLES, 0, (GLsizei)triangles_vcount));
}
glsafe(::glDisable(GL_LIGHTING));
// draw grid
// we need depth test for grid, otherwise it would disappear when looking the object from below
glsafe(::glEnable(GL_DEPTH_TEST));
glsafe(::glLineWidth(3.0f * m_scale_factor));
if (has_model && !bottom)
glsafe(::glColor4f(0.75f, 0.75f, 0.75f, 1.0f));

View file

@ -111,13 +111,13 @@ public:
Point point_projection(const Point& point) const;
void render(GLCanvas3D& canvas, float theta, float scale_factor) const;
void render_axes() const;
private:
void calc_bounding_boxes() const;
void calc_triangles(const ExPolygon& poly);
void calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox);
EType detect_type(const Pointfs& shape) const;
void render_axes() const;
void render_prusa(GLCanvas3D& canvas, const std::string& key, bool bottom) const;
void render_texture(const std::string& filename, bool bottom, GLCanvas3D& canvas) const;
void render_model(const std::string& filename) const;

View file

@ -1561,19 +1561,10 @@ void GLCanvas3D::render()
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
_render_background();
// textured bed needs to be rendered after objects if the texture is transparent
bool early_bed_render = m_bed.is_custom() || (theta <= 90.0f);
if (early_bed_render)
_render_bed(theta);
_render_objects();
_render_sla_slices();
_render_selection();
_render_axes();
if (!early_bed_render)
_render_bed(theta);
_render_bed(theta);
#if ENABLE_RENDER_SELECTION_CENTER
_render_selection_center();
@ -3906,11 +3897,6 @@ void GLCanvas3D::_render_bed(float theta) const
m_bed.render(const_cast<GLCanvas3D&>(*this), theta, scale_factor);
}
void GLCanvas3D::_render_axes() const
{
m_bed.render_axes();
}
void GLCanvas3D::_render_objects() const
{
if (m_volumes.empty())

View file

@ -662,7 +662,6 @@ private:
void _rectangular_selection_picking_pass() const;
void _render_background() const;
void _render_bed(float theta) const;
void _render_axes() const;
void _render_objects() const;
void _render_selection() const;
#if ENABLE_RENDER_SELECTION_CENTER