mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -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
|
@ -1,10 +1,8 @@
|
|||
#include <GL/glew.h>
|
||||
|
||||
#include "3DScene.hpp"
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
#include "GLShader.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
|
||||
#include "libslic3r/ExtrusionEntity.hpp"
|
||||
#include "libslic3r/ExtrusionEntityCollection.hpp"
|
||||
|
@ -644,11 +642,9 @@ GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCo
|
|||
|
||||
void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func) const
|
||||
{
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
|
||||
glsafe(::glEnable(GL_BLEND));
|
||||
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||
|
@ -660,7 +656,6 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
shader->set_uniform("print_box.min", m_print_box_min, 3);
|
||||
shader->set_uniform("print_box.max", m_print_box_max, 3);
|
||||
shader->set_uniform("z_range", m_z_range, 2);
|
||||
|
@ -668,74 +663,16 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||
#if ENABLE_SLOPE_RENDERING
|
||||
shader->set_uniform("slope.z_range", m_slope.z_range);
|
||||
#endif // ENABLE_SLOPE_RENDERING
|
||||
#else
|
||||
GLint current_program_id;
|
||||
glsafe(::glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_program_id));
|
||||
GLint color_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "uniform_color") : -1;
|
||||
GLint z_range_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "z_range") : -1;
|
||||
GLint clipping_plane_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "clipping_plane") : -1;
|
||||
|
||||
GLint print_box_min_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.min") : -1;
|
||||
GLint print_box_max_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.max") : -1;
|
||||
GLint print_box_active_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.actived") : -1;
|
||||
GLint print_box_worldmatrix_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.volume_world_matrix") : -1;
|
||||
|
||||
#if ENABLE_SLOPE_RENDERING
|
||||
GLint slope_active_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "slope.actived") : -1;
|
||||
GLint slope_normal_matrix_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "slope.volume_world_normal_matrix") : -1;
|
||||
GLint slope_z_range_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "slope.z_range") : -1;
|
||||
#endif // ENABLE_SLOPE_RENDERING
|
||||
glcheck();
|
||||
|
||||
if (print_box_min_id != -1)
|
||||
glsafe(::glUniform3fv(print_box_min_id, 1, (const GLfloat*)m_print_box_min));
|
||||
|
||||
if (print_box_max_id != -1)
|
||||
glsafe(::glUniform3fv(print_box_max_id, 1, (const GLfloat*)m_print_box_max));
|
||||
|
||||
if (z_range_id != -1)
|
||||
glsafe(::glUniform2fv(z_range_id, 1, (const GLfloat*)m_z_range));
|
||||
|
||||
if (clipping_plane_id != -1)
|
||||
glsafe(::glUniform4fv(clipping_plane_id, 1, (const GLfloat*)m_clipping_plane));
|
||||
|
||||
#if ENABLE_SLOPE_RENDERING
|
||||
if (slope_z_range_id != -1)
|
||||
glsafe(::glUniform2fv(slope_z_range_id, 1, (const GLfloat*)m_slope.z_range.data()));
|
||||
#endif // ENABLE_SLOPE_RENDERING
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
|
||||
GLVolumeWithIdAndZList to_render = volumes_to_render(this->volumes, type, view_matrix, filter_func);
|
||||
for (GLVolumeWithIdAndZ& volume : to_render) {
|
||||
volume.first->set_render_color();
|
||||
#if ENABLE_SLOPE_RENDERING
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
shader->set_uniform("uniform_color", volume.first->render_color, 4);
|
||||
shader->set_uniform("print_box.actived", volume.first->shader_outside_printer_detection_enabled);
|
||||
shader->set_uniform("print_box.volume_world_matrix", volume.first->world_matrix());
|
||||
shader->set_uniform("slope.actived", m_slope.active && !volume.first->is_modifier && !volume.first->is_wipe_tower);
|
||||
shader->set_uniform("slope.volume_world_normal_matrix", volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast<float>());
|
||||
#else
|
||||
if (color_id >= 0)
|
||||
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)volume.first->render_color));
|
||||
else
|
||||
glsafe(::glColor4fv(volume.first->render_color));
|
||||
|
||||
if (print_box_active_id != -1)
|
||||
glsafe(::glUniform1i(print_box_active_id, volume.first->shader_outside_printer_detection_enabled ? 1 : 0));
|
||||
|
||||
if (print_box_worldmatrix_id != -1)
|
||||
glsafe(::glUniformMatrix4fv(print_box_worldmatrix_id, 1, GL_FALSE, (const GLfloat*)volume.first->world_matrix().cast<float>().data()));
|
||||
|
||||
if (slope_active_id != -1)
|
||||
glsafe(::glUniform1i(slope_active_id, m_slope.active && !volume.first->is_modifier && !volume.first->is_wipe_tower ? 1 : 0));
|
||||
|
||||
if (slope_normal_matrix_id != -1)
|
||||
{
|
||||
Matrix3f normal_matrix = volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast<float>();
|
||||
glsafe(::glUniformMatrix3fv(slope_normal_matrix_id, 1, GL_FALSE, (const GLfloat*)normal_matrix.data()));
|
||||
}
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
|
||||
volume.first->render();
|
||||
#else
|
||||
|
@ -1940,11 +1877,9 @@ void GLModel::reset()
|
|||
|
||||
void GLModel::render() const
|
||||
{
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
|
||||
glsafe(::glEnable(GL_BLEND));
|
||||
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||
|
@ -1953,23 +1888,8 @@ void GLModel::render() const
|
|||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
|
||||
#if !ENABLE_SHADERS_MANAGER
|
||||
GLint current_program_id;
|
||||
glsafe(::glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_program_id));
|
||||
GLint color_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "uniform_color") : -1;
|
||||
glcheck();
|
||||
#endif // !ENABLE_SHADERS_MANAGER
|
||||
|
||||
#if ENABLE_SLOPE_RENDERING
|
||||
#if ENABLE_SHADERS_MANAGER
|
||||
shader->set_uniform("uniform_color", m_volume.render_color, 4);
|
||||
#else
|
||||
if (color_id >= 0)
|
||||
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)m_volume.render_color));
|
||||
else
|
||||
glsafe(::glColor4fv(m_volume.render_color));
|
||||
#endif // ENABLE_SHADERS_MANAGER
|
||||
|
||||
m_volume.render();
|
||||
#else
|
||||
m_volume.render(color_id, -1, -1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue