mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
ENABLE_SHADERS_MANAGER set as default
This commit is contained in:
parent
4d05ec0856
commit
314995fa0b
18 changed files with 57 additions and 1198 deletions
|
@ -163,14 +163,7 @@ Bed3D::Axes::~Axes()
|
|||
void Bed3D::Axes::render() const
|
||||
{
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
auto render_axis = [this](const Transform3f& transform) {
|
||||
#else
|
||||
auto render_axis = [this](const Transform3f& transform, GLint color_id, const std::array<float, 4>& color) {
|
||||
if (color_id >= 0)
|
||||
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)color.data()));
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glMultMatrixf(transform.data()));
|
||||
m_arrow.render();
|
||||
|
@ -178,21 +171,13 @@ void Bed3D::Axes::render() const
|
|||
};
|
||||
|
||||
m_arrow.init_from(stilized_arrow(16, DefaultTipRadius, DefaultTipLength, DefaultStemRadius, m_stem_length));
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
#else
|
||||
if (!m_shader.init("gouraud_light.vs", "gouraud_light.fs"))
|
||||
BOOST_LOG_TRIVIAL(error) << "Unable to initialize gouraud_light shader: please, check that the files gouraud_light.vs and gouraud_light.fs are available";
|
||||
|
||||
if (!m_shader.is_initialized())
|
||||
return;
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
shader->start_using();
|
||||
|
||||
// x axis
|
||||
|
@ -211,21 +196,6 @@ void Bed3D::Axes::render() const
|
|||
render_axis(Geometry::assemble_transform(m_origin).cast<float>());
|
||||
|
||||
shader->stop_using();
|
||||
#else
|
||||
m_shader.start_using();
|
||||
GLint color_id = ::glGetUniformLocation(m_shader.get_shader_program_id(), "uniform_color");
|
||||
|
||||
// x axis
|
||||
render_axis(Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0f }).cast<float>(), color_id, { 0.75f, 0.0f, 0.0f, 1.0f });
|
||||
|
||||
// y axis
|
||||
render_axis(Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0f }).cast<float>(), color_id, { 0.0f, 0.75f, 0.0f, 1.0f });
|
||||
|
||||
// z axis
|
||||
render_axis(Geometry::assemble_transform(m_origin).cast<float>(), color_id, { 0.0f, 0.0f, 0.75f, 1.0f });
|
||||
|
||||
m_shader.stop_using();
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
#else
|
||||
|
@ -571,23 +541,12 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const
|
|||
|
||||
if (m_triangles.get_vertices_count() > 0)
|
||||
{
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("printbed");
|
||||
if (shader != nullptr)
|
||||
{
|
||||
shader->start_using();
|
||||
shader->set_uniform("transparent_background", bottom);
|
||||
shader->set_uniform("svg_source", boost::algorithm::iends_with(m_texture.get_source(), ".svg"));
|
||||
#else
|
||||
if (m_shader.get_shader_program_id() == 0)
|
||||
m_shader.init("printbed.vs", "printbed.fs");
|
||||
|
||||
if (m_shader.is_initialized())
|
||||
{
|
||||
m_shader.start_using();
|
||||
m_shader.set_uniform("transparent_background", bottom);
|
||||
m_shader.set_uniform("svg_source", boost::algorithm::iends_with(m_texture.get_source(), ".svg"));
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
|
||||
if (m_vbo_id == 0)
|
||||
{
|
||||
|
@ -608,13 +567,8 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const
|
|||
|
||||
unsigned int stride = m_triangles.get_vertex_data_size();
|
||||
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
GLint position_id = shader->get_attrib_location("v_position");
|
||||
GLint tex_coords_id = shader->get_attrib_location("v_tex_coords");
|
||||
#else
|
||||
GLint position_id = m_shader.get_attrib_location("v_position");
|
||||
GLint tex_coords_id = m_shader.get_attrib_location("v_tex_coords");
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
|
||||
// show the temporary texture while no compressed data is available
|
||||
GLuint tex_id = (GLuint)m_temp_texture.get_id();
|
||||
|
@ -652,11 +606,7 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const
|
|||
glsafe(::glDisable(GL_BLEND));
|
||||
glsafe(::glDepthMask(GL_TRUE));
|
||||
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
shader->stop_using();
|
||||
#else
|
||||
m_shader.stop_using();
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -679,7 +629,6 @@ void Bed3D::render_model() const
|
|||
|
||||
if (!m_model.get_filename().empty())
|
||||
{
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
if (shader != nullptr)
|
||||
{
|
||||
|
@ -687,11 +636,6 @@ void Bed3D::render_model() const
|
|||
m_model.render();
|
||||
shader->stop_using();
|
||||
}
|
||||
#else
|
||||
glsafe(::glEnable(GL_LIGHTING));
|
||||
m_model.render();
|
||||
glsafe(::glDisable(GL_LIGHTING));
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue