Merge branch 'et_opengl_3' of https://github.com/prusa3d/PrusaSlicer into et_opengl_es

This commit is contained in:
enricoturri1966 2022-03-30 15:23:23 +02:00
commit 2e6d9dc4dd
7 changed files with 78 additions and 14 deletions

View File

@ -37,6 +37,8 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (WIN32)
set(_boost_toolset "clang-win")
elseif (APPLE)
set(_boost_toolset "clang")
else()
set(_boost_toolset "clang")
endif()
@ -103,11 +105,16 @@ if (NOT _boost_variants)
set(_boost_variants release)
endif()
set(_boost_layout system)
if (MSVC)
set(_boost_layout versioned)
endif ()
set(_build_cmd ${_build_cmd}
${_boost_flags}
-j${NPROC}
${_libs}
--layout=versioned
--layout=${_boost_layout}
--debug-configuration
toolset=${_boost_toolset}
address-model=${_bits}

View File

@ -363,7 +363,7 @@ namespace Slic3r {
// All G1 commands should be translated and rotated. X and Y coords are
// only pushed to the output when they differ from last time.
// WT generator can override this by appending the never_skip_tag
if (line.find("G1 ") == 0) {
if (boost::starts_with(line, "G1 ")) {
bool never_skip = false;
auto it = line.find(WipeTower::never_skip_tag());
if (it != std::string::npos) {
@ -375,6 +375,7 @@ namespace Slic3r {
std::istringstream line_str(line);
line_str >> std::noskipws; // don't skip whitespace
char ch = 0;
line_str >> ch >> ch; // read the "G1"
while (line_str >> ch) {
if (ch == 'X' || ch == 'Y')
line_str >> (ch == 'X' ? pos.x() : pos.y());
@ -386,14 +387,16 @@ namespace Slic3r {
if (transformed_pos != old_pos || never_skip) {
line = line_out.str();
boost::trim_left(line); // Remove leading spaces
std::ostringstream oss;
oss << std::fixed << std::setprecision(3) << "G1";
if (transformed_pos.x() != old_pos.x() || never_skip)
oss << " X" << transformed_pos.x() - extruder_offset.x();
if (transformed_pos.y() != old_pos.y() || never_skip)
oss << " Y" << transformed_pos.y() - extruder_offset.y();
if (! line.empty())
oss << " ";
line.replace(line.find("G1 "), 3, oss.str());
line = oss.str() + line;
old_pos = transformed_pos;
}
}
@ -444,7 +447,7 @@ namespace Slic3r {
bool ignore_sparse = false;
if (gcodegen.config().wipe_tower_no_sparse_layers.value) {
wipe_tower_z = m_last_wipe_tower_print_z;
ignore_sparse = (m_tool_changes[m_layer_idx].size() == 1 && m_tool_changes[m_layer_idx].front().initial_tool == m_tool_changes[m_layer_idx].front().new_tool);
ignore_sparse = (m_tool_changes[m_layer_idx].size() == 1 && m_tool_changes[m_layer_idx].front().initial_tool == m_tool_changes[m_layer_idx].front().new_tool && m_layer_idx != 0);
if (m_tool_change_idx == 0 && !ignore_sparse)
wipe_tower_z = m_last_wipe_tower_print_z + m_tool_changes[m_layer_idx].front().layer_height;
}

View File

@ -1180,7 +1180,7 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
// Ask our writer about how much material was consumed.
// Skip this in case the layer is sparse and config option to not print sparse layers is enabled.
if (! m_no_sparse_layers || toolchanges_on_layer)
if (! m_no_sparse_layers || toolchanges_on_layer || first_layer)
if (m_current_tool < m_used_filament_length.size())
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
@ -1196,7 +1196,7 @@ void WipeTower::plan_toolchange(float z_par, float layer_height_par, unsigned in
if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan first
m_plan.push_back(WipeTowerInfo(z_par, layer_height_par));
if (m_first_layer_idx == size_t(-1) && (! m_no_sparse_layers || old_tool != new_tool))
if (m_first_layer_idx == size_t(-1) && (! m_no_sparse_layers || old_tool != new_tool || m_plan.size() == 1))
m_first_layer_idx = m_plan.size() - 1;
if (old_tool == new_tool) // new layer without toolchanges - we are done

View File

@ -55,7 +55,7 @@
#define ENABLE_WIPETOWER_OBJECTID_1000_REMOVAL (1 && ENABLE_2_5_0_ALPHA1)
// Enable removal of legacy OpenGL calls
#define ENABLE_LEGACY_OPENGL_REMOVAL (1 && ENABLE_2_5_0_ALPHA1)
// Enable OpenGL core profile context
// Enable OpenGL core profile context (tested against Mesa 20.1.8 on Windows)
#define ENABLE_GL_CORE_PROFILE (1 && ENABLE_LEGACY_OPENGL_REMOVAL)
// Shows an imgui dialog with GLModel statistics data
#define ENABLE_GLMODEL_STATISTICS (0 && ENABLE_LEGACY_OPENGL_REMOVAL)

View File

@ -123,8 +123,14 @@ void GLCanvas3D::LayersEditing::init()
{
glsafe(::glGenTextures(1, (GLuint*)&m_z_texture_id));
glsafe(::glBindTexture(GL_TEXTURE_2D, m_z_texture_id));
#if _WIN32 && ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile() || !OpenGLManager::get_gl_info().is_mesa()) {
#endif // _WIN32 && ENABLE_GL_CORE_PROFILE
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP));
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP));
#if _WIN32 && ENABLE_GL_CORE_PROFILE
}
#endif // _WIN32 && ENABLE_GL_CORE_PROFILE
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST));
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1));

View File

@ -30,6 +30,7 @@ namespace GUI {
std::string gl_get_string_safe(GLenum param, const std::string& default_value)
{
const char* value = (const char*)::glGetString(param);
glcheck();
return std::string((value != nullptr) ? value : default_value);
}
@ -65,6 +66,20 @@ const std::string& OpenGLManager::GLInfo::get_renderer() const
return m_renderer;
}
#if ENABLE_GL_CORE_PROFILE
bool OpenGLManager::GLInfo::is_core_profile() const
{
return !GLEW_ARB_compatibility;
}
#if _WIN32
bool OpenGLManager::GLInfo::is_mesa() const
{
return boost::icontains(m_version, "mesa");
}
#endif // _WIN32
#endif // ENABLE_OPENGL_ES
int OpenGLManager::GLInfo::get_max_tex_size() const
{
if (!m_detected)
@ -176,7 +191,7 @@ std::string OpenGLManager::GLInfo::to_string(bool for_github) const
out << h2_start << "OpenGL installation" << h2_end << line_end;
out << b_start << "GL version: " << b_end << m_version << line_end;
#if ENABLE_GL_CORE_PROFILE
out << b_start << "Profile: " << b_end << (GLEW_ARB_compatibility ? "Compatibility" : "Core") << line_end;
out << b_start << "Profile: " << b_end << (is_core_profile() ? "Core" : "Compatibility") << line_end;
#endif // ENABLE_GL_CORE_PROFILE
out << b_start << "Vendor: " << b_end << m_vendor << line_end;
out << b_start << "Renderer: " << b_end << m_renderer << line_end;
@ -184,8 +199,25 @@ std::string OpenGLManager::GLInfo::to_string(bool for_github) const
{
std::vector<std::string> extensions_list;
std::string extensions_str = gl_get_string_safe(GL_EXTENSIONS, "");
#if ENABLE_GL_CORE_PROFILE
std::string extensions_str;
if (is_core_profile()) {
GLint n = 0;
glsafe(::glGetIntegerv(GL_NUM_EXTENSIONS, &n));
for (GLint i = 0; i < n; ++i) {
const char* extension = (const char*)::glGetStringi(GL_EXTENSIONS, i);
glcheck();
if (extension != nullptr)
extensions_list.emplace_back(extension);
}
}
else {
extensions_str = gl_get_string_safe(GL_EXTENSIONS, "");
boost::split(extensions_list, extensions_str, boost::is_any_of(" "), boost::token_compress_on);
}
#else
const std::string extensions_str = gl_get_string_safe(GL_EXTENSIONS, "");
#endif // ENABLE_GL_CORE_PROFILE
if (!extensions_list.empty()) {
if (for_github)
@ -272,12 +304,21 @@ bool OpenGLManager::init_gl()
else
s_framebuffers_type = EFramebufferType::Unknown;
#if ENABLE_GL_CORE_PROFILE
bool valid_version = s_gl_info.is_core_profile() ? s_gl_info.is_version_greater_or_equal_to(3, 3) : s_gl_info.is_version_greater_or_equal_to(2, 0);
#else
bool valid_version = s_gl_info.is_version_greater_or_equal_to(2, 0);
#endif // ENABLE_GL_CORE_PROFILE
if (!valid_version) {
// Complain about the OpenGL version.
wxString message = from_u8((boost::format(
#if ENABLE_GL_CORE_PROFILE
_utf8(L("PrusaSlicer requires OpenGL %s capable graphics driver to run correctly, \n"
"while OpenGL version %s, render %s, vendor %s was detected."))) % (s_gl_info.is_core_profile() ? "3.3" : "2.0") % s_gl_info.get_version() % s_gl_info.get_renderer() % s_gl_info.get_vendor()).str());
#else
_utf8(L("PrusaSlicer requires OpenGL 2.0 capable graphics driver to run correctly, \n"
"while OpenGL version %s, render %s, vendor %s was detected."))) % s_gl_info.get_version() % s_gl_info.get_renderer() % s_gl_info.get_vendor()).str());
#endif // ENABLE_GL_CORE_PROFILE
message += "\n";
message += _L("You may need to update your graphics card driver.");
#ifdef _WIN32

View File

@ -43,6 +43,13 @@ public:
const std::string& get_vendor() const;
const std::string& get_renderer() const;
#if ENABLE_GL_CORE_PROFILE
bool is_core_profile() const;
#if _WIN32
bool is_mesa() const;
#endif // _WIN32
#endif // ENABLE_OPENGL_ES
int get_max_tex_size() const;
float get_max_anisotropy() const;