Tech ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - Use vertex attributes and matrices in shaders.
Shader: background
This commit is contained in:
parent
191222c3a8
commit
b84b6af32a
3 changed files with 25 additions and 3 deletions
12
resources/shaders/background_attr.vs
Normal file
12
resources/shaders/background_attr.vs
Normal file
|
@ -0,0 +1,12 @@
|
|||
#version 110
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec2 v_tex_coord;
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coord = v_tex_coord;
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
|
@ -5352,11 +5352,13 @@ void GLCanvas3D::_render_background()
|
|||
use_error_color &= m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed();
|
||||
}
|
||||
|
||||
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glLoadIdentity());
|
||||
glsafe(::glMatrixMode(GL_PROJECTION));
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glLoadIdentity());
|
||||
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
|
||||
// Draws a bottom to top gradient over the complete screen.
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
@ -5385,12 +5387,15 @@ void GLCanvas3D::_render_background()
|
|||
m_background.init_from(std::move(init_data));
|
||||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("background_attr");
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("background");
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
shader->set_uniform("top_color", use_error_color ? ERROR_BG_LIGHT_COLOR : DEFAULT_BG_LIGHT_COLOR);
|
||||
shader->set_uniform("bottom_color", bottom_color);
|
||||
|
||||
m_background.render();
|
||||
shader->stop_using();
|
||||
}
|
||||
|
@ -5408,9 +5413,11 @@ void GLCanvas3D::_render_background()
|
|||
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
glsafe(::glMatrixMode(GL_MODELVIEW));
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
|
|
|
@ -35,13 +35,16 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||
|
||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
// basic shader, used to render all what was previously rendered using the immediate mode
|
||||
valid &= append_shader("flat", { "flat.vs", "flat.fs" });
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
valid &= append_shader("flat_attr", { "flat_attr.vs", "flat.fs" });
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
valid &= append_shader("flat", { "flat.vs", "flat.fs" });
|
||||
// basic shader for textures, used to render textures
|
||||
valid &= append_shader("flat_texture", { "flat_texture.vs", "flat_texture.fs" });
|
||||
// used to render 3D scene background
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
valid &= append_shader("background_attr", { "background_attr.vs", "background.fs" });
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
valid &= append_shader("background", { "background.vs", "background.fs" });
|
||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||
#if ENABLE_SHOW_TOOLPATHS_COG
|
||||
|
@ -57,10 +60,10 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||
valid &= append_shader("printbed", { "printbed.vs", "printbed.fs" });
|
||||
// used to render options in gcode preview
|
||||
if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 3)) {
|
||||
valid &= append_shader("gouraud_light_instanced", { "gouraud_light_instanced.vs", "gouraud_light_instanced.fs" });
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
valid &= append_shader("gouraud_light_instanced_attr", { "gouraud_light_instanced_attr.vs", "gouraud_light_instanced.fs" });
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
valid &= append_shader("gouraud_light_instanced", { "gouraud_light_instanced.vs", "gouraud_light_instanced.fs" });
|
||||
}
|
||||
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
// used to render extrusion and travel paths as lines in gcode preview
|
||||
|
|
Loading…
Reference in a new issue