ENH: shader: add logic to avoid error when opengl version less than 3.0

use a seperate shader for function which needs opengl 3.0 supports

Change-Id: Iff30a90211aa10ae9c4a1e36afeb331d252fb814
This commit is contained in:
lane.wei 2022-10-16 23:21:10 +08:00 committed by Lane.Wei
parent c9c98dcee8
commit 227e1f4dc3
5 changed files with 218 additions and 38 deletions

View file

@ -45,11 +45,20 @@ std::pair<bool, std::string> GLShadersManager::init()
// used to render extrusion and travel paths as lines in gcode preview
valid &= append_shader("toolpaths_lines", { "toolpaths_lines.vs", "toolpaths_lines.fs" });
// used to render objects in 3d editor
valid &= append_shader("gouraud", { "gouraud.vs", "gouraud.fs" }
if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 0)) {
valid &= append_shader("gouraud", { "gouraud_130.vs", "gouraud_130.fs" }
#if ENABLE_ENVIRONMENT_MAP
, { "ENABLE_ENVIRONMENT_MAP"sv }
#endif // ENABLE_ENVIRONMENT_MAP
);
}
else {
valid &= append_shader("gouraud", { "gouraud.vs", "gouraud.fs" }
#if ENABLE_ENVIRONMENT_MAP
, { "ENABLE_ENVIRONMENT_MAP"sv }
#endif // ENABLE_ENVIRONMENT_MAP
);
}
// used to render variable layers heights in 3d editor
valid &= append_shader("variable_layer_height", { "variable_layer_height.vs", "variable_layer_height.fs" });
// used to render highlight contour around selected triangles inside the multi-material gizmo