Tech ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - Use vertex attributes and matrices in shaders.

Shader: flat - Gizmo Move
This commit is contained in:
enricoturri1966 2022-03-01 09:56:00 +01:00
parent d766627099
commit 3b53ba7865

View File

@ -2,6 +2,9 @@
#include "GLGizmoMove.hpp" #include "GLGizmoMove.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp" #include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/GUI_App.hpp"
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
#include "slic3r/GUI/Plater.hpp"
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
#include <GL/glew.h> #include <GL/glew.h>
@ -151,11 +154,20 @@ void GLGizmoMove3D::on_render()
if (m_hover_id == -1) { if (m_hover_id == -1) {
#if ENABLE_GLBEGIN_GLEND_REMOVAL #if ENABLE_GLBEGIN_GLEND_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL #endif // ENABLE_GLBEGIN_GLEND_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
const Transform3d matrix = wxGetApp().plater()->get_camera().get_projection_view_matrix();
shader->set_uniform("projection_view_model_matrix", matrix);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
// draw axes // draw axes
for (unsigned int i = 0; i < 3; ++i) { for (unsigned int i = 0; i < 3; ++i) {
#if ENABLE_GLBEGIN_GLEND_REMOVAL #if ENABLE_GLBEGIN_GLEND_REMOVAL
@ -186,9 +198,19 @@ void GLGizmoMove3D::on_render()
else { else {
// draw axis // draw axis
#if ENABLE_GLBEGIN_GLEND_REMOVAL #if ENABLE_GLBEGIN_GLEND_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
const Transform3d matrix = wxGetApp().plater()->get_camera().get_projection_view_matrix();
shader->set_uniform("projection_view_model_matrix", matrix);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
render_grabber_connection(m_hover_id); render_grabber_connection(m_hover_id);
shader->stop_using(); shader->stop_using();
} }
@ -207,7 +229,7 @@ void GLGizmoMove3D::on_render()
shader->start_using(); shader->start_using();
shader->set_uniform("emission_factor", 0.1f); shader->set_uniform("emission_factor", 0.1f);
// draw grabber // draw grabber
float mean_size = (float)((box.size().x() + box.size().y() + box.size().z()) / 3.0); const float mean_size = (float)((box.size().x() + box.size().y() + box.size().z()) / 3.0);
m_grabbers[m_hover_id].render(true, mean_size); m_grabbers[m_hover_id].render(true, mean_size);
shader->stop_using(); shader->stop_using();
} }