Tech ENABLE_GL_CORE_PROFILE set as default

This commit is contained in:
enricoturri1966 2024-03-12 13:41:04 +01:00 committed by Lukas Matena
parent 1112fca688
commit c2b8914ed0
28 changed files with 537 additions and 535 deletions

View File

@ -40,9 +40,9 @@
#include "unix/fhs.hpp" // Generated by CMake from ../platform/unix/fhs.hpp.in #include "unix/fhs.hpp" // Generated by CMake from ../platform/unix/fhs.hpp.in
#include "libslic3r/libslic3r.h" #include "libslic3r/libslic3r.h"
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
#include "libslic3r/Config.hpp" #include "libslic3r/Config.hpp"
#include "libslic3r/Geometry.hpp" #include "libslic3r/Geometry.hpp"
#include "libslic3r/GCode/PostProcessor.hpp" #include "libslic3r/GCode/PostProcessor.hpp"
@ -191,7 +191,17 @@ int CLI::run(int argc, char **argv)
m_actions.erase(it); m_actions.erase(it);
} }
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES #endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
// are we starting as gcodeviewer ?
for (auto it = m_actions.begin(); it != m_actions.end(); ++it) {
if (*it == "gcodeviewer") {
start_gui = true;
start_as_gcodeviewer = true;
m_actions.erase(it);
break;
}
}
#else
std::pair<int, int> opengl_version = { 0, 0 }; std::pair<int, int> opengl_version = { 0, 0 };
bool opengl_debug = false; bool opengl_debug = false;
bool opengl_compatibility_profile = false; bool opengl_compatibility_profile = false;
@ -239,17 +249,7 @@ int CLI::run(int argc, char **argv)
opengl_debug = true; opengl_debug = true;
m_actions.erase(it); m_actions.erase(it);
} }
#else #endif // SLIC3R_OPENGL_ES
// are we starting as gcodeviewer ?
for (auto it = m_actions.begin(); it != m_actions.end(); ++it) {
if (*it == "gcodeviewer") {
start_gui = true;
start_as_gcodeviewer = true;
m_actions.erase(it);
break;
}
}
#endif // ENABLE_GL_CORE_PROFILE
#else // SLIC3R_GUI #else // SLIC3R_GUI
// If there is no GUI, we shall ignore the parameters. Remove them from the list. // If there is no GUI, we shall ignore the parameters. Remove them from the list.
#if ENABLE_OPENGL_AUTO_AA_SAMPLES #if ENABLE_OPENGL_AUTO_AA_SAMPLES
@ -760,11 +760,11 @@ int CLI::run(int argc, char **argv)
#if ENABLE_OPENGL_AUTO_AA_SAMPLES #if ENABLE_OPENGL_AUTO_AA_SAMPLES
params.opengl_aa = opengl_aa; params.opengl_aa = opengl_aa;
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES #endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
params.opengl_version = opengl_version; params.opengl_version = opengl_version;
params.opengl_debug = opengl_debug; params.opengl_debug = opengl_debug;
params.opengl_compatibiity_profile = opengl_compatibility_profile; params.opengl_compatibiity_profile = opengl_compatibility_profile;
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
return Slic3r::GUI::GUI_Run(params); return Slic3r::GUI::GUI_Run(params);
#else // SLIC3R_GUI #else // SLIC3R_GUI
// No GUI support. Just print out a help. // No GUI support. Just print out a help.

View File

@ -4923,7 +4923,7 @@ CLIActionsConfigDef::CLIActionsConfigDef()
def->set_default_value(new ConfigOptionBool(false)); def->set_default_value(new ConfigOptionBool(false));
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES #endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
def = this->add("opengl-version", coString); def = this->add("opengl-version", coString);
def->label = L("OpenGL version"); def->label = L("OpenGL version");
def->tooltip = L("Select a specific version of OpenGL"); def->tooltip = L("Select a specific version of OpenGL");
@ -4941,7 +4941,7 @@ CLIActionsConfigDef::CLIActionsConfigDef()
def->tooltip = L("Activate OpenGL debug output on graphic cards which support it (OpenGL 4.3 or higher)"); def->tooltip = L("Activate OpenGL debug output on graphic cards which support it (OpenGL 4.3 or higher)");
def->cli = "opengl-debug"; def->cli = "opengl-debug";
def->set_default_value(new ConfigOptionBool(false)); def->set_default_value(new ConfigOptionBool(false));
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
def = this->add("slice", coBool); def = this->add("slice", coBool);
def->label = L("Slice"); def->label = L("Slice");

View File

@ -47,9 +47,6 @@
// Enable smoothing of objects normals // Enable smoothing of objects normals
#define ENABLE_SMOOTH_NORMALS 0 #define ENABLE_SMOOTH_NORMALS 0
// Enable OpenGL core profile context (tested against Mesa 20.1.8 on Windows)
#define ENABLE_GL_CORE_PROFILE (1 && !SLIC3R_OPENGL_ES)
// Enable automatic detection of highest number of samples supported for OpenGL antialising // Enable automatic detection of highest number of samples supported for OpenGL antialising
#define ENABLE_OPENGL_AUTO_AA_SAMPLES 1 #define ENABLE_OPENGL_AUTO_AA_SAMPLES 1

View File

@ -518,10 +518,10 @@ void Bed3D::render_default(bool bottom, bool picking, bool show_texture, const T
if (show_texture) { if (show_texture) {
// draw grid // draw grid
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (!OpenGLManager::get_gl_info().is_core_profile()) if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(1.5f * m_scale_factor)); glsafe(::glLineWidth(1.5f * m_scale_factor));
#endif // !SLIC3R_OPENGL_ES
m_gridlines.set_color(has_model && !bottom ? DEFAULT_SOLID_GRID_COLOR : DEFAULT_TRANSPARENT_GRID_COLOR); m_gridlines.set_color(has_model && !bottom ? DEFAULT_SOLID_GRID_COLOR : DEFAULT_TRANSPARENT_GRID_COLOR);
m_gridlines.render(); m_gridlines.render();
} }
@ -549,10 +549,10 @@ void Bed3D::render_contour(const Transform3d& view_matrix, const Transform3d& pr
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
// draw contour // draw contour
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (!OpenGLManager::get_gl_info().is_core_profile()) if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(1.5f * m_scale_factor)); glsafe(::glLineWidth(1.5f * m_scale_factor));
#endif // !SLIC3R_OPENGL_ES
m_contourlines.render(); m_contourlines.render();
glsafe(::glDisable(GL_BLEND)); glsafe(::glDisable(GL_BLEND));

View File

@ -147,10 +147,10 @@ void GLVolume::NonManifoldEdges::render()
{ {
update(); update();
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (!GUI::OpenGLManager::get_gl_info().is_core_profile()) if (!GUI::OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(2.0f)); glsafe(::glLineWidth(2.0f));
#endif // !SLIC3R_OPENGL_ES
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader(); GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
if (shader == nullptr) if (shader == nullptr)
@ -159,12 +159,16 @@ void GLVolume::NonManifoldEdges::render()
const GUI::Camera& camera = GUI::wxGetApp().plater()->get_camera(); const GUI::Camera& camera = GUI::wxGetApp().plater()->get_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * m_parent.world_matrix()); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * m_parent.world_matrix());
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (GUI::OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = camera.get_viewport(); const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.5f); shader->set_uniform("width", 0.5f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
m_model.set_color(complementary(m_parent.render_color)); m_model.set_color(complementary(m_parent.render_color));
m_model.render(); m_model.render();
} }
@ -749,11 +753,11 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
return; return;
GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat"); GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat");
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* edges_shader = GUI::OpenGLManager::get_gl_info().is_core_profile() ? GUI::wxGetApp().get_shader("dashed_thick_lines") : GUI::wxGetApp().get_shader("flat"); GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("dashed_lines");
#else #else
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat"); GLShaderProgram* edges_shader = GUI::OpenGLManager::get_gl_info().is_core_profile() ? GUI::wxGetApp().get_shader("dashed_thick_lines") : GUI::wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
if (type == ERenderType::Transparent) { if (type == ERenderType::Transparent) {
glsafe(::glEnable(GL_BLEND)); glsafe(::glEnable(GL_BLEND));

View File

@ -465,21 +465,25 @@ void GLCanvas3D::LayersEditing::render_profile(const GLCanvas3D& canvas)
m_profile.profile.init_from(std::move(init_data)); m_profile.profile.init_from(std::move(init_data));
} }
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
shader->set_uniform("view_model_matrix", Transform3d::Identity()); shader->set_uniform("view_model_matrix", Transform3d::Identity());
shader->set_uniform("projection_matrix", Transform3d::Identity()); shader->set_uniform("projection_matrix", Transform3d::Identity());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = wxGetApp().plater()->get_camera().get_viewport(); const std::array<int, 4>& viewport = wxGetApp().plater()->get_camera().get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f); shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
m_profile.baseline.render(); m_profile.baseline.render();
m_profile.profile.render(); m_profile.profile.render();
shader->stop_using(); shader->stop_using();
@ -955,11 +959,16 @@ void GLCanvas3D::SequentialPrintClearance::render()
if (!m_evaluating && !m_dragging) if (!m_evaluating && !m_dragging)
m_fill.render(); m_fill.render();
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) { if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
shader->stop_using(); shader->stop_using();
#if SLIC3R_OPENGL_ES
shader = wxGetApp().get_shader("dashed_lines");
#else
shader = wxGetApp().get_shader("dashed_thick_lines"); shader = wxGetApp().get_shader("dashed_thick_lines");
#endif // SLIC3R_OPENGL_ES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -969,10 +978,11 @@ void GLCanvas3D::SequentialPrintClearance::render()
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 1.0f); shader->set_uniform("width", 1.0f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#if !SLIC3R_OPENGL_ES
} }
else else
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(2.0f)); glsafe(::glLineWidth(2.0f));
#endif // !SLIC3R_OPENGL_ES
for (const auto& [id, trafo] : m_instances) { for (const auto& [id, trafo] : m_instances) {
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * trafo); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * trafo);
@ -6172,10 +6182,10 @@ void GLCanvas3D::_render_camera_target()
static const float half_length = 5.0f; static const float half_length = 5.0f;
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (!OpenGLManager::get_gl_info().is_core_profile()) if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(2.0f)); glsafe(::glLineWidth(2.0f));
#endif // !SLIC3R_OPENGL_ES
const Vec3f& target = wxGetApp().plater()->get_camera().get_target().cast<float>(); const Vec3f& target = wxGetApp().plater()->get_camera().get_target().cast<float>();
m_camera_target.target = target.cast<double>(); m_camera_target.target = target.cast<double>();
@ -6211,22 +6221,26 @@ void GLCanvas3D::_render_camera_target()
} }
} }
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * Geometry::translation_transform(m_camera_target.target)); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * Geometry::translation_transform(m_camera_target.target));
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = camera.get_viewport(); const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.5f); shader->set_uniform("width", 0.5f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
m_camera_target.axis[i].render(); m_camera_target.axis[i].render();
} }

View File

@ -685,12 +685,16 @@ void GLModel::reset()
s_statistics.gpu_memory.vertices.current -= vertices_size_bytes(); s_statistics.gpu_memory.vertices.current -= vertices_size_bytes();
#endif // ENABLE_GLMODEL_STATISTICS #endif // ENABLE_GLMODEL_STATISTICS
} }
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
if (m_render_data.vao_id > 0) { if (m_render_data.vao_id > 0) {
glsafe(::glDeleteVertexArrays(1, &m_render_data.vao_id)); glsafe(::glDeleteVertexArrays(1, &m_render_data.vao_id));
m_render_data.vao_id = 0; m_render_data.vao_id = 0;
} }
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
m_render_data.vertices_count = 0; m_render_data.vertices_count = 0;
m_render_data.indices_count = 0; m_render_data.indices_count = 0;
@ -760,11 +764,14 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
const bool tex_coord = Geometry::has_tex_coord(data.format); const bool tex_coord = Geometry::has_tex_coord(data.format);
const bool extra = Geometry::has_extra(data.format); const bool extra = Geometry::has_extra(data.format);
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
glsafe(::glBindVertexArray(m_render_data.vao_id)); glsafe(::glBindVertexArray(m_render_data.vao_id));
#if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
// the following binding is needed to set the vertex attributes // the following binding is needed to set the vertex attributes
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_render_data.vbo_id)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_render_data.vbo_id));
int position_id = -1; int position_id = -1;
@ -803,14 +810,8 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
shader->set_uniform("uniform_color", data.color); shader->set_uniform("uniform_color", data.color);
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_render_data.ibo_id)); glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_render_data.ibo_id));
glsafe(::glDrawElements(mode, range.second - range.first, index_type, (const void*)(range.first * Geometry::index_stride_bytes(data)))); glsafe(::glDrawElements(mode, range.second - range.first, index_type, (const void*)(range.first * Geometry::index_stride_bytes(data))));
#if !ENABLE_GL_CORE_PROFILE
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
#endif // !ENABLE_GL_CORE_PROFILE
if (extra_id != -1) if (extra_id != -1)
glsafe(::glDisableVertexAttribArray(extra_id)); glsafe(::glDisableVertexAttribArray(extra_id));
@ -822,10 +823,13 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
glsafe(::glDisableVertexAttribArray(position_id)); glsafe(::glDisableVertexAttribArray(position_id));
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
glsafe(::glBindVertexArray(0)); glsafe(::glBindVertexArray(0));
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
#if ENABLE_GLMODEL_STATISTICS #if ENABLE_GLMODEL_STATISTICS
++s_statistics.render_calls; ++s_statistics.render_calls;
@ -858,10 +862,13 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
return; return;
} }
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
glsafe(::glBindVertexArray(m_render_data.vao_id)); glsafe(::glBindVertexArray(m_render_data.vao_id));
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, instances_vbo)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, instances_vbo));
const size_t instance_stride = 5 * sizeof(float); const size_t instance_stride = 5 * sizeof(float);
@ -882,9 +889,7 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
const bool position = Geometry::has_position(data.format); const bool position = Geometry::has_position(data.format);
const bool normal = Geometry::has_normal(data.format); const bool normal = Geometry::has_normal(data.format);
#if ENABLE_GL_CORE_PROFILE
// the following binding is needed to set the vertex attributes // the following binding is needed to set the vertex attributes
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_render_data.vbo_id)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_render_data.vbo_id));
if (position) { if (position) {
@ -899,13 +904,7 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
shader->set_uniform("uniform_color", data.color); shader->set_uniform("uniform_color", data.color);
#if !ENABLE_GL_CORE_PROFILE
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_render_data.ibo_id));
#endif // !ENABLE_GL_CORE_PROFILE
glsafe(::glDrawElementsInstanced(mode, indices_count(), index_type, (const void*)0, instances_count)); glsafe(::glDrawElementsInstanced(mode, indices_count(), index_type, (const void*)0, instances_count));
#if !ENABLE_GL_CORE_PROFILE
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
#endif // !ENABLE_GL_CORE_PROFILE
if (normal) if (normal)
glsafe(::glDisableVertexAttribArray(normal_id)); glsafe(::glDisableVertexAttribArray(normal_id));
@ -916,10 +915,13 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
glsafe(::glDisableVertexAttribArray(offset_id)); glsafe(::glDisableVertexAttribArray(offset_id));
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
glsafe(::glBindVertexArray(0)); glsafe(::glBindVertexArray(0));
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
#if ENABLE_GLMODEL_STATISTICS #if ENABLE_GLMODEL_STATISTICS
++s_statistics.render_instanced_calls; ++s_statistics.render_instanced_calls;
@ -939,12 +941,14 @@ bool GLModel::send_to_gpu()
return false; return false;
} }
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) { if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
glsafe(::glGenVertexArrays(1, &m_render_data.vao_id)); glsafe(::glGenVertexArrays(1, &m_render_data.vao_id));
glsafe(::glBindVertexArray(m_render_data.vao_id)); glsafe(::glBindVertexArray(m_render_data.vao_id));
#if !SLIC3R_OPENGL_ES
} }
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
// vertices // vertices
glsafe(::glGenBuffers(1, &m_render_data.vbo_id)); glsafe(::glGenBuffers(1, &m_render_data.vbo_id));
@ -985,11 +989,6 @@ bool GLModel::send_to_gpu()
glsafe(::glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.indices_size_bytes(), data.indices.data(), GL_STATIC_DRAW)); glsafe(::glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.indices_size_bytes(), data.indices.data(), GL_STATIC_DRAW));
} }
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
m_render_data.indices_count = indices_count; m_render_data.indices_count = indices_count;
#if ENABLE_GLMODEL_STATISTICS #if ENABLE_GLMODEL_STATISTICS
s_statistics.gpu_memory.indices.current += data.indices_size_bytes(); s_statistics.gpu_memory.indices.current += data.indices_size_bytes();
@ -997,10 +996,13 @@ bool GLModel::send_to_gpu()
#endif // ENABLE_GLMODEL_STATISTICS #endif // ENABLE_GLMODEL_STATISTICS
data.indices = std::vector<unsigned int>(); data.indices = std::vector<unsigned int>();
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
glsafe(::glBindVertexArray(0)); glsafe(::glBindVertexArray(0));
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
return true; return true;
} }

View File

@ -154,9 +154,7 @@ namespace GUI {
struct RenderData struct RenderData
{ {
Geometry geometry; Geometry geometry;
#if ENABLE_GL_CORE_PROFILE
unsigned int vao_id{ 0 }; unsigned int vao_id{ 0 };
#endif // ENABLE_GL_CORE_PROFILE
unsigned int vbo_id{ 0 }; unsigned int vbo_id{ 0 };
unsigned int ibo_id{ 0 }; unsigned int ibo_id{ 0 };
size_t vertices_count{ 0 }; size_t vertices_count{ 0 };

View File

@ -76,32 +76,25 @@ namespace GUI {
const float top = -2.0f * (get_top() * cnv_inv_height - 0.5f); const float top = -2.0f * (get_top() * cnv_inv_height - 0.5f);
const float bottom = -2.0f * (get_bottom() * cnv_inv_height - 0.5f); const float bottom = -2.0f * (get_bottom() * cnv_inv_height - 0.5f);
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
const bool core_profile = OpenGLManager::get_gl_info().is_core_profile(); if (!OpenGLManager::get_gl_info().is_core_profile())
if (!core_profile)
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(1.5f)); glsafe(::glLineWidth(1.5f));
#endif // !SLIC3R_OPENGL_ES
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
#if !SLIC3R_OPENGL_ES #if !SLIC3R_OPENGL_ES
#if ENABLE_GL_CORE_PROFILE if (!OpenGLManager::get_gl_info().is_core_profile()) {
if (!core_profile) {
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glPushAttrib(GL_ENABLE_BIT)); glsafe(::glPushAttrib(GL_ENABLE_BIT));
glsafe(::glLineStipple(4, 0xAAAA)); glsafe(::glLineStipple(4, 0xAAAA));
glsafe(::glEnable(GL_LINE_STIPPLE)); glsafe(::glEnable(GL_LINE_STIPPLE));
#if ENABLE_GL_CORE_PROFILE
} }
#endif // ENABLE_GL_CORE_PROFILE
#endif // !SLIC3R_OPENGL_ES #endif // !SLIC3R_OPENGL_ES
#if SLIC3R_OPENGL_ES #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines"); GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#elif ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = core_profile ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#endif // SLIC3R_OPENGL_ES #endif // SLIC3R_OPENGL_ES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
@ -112,18 +105,25 @@ namespace GUI {
m_rectangle.reset(); m_rectangle.reset();
GLModel::Geometry init_data; GLModel::Geometry init_data;
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P4 }; init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P4 };
init_data.reserve_vertices(5); init_data.reserve_vertices(5);
init_data.reserve_indices(8); init_data.reserve_indices(8);
#else #if !SLIC3R_OPENGL_ES
}
else {
init_data.format = { GLModel::Geometry::EPrimitiveType::LineLoop, GLModel::Geometry::EVertexLayout::P2 }; init_data.format = { GLModel::Geometry::EPrimitiveType::LineLoop, GLModel::Geometry::EVertexLayout::P2 };
init_data.reserve_vertices(4); init_data.reserve_vertices(4);
init_data.reserve_indices(4); init_data.reserve_indices(4);
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES }
#endif // !SLIC3R_OPENGL_ES
// vertices // vertices
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const float width = right - left; const float width = right - left;
const float height = top - bottom; const float height = top - bottom;
float perimeter = 0.0f; float perimeter = 0.0f;
@ -143,7 +143,9 @@ namespace GUI {
init_data.add_line(1, 2); init_data.add_line(1, 2);
init_data.add_line(2, 3); init_data.add_line(2, 3);
init_data.add_line(3, 4); init_data.add_line(3, 4);
#else #if !SLIC3R_OPENGL_ES
}
else {
init_data.add_vertex(Vec2f(left, bottom)); init_data.add_vertex(Vec2f(left, bottom));
init_data.add_vertex(Vec2f(right, bottom)); init_data.add_vertex(Vec2f(right, bottom));
init_data.add_vertex(Vec2f(right, top)); init_data.add_vertex(Vec2f(right, top));
@ -154,25 +156,25 @@ namespace GUI {
init_data.add_index(1); init_data.add_index(1);
init_data.add_index(2); init_data.add_index(2);
init_data.add_index(3); init_data.add_index(3);
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES }
#endif // !SLIC3R_OPENGL_ES
m_rectangle.init_from(std::move(init_data)); m_rectangle.init_from(std::move(init_data));
} }
shader->set_uniform("view_model_matrix", Transform3d::Identity()); shader->set_uniform("view_model_matrix", Transform3d::Identity());
shader->set_uniform("projection_matrix", Transform3d::Identity()); shader->set_uniform("projection_matrix", Transform3d::Identity());
#if SLIC3R_OPENGL_ES #if !SLIC3R_OPENGL_ES
shader->set_uniform("dash_size", 0.01f); if (OpenGLManager::get_gl_info().is_core_profile()) {
shader->set_uniform("gap_size", 0.0075f); #endif // !SLIC3R_OPENGL_ES
#elif ENABLE_GL_CORE_PROFILE
if (core_profile) {
const std::array<int, 4>& viewport = wxGetApp().plater()->get_camera().get_viewport(); const std::array<int, 4>& viewport = wxGetApp().plater()->get_camera().get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f); shader->set_uniform("width", 0.25f);
shader->set_uniform("dash_size", 0.01f); shader->set_uniform("dash_size", 0.01f);
shader->set_uniform("gap_size", 0.0075f); shader->set_uniform("gap_size", 0.0075f);
#if !SLIC3R_OPENGL_ES
} }
#endif // SLIC3R_OPENGL_ES #endif // !SLIC3R_OPENGL_ES
m_rectangle.set_color(ColorRGBA((m_state == EState::Select) ? 0.3f : 1.0f, (m_state == EState::Select) ? 1.0f : 0.3f, 0.3f, 1.0f)); m_rectangle.set_color(ColorRGBA((m_state == EState::Select) ? 0.3f : 1.0f, (m_state == EState::Select) ? 1.0f : 0.3f, 0.3f, 1.0f));
m_rectangle.render(); m_rectangle.render();
@ -180,9 +182,7 @@ namespace GUI {
} }
#if !SLIC3R_OPENGL_ES #if !SLIC3R_OPENGL_ES
#if ENABLE_GL_CORE_PROFILE if (!OpenGLManager::get_gl_info().is_core_profile())
if (!core_profile)
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glPopAttrib()); glsafe(::glPopAttrib());
#endif // !SLIC3R_OPENGL_ES #endif // !SLIC3R_OPENGL_ES
} }

View File

@ -7,9 +7,9 @@
#include "GLShadersManager.hpp" #include "GLShadersManager.hpp"
#include "3DScene.hpp" #include "3DScene.hpp"
#include "GUI_App.hpp" #include "GUI_App.hpp"
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
#include "OpenGLManager.hpp" #include "OpenGLManager.hpp"
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
#include <cassert> #include <cassert>
#include <algorithm> #include <algorithm>
@ -60,7 +60,7 @@ std::pair<bool, std::string> GLShadersManager::init()
#if SLIC3R_OPENGL_ES #if SLIC3R_OPENGL_ES
// used to render dashed lines // used to render dashed lines
valid &= append_shader("dashed_lines", { prefix + "dashed_lines.vs", prefix + "dashed_lines.fs" }); valid &= append_shader("dashed_lines", { prefix + "dashed_lines.vs", prefix + "dashed_lines.fs" });
#elif ENABLE_GL_CORE_PROFILE #else
if (GUI::OpenGLManager::get_gl_info().is_core_profile()) if (GUI::OpenGLManager::get_gl_info().is_core_profile())
// used to render thick and/or dashed lines // used to render thick and/or dashed lines
valid &= append_shader("dashed_thick_lines", { prefix + "dashed_thick_lines.vs", prefix + "dashed_thick_lines.fs", prefix + "dashed_thick_lines.gs" }); valid &= append_shader("dashed_thick_lines", { prefix + "dashed_thick_lines.vs", prefix + "dashed_thick_lines.fs", prefix + "dashed_thick_lines.gs" });

View File

@ -336,12 +336,6 @@ void GLTexture::render_sub_texture(unsigned int tex_id, float left, float right,
{ {
glsafe(::glEnable(GL_BLEND)); glsafe(::glEnable(GL_BLEND));
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
#if !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES
glsafe(::glEnable(GL_TEXTURE_2D));
glsafe(::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE));
#endif // !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES
glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)tex_id)); glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)tex_id));
GLModel::Geometry init_data; GLModel::Geometry init_data;
@ -372,10 +366,6 @@ void GLTexture::render_sub_texture(unsigned int tex_id, float left, float right,
} }
glsafe(::glBindTexture(GL_TEXTURE_2D, 0)); glsafe(::glBindTexture(GL_TEXTURE_2D, 0));
#if !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES
glsafe(::glDisable(GL_TEXTURE_2D));
#endif // !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES
glsafe(::glDisable(GL_BLEND)); glsafe(::glDisable(GL_BLEND));
} }

View File

@ -887,12 +887,12 @@ std::string GUI_App::get_gl_info(bool for_github)
wxGLContext* GUI_App::init_glcontext(wxGLCanvas& canvas) wxGLContext* GUI_App::init_glcontext(wxGLCanvas& canvas)
{ {
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
return m_opengl_mgr.init_glcontext(canvas);
#else
return m_opengl_mgr.init_glcontext(canvas, init_params != nullptr ? init_params->opengl_version : std::make_pair(0, 0), return m_opengl_mgr.init_glcontext(canvas, init_params != nullptr ? init_params->opengl_version : std::make_pair(0, 0),
init_params != nullptr ? init_params->opengl_compatibiity_profile : false, init_params != nullptr ? init_params->opengl_debug : false); init_params != nullptr ? init_params->opengl_compatibiity_profile : false, init_params != nullptr ? init_params->opengl_debug : false);
#else #endif // SLIC3R_OPENGL_ES
return m_opengl_mgr.init_glcontext(canvas);
#endif // ENABLE_GL_CORE_PROFILE
} }
bool GUI_App::init_opengl() bool GUI_App::init_opengl()

View File

@ -33,11 +33,11 @@ struct GUI_InitParams
bool start_downloader; bool start_downloader;
bool delete_after_load; bool delete_after_load;
std::string download_url; std::string download_url;
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
std::pair<int, int> opengl_version; std::pair<int, int> opengl_version;
bool opengl_debug; bool opengl_debug;
bool opengl_compatibiity_profile; bool opengl_compatibiity_profile;
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
#if ENABLE_OPENGL_AUTO_AA_SAMPLES #if ENABLE_OPENGL_AUTO_AA_SAMPLES
bool opengl_aa; bool opengl_aa;
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES #endif // ENABLE_OPENGL_AUTO_AA_SAMPLES

View File

@ -1168,24 +1168,29 @@ void GLGizmoMeasure::render_dimensioning()
const Transform3d ss_to_ndc_matrix = TransformHelper::ndc_to_ss_matrix_inverse(viewport); const Transform3d ss_to_ndc_matrix = TransformHelper::ndc_to_ss_matrix_inverse(viewport);
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) { if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
shader->stop_using(); shader->stop_using();
#if SLIC3R_OPENGL_ES
shader = wxGetApp().get_shader("dashed_lines");
#else
shader = wxGetApp().get_shader("dashed_thick_lines"); shader = wxGetApp().get_shader("dashed_thick_lines");
#endif // SLIC3R_OPENGL_ES
if (shader == nullptr) if (shader == nullptr)
return; return;
shader->start_using(); shader->start_using();
shader->set_uniform("projection_matrix", Transform3d::Identity()); shader->set_uniform("projection_matrix", Transform3d::Identity());
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 1.0f); shader->set_uniform("width", 1.0f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#if !SLIC3R_OPENGL_ES
} }
else else
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(2.0f)); glsafe(::glLineWidth(2.0f));
#endif // !SLIC3R_OPENGL_ES
// stem // stem
shader->set_uniform("view_model_matrix", overlap ? shader->set_uniform("view_model_matrix", overlap ?
@ -1194,8 +1199,9 @@ void GLGizmoMeasure::render_dimensioning()
m_dimensioning.line.set_color(ColorRGBA::WHITE()); m_dimensioning.line.set_color(ColorRGBA::WHITE());
m_dimensioning.line.render(); m_dimensioning.line.render();
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) { if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
shader->stop_using(); shader->stop_using();
shader = wxGetApp().get_shader("flat"); shader = wxGetApp().get_shader("flat");
@ -1203,10 +1209,11 @@ void GLGizmoMeasure::render_dimensioning()
return; return;
shader->start_using(); shader->start_using();
#if !SLIC3R_OPENGL_ES
} }
else else
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(1.0f)); glsafe(::glLineWidth(1.0f));
#endif // !SLIC3R_OPENGL_ES
// arrow 1 // arrow 1
shader->set_uniform("view_model_matrix", overlap ? shader->set_uniform("view_model_matrix", overlap ?
@ -1462,11 +1469,16 @@ void GLGizmoMeasure::render_dimensioning()
} }
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) { if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
shader->stop_using(); shader->stop_using();
#if SLIC3R_OPENGL_ES
shader = wxGetApp().get_shader("dashed_lines");
#else
shader = wxGetApp().get_shader("dashed_thick_lines"); shader = wxGetApp().get_shader("dashed_thick_lines");
#endif // SLIC3R_OPENGL_ES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -1476,18 +1488,20 @@ void GLGizmoMeasure::render_dimensioning()
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 1.0f); shader->set_uniform("width", 1.0f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#if !SLIC3R_OPENGL_ES
} }
else else
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(2.0f)); glsafe(::glLineWidth(2.0f));
#endif // !SLIC3R_OPENGL_ES
// arc // arc
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * Geometry::translation_transform(center)); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * Geometry::translation_transform(center));
m_dimensioning.arc.render(); m_dimensioning.arc.render();
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) { if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
shader->stop_using(); shader->stop_using();
shader = wxGetApp().get_shader("flat"); shader = wxGetApp().get_shader("flat");
@ -1495,10 +1509,11 @@ void GLGizmoMeasure::render_dimensioning()
return; return;
shader->start_using(); shader->start_using();
#if !SLIC3R_OPENGL_ES
} }
else else
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(1.0f)); glsafe(::glLineWidth(1.0f));
#endif // !SLIC3R_OPENGL_ES
// arrows // arrows
auto render_arrow = [this, shader, &camera, &normal, &center, &e1_unit, draw_radius, step, resolution](unsigned int endpoint_id) { auto render_arrow = [this, shader, &camera, &normal, &center, &e1_unit, draw_radius, step, resolution](unsigned int endpoint_id) {

View File

@ -664,12 +664,16 @@ void GLMmSegmentationGizmo3DScene::release_geometry() {
glsafe(::glDeleteBuffers(1, &triangle_indices_VBO_id)); glsafe(::glDeleteBuffers(1, &triangle_indices_VBO_id));
triangle_indices_VBO_id = 0; triangle_indices_VBO_id = 0;
} }
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
if (this->vertices_VAO_id > 0) { if (this->vertices_VAO_id > 0) {
glsafe(::glDeleteVertexArrays(1, &this->vertices_VAO_id)); glsafe(::glDeleteVertexArrays(1, &this->vertices_VAO_id));
this->vertices_VAO_id = 0; this->vertices_VAO_id = 0;
} }
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
this->clear(); this->clear();
} }
@ -678,10 +682,13 @@ void GLMmSegmentationGizmo3DScene::render(size_t triangle_indices_idx) const
{ {
assert(triangle_indices_idx < this->triangle_indices_VBO_ids.size()); assert(triangle_indices_idx < this->triangle_indices_VBO_ids.size());
assert(this->triangle_indices_sizes.size() == this->triangle_indices_VBO_ids.size()); assert(this->triangle_indices_sizes.size() == this->triangle_indices_VBO_ids.size());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
assert(this->vertices_VAO_id != 0); assert(this->vertices_VAO_id != 0);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
assert(this->vertices_VBO_id != 0); assert(this->vertices_VBO_id != 0);
assert(this->triangle_indices_VBO_ids[triangle_indices_idx] != 0); assert(this->triangle_indices_VBO_ids[triangle_indices_idx] != 0);
@ -689,11 +696,14 @@ void GLMmSegmentationGizmo3DScene::render(size_t triangle_indices_idx) const
if (shader == nullptr) if (shader == nullptr)
return; return;
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
glsafe(::glBindVertexArray(this->vertices_VAO_id)); glsafe(::glBindVertexArray(this->vertices_VAO_id));
#if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
// the following binding is needed to set the vertex attributes // the following binding is needed to set the vertex attributes
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, this->vertices_VBO_id)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, this->vertices_VBO_id));
const GLint position_id = shader->get_attrib_location("v_position"); const GLint position_id = shader->get_attrib_location("v_position");
if (position_id != -1) { if (position_id != -1) {
@ -713,25 +723,34 @@ void GLMmSegmentationGizmo3DScene::render(size_t triangle_indices_idx) const
glsafe(::glDisableVertexAttribArray(position_id)); glsafe(::glDisableVertexAttribArray(position_id));
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
glsafe(::glBindVertexArray(0)); glsafe(::glBindVertexArray(0));
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
} }
void GLMmSegmentationGizmo3DScene::finalize_vertices() void GLMmSegmentationGizmo3DScene::finalize_vertices()
{ {
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
assert(this->vertices_VAO_id == 0); assert(this->vertices_VAO_id == 0);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
assert(this->vertices_VBO_id == 0); assert(this->vertices_VBO_id == 0);
if (!this->vertices.empty()) { if (!this->vertices.empty()) {
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) { if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
glsafe(::glGenVertexArrays(1, &this->vertices_VAO_id)); glsafe(::glGenVertexArrays(1, &this->vertices_VAO_id));
glsafe(::glBindVertexArray(this->vertices_VAO_id)); glsafe(::glBindVertexArray(this->vertices_VAO_id));
#if !SLIC3R_OPENGL_ES
} }
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
glsafe(::glGenBuffers(1, &this->vertices_VBO_id)); glsafe(::glGenBuffers(1, &this->vertices_VBO_id));
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, this->vertices_VBO_id)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, this->vertices_VBO_id));
@ -739,10 +758,13 @@ void GLMmSegmentationGizmo3DScene::finalize_vertices()
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
this->vertices.clear(); this->vertices.clear();
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
glsafe(::glBindVertexArray(0)); glsafe(::glBindVertexArray(0));
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
} }
} }
@ -751,7 +773,7 @@ void GLMmSegmentationGizmo3DScene::finalize_triangle_indices()
assert(std::all_of(triangle_indices_VBO_ids.cbegin(), triangle_indices_VBO_ids.cend(), [](const auto &ti_VBO_id) { return ti_VBO_id == 0; })); assert(std::all_of(triangle_indices_VBO_ids.cbegin(), triangle_indices_VBO_ids.cend(), [](const auto &ti_VBO_id) { return ti_VBO_id == 0; }));
assert(this->triangle_indices.size() == this->triangle_indices_VBO_ids.size()); assert(this->triangle_indices.size() == this->triangle_indices_VBO_ids.size());
for (size_t buffer_idx = 0; buffer_idx < this->triangle_indices.size(); ++buffer_idx) for (size_t buffer_idx = 0; buffer_idx < this->triangle_indices.size(); ++buffer_idx) {
if (!this->triangle_indices[buffer_idx].empty()) { if (!this->triangle_indices[buffer_idx].empty()) {
glsafe(::glGenBuffers(1, &this->triangle_indices_VBO_ids[buffer_idx])); glsafe(::glGenBuffers(1, &this->triangle_indices_VBO_ids[buffer_idx]));
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->triangle_indices_VBO_ids[buffer_idx])); glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->triangle_indices_VBO_ids[buffer_idx]));
@ -760,5 +782,6 @@ void GLMmSegmentationGizmo3DScene::finalize_triangle_indices()
this->triangle_indices[buffer_idx].clear(); this->triangle_indices[buffer_idx].clear();
} }
} }
}
} // namespace Slic3r } // namespace Slic3r

View File

@ -61,9 +61,7 @@ public:
// IDs of the Vertex Array Objects, into which the geometry has been loaded. // IDs of the Vertex Array Objects, into which the geometry has been loaded.
// Zero if the VBOs are not sent to GPU yet. // Zero if the VBOs are not sent to GPU yet.
#if ENABLE_GL_CORE_PROFILE
unsigned int vertices_VAO_id{ 0 }; unsigned int vertices_VAO_id{ 0 };
#endif // ENABLE_GL_CORE_PROFILE
unsigned int vertices_VBO_id{ 0 }; unsigned int vertices_VBO_id{ 0 };
std::vector<unsigned int> triangle_indices_VBO_ids; std::vector<unsigned int> triangle_indices_VBO_ids;
}; };

View File

@ -134,10 +134,10 @@ void GLGizmoMove3D::on_render()
m_grabbers[2].center = { 0.0, 0.0, half_box_size.z() + Offset }; m_grabbers[2].center = { 0.0, 0.0, half_box_size.z() + Offset };
m_grabbers[2].color = AXES_COLOR[2]; m_grabbers[2].color = AXES_COLOR[2];
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (!OpenGLManager::get_gl_info().is_core_profile()) if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f)); glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
#endif // !SLIC3R_OPENGL_ES
auto render_grabber_connection = [this, &zero](unsigned int id) { auto render_grabber_connection = [this, &zero](unsigned int id) {
if (m_grabbers[id].enabled) { if (m_grabbers[id].enabled) {
@ -166,22 +166,26 @@ void GLGizmoMove3D::on_render()
}; };
if (m_hover_id == -1) { if (m_hover_id == -1) {
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * base_matrix); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * base_matrix);
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = camera.get_viewport(); const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f); shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
// draw axes // draw axes
for (unsigned int i = 0; i < 3; ++i) { for (unsigned int i = 0; i < 3; ++i) {
@ -196,23 +200,27 @@ void GLGizmoMove3D::on_render()
} }
else { else {
// draw axis // draw axis
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix()* base_matrix); shader->set_uniform("view_model_matrix", camera.get_view_matrix()* base_matrix);
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif /// !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = camera.get_viewport(); const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.5f); shader->set_uniform("width", 0.5f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
render_grabber_connection(m_hover_id); render_grabber_connection(m_hover_id);
shader->stop_using(); shader->stop_using();

View File

@ -158,103 +158,115 @@ void GLGizmoPainterBase::render_cursor_circle()
const float cnv_inv_height = 1.0f / cnv_height; const float cnv_inv_height = 1.0f / cnv_height;
const Vec2d center = m_parent.get_local_mouse_position(); const Vec2d center = m_parent.get_local_mouse_position();
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
const float zoom = float(wxGetApp().plater()->get_camera().get_zoom()); const float zoom = float(wxGetApp().plater()->get_camera().get_zoom());
const float radius = m_cursor_radius * zoom; const float radius = m_cursor_radius * zoom;
#else
const float radius = m_cursor_radius * float(wxGetApp().plater()->get_camera().get_zoom());
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (!OpenGLManager::get_gl_info().is_core_profile()) if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(1.5f)); glsafe(::glLineWidth(1.5f));
#endif // !SLIC3R_OPENGL_ES
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
#if !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES #if !SLIC3R_OPENGL_ES
if (!OpenGLManager::get_gl_info().is_core_profile()) {
glsafe(::glPushAttrib(GL_ENABLE_BIT)); glsafe(::glPushAttrib(GL_ENABLE_BIT));
glsafe(::glLineStipple(4, 0xAAAA)); glsafe(::glLineStipple(4, 0xAAAA));
glsafe(::glEnable(GL_LINE_STIPPLE)); glsafe(::glEnable(GL_LINE_STIPPLE));
#endif // !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES }
#endif // !SLIC3R_OPENGL_ES
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
if (!m_circle.is_initialized() || std::abs(m_old_cursor_radius - radius) > EPSILON) {
m_old_cursor_radius = radius;
m_circle.reset();
#else
if (!m_circle.is_initialized() || !m_old_center.isApprox(center) || std::abs(m_old_cursor_radius - radius) > EPSILON) { if (!m_circle.is_initialized() || !m_old_center.isApprox(center) || std::abs(m_old_cursor_radius - radius) > EPSILON) {
m_old_cursor_radius = radius; m_old_cursor_radius = radius;
m_old_center = center; m_old_center = center;
m_circle.reset(); m_circle.reset();
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
GLModel::Geometry init_data; GLModel::Geometry init_data;
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES unsigned int steps_count = 0;
const unsigned int StepsCount = (unsigned int)(2 * (4 + int(252 * (zoom - 1.0f) / (250.0f - 1.0f)))); #if !SLIC3R_OPENGL_ES
const float StepSize = 2.0f * float(PI) / float(StepsCount); if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
steps_count = (unsigned int)(2 * (4 + int(252 * (zoom - 1.0f) / (250.0f - 1.0f))));
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P2 }; init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P2 };
#else #if !SLIC3R_OPENGL_ES
static const unsigned int StepsCount = 32; }
static const float StepSize = 2.0f * float(PI) / float(StepsCount); else {
steps_count = 32;
init_data.format = { GLModel::Geometry::EPrimitiveType::LineLoop, GLModel::Geometry::EVertexLayout::P2 }; init_data.format = { GLModel::Geometry::EPrimitiveType::LineLoop, GLModel::Geometry::EVertexLayout::P2 };
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES }
#endif // !SLIC3R_OPENGL_ES
const float step_size = 2.0f * float(PI) / float(steps_count);
init_data.color = { 0.0f, 1.0f, 0.3f, 1.0f }; init_data.color = { 0.0f, 1.0f, 0.3f, 1.0f };
init_data.reserve_vertices(StepsCount); init_data.reserve_vertices(steps_count);
init_data.reserve_indices(StepsCount); init_data.reserve_indices(steps_count);
// vertices + indices // vertices + indices
for (unsigned int i = 0; i < StepsCount; ++i) { for (unsigned int i = 0; i < steps_count; ++i) {
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
if (i % 2 != 0) continue; if (i % 2 != 0) continue;
const float angle_i = float(i) * StepSize; const float angle_i = float(i) * step_size;
const unsigned int j = (i + 1) % StepsCount; const unsigned int j = (i + 1) % steps_count;
const float angle_j = float(j) * StepSize; const float angle_j = float(j) * step_size;
const Vec2d v_i(::cos(angle_i), ::sin(angle_i)); const Vec2d v_i(::cos(angle_i), ::sin(angle_i));
const Vec2d v_j(::cos(angle_j), ::sin(angle_j)); const Vec2d v_j(::cos(angle_j), ::sin(angle_j));
init_data.add_vertex(Vec2f(v_i.x(), v_i.y())); init_data.add_vertex(Vec2f(v_i.x(), v_i.y()));
init_data.add_vertex(Vec2f(v_j.x(), v_j.y())); init_data.add_vertex(Vec2f(v_j.x(), v_j.y()));
const size_t vcount = init_data.vertices_count(); const size_t vcount = init_data.vertices_count();
init_data.add_line(vcount - 2, vcount - 1); init_data.add_line(vcount - 2, vcount - 1);
#else #if !SLIC3R_OPENGL_ES
const float angle = float(i) * StepSize; }
else {
const float angle = float(i) * step_size;
init_data.add_vertex(Vec2f(2.0f * ((center.x() + ::cos(angle) * radius) * cnv_inv_width - 0.5f), init_data.add_vertex(Vec2f(2.0f * ((center.x() + ::cos(angle) * radius) * cnv_inv_width - 0.5f),
-2.0f * ((center.y() + ::sin(angle) * radius) * cnv_inv_height - 0.5f))); -2.0f * ((center.y() + ::sin(angle) * radius) * cnv_inv_height - 0.5f)));
init_data.add_index(i); init_data.add_index(i);
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES }
#endif // !SLIC3R_OPENGL_ES
} }
m_circle.init_from(std::move(init_data)); m_circle.init_from(std::move(init_data));
} }
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#else #else
GLShaderProgram* shader = GUI::wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const Transform3d view_model_matrix = Geometry::translation_transform(Vec3d(2.0f * (center.x() * cnv_inv_width - 0.5f), -2.0f * (center.y() * cnv_inv_height - 0.5f), 0.0)) * const Transform3d view_model_matrix = Geometry::translation_transform(Vec3d(2.0f * (center.x() * cnv_inv_width - 0.5f), -2.0f * (center.y() * cnv_inv_height - 0.5f), 0.0)) *
Geometry::scale_transform(Vec3d(2.0f * radius * cnv_inv_width, 2.0f * radius * cnv_inv_height, 1.0f)); Geometry::scale_transform(Vec3d(2.0f * radius * cnv_inv_width, 2.0f * radius * cnv_inv_height, 1.0f));
shader->set_uniform("view_model_matrix", view_model_matrix); shader->set_uniform("view_model_matrix", view_model_matrix);
#else #if !SLIC3R_OPENGL_ES
}
else
shader->set_uniform("view_model_matrix", Transform3d::Identity()); shader->set_uniform("view_model_matrix", Transform3d::Identity());
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES #endif // !SLIC3R_OPENGL_ES
shader->set_uniform("projection_matrix", Transform3d::Identity()); shader->set_uniform("projection_matrix", Transform3d::Identity());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = wxGetApp().plater()->get_camera().get_viewport(); const std::array<int, 4>& viewport = wxGetApp().plater()->get_camera().get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f); shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
m_circle.render(); m_circle.render();
shader->stop_using(); shader->stop_using();
} }
#if !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES #if !SLIC3R_OPENGL_ES
if (!OpenGLManager::get_gl_info().is_core_profile())
glsafe(::glPopAttrib()); glsafe(::glPopAttrib());
#endif // !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES #endif // !SLIC3R_OPENGL_ES
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
} }

View File

@ -154,9 +154,7 @@ protected:
float m_highlight_by_angle_threshold_deg = 0.f; float m_highlight_by_angle_threshold_deg = 0.f;
GLModel m_circle; GLModel m_circle;
#if !ENABLE_GL_CORE_PROFILE
Vec2d m_old_center{ Vec2d::Zero() }; Vec2d m_old_center{ Vec2d::Zero() };
#endif // !ENABLE_GL_CORE_PROFILE
float m_old_cursor_radius{ 0.0f }; float m_old_cursor_radius{ 0.0f };
static constexpr float SmartFillAngleMin = 0.0f; static constexpr float SmartFillAngleMin = 0.0f;

View File

@ -153,16 +153,16 @@ void GLGizmoRotate::on_render()
m_grabbers.front().matrix = local_transform(selection); m_grabbers.front().matrix = local_transform(selection);
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (!OpenGLManager::get_gl_info().is_core_profile()) if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f)); glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
#endif // !SLIC3R_OPENGL_ES
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
@ -170,12 +170,16 @@ void GLGizmoRotate::on_render()
const Transform3d view_model_matrix = camera.get_view_matrix() * m_grabbers.front().matrix; const Transform3d view_model_matrix = camera.get_view_matrix() * m_grabbers.front().matrix;
shader->set_uniform("view_model_matrix", view_model_matrix); shader->set_uniform("view_model_matrix", view_model_matrix);
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = camera.get_viewport(); const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f); shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
const bool radius_changed = std::abs(m_old_radius - m_radius) > EPSILON; const bool radius_changed = std::abs(m_old_radius - m_radius) > EPSILON;
m_old_radius = m_radius; m_old_radius = m_radius;

View File

@ -164,31 +164,35 @@ void GLGizmoScale3D::on_render()
update_render_data(); update_render_data();
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (!OpenGLManager::get_gl_info().is_core_profile()) if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f)); glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
#endif // !SLIC3R_OPENGL_ES
const float grabber_mean_size = (float)((m_bounding_box.size().x() + m_bounding_box.size().y() + m_bounding_box.size().z()) / 3.0); const float grabber_mean_size = (float)((m_bounding_box.size().x() + m_bounding_box.size().y() + m_bounding_box.size().z()) / 3.0);
if (m_hover_id == -1) { if (m_hover_id == -1) {
// draw connections // draw connections
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * m_grabbers_transform); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * m_grabbers_transform);
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = camera.get_viewport(); const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f); shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
if (m_grabbers[0].enabled && m_grabbers[1].enabled) if (m_grabbers[0].enabled && m_grabbers[1].enabled)
render_grabbers_connection(0, 1, m_grabbers[0].color); render_grabbers_connection(0, 1, m_grabbers[0].color);
if (m_grabbers[2].enabled && m_grabbers[3].enabled) if (m_grabbers[2].enabled && m_grabbers[3].enabled)
@ -207,22 +211,26 @@ void GLGizmoScale3D::on_render()
} }
else if ((m_hover_id == 0 || m_hover_id == 1) && m_grabbers[0].enabled && m_grabbers[1].enabled) { else if ((m_hover_id == 0 || m_hover_id == 1) && m_grabbers[0].enabled && m_grabbers[1].enabled) {
// draw connections // draw connections
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * m_grabbers_transform); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * m_grabbers_transform);
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = camera.get_viewport(); const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f); shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
render_grabbers_connection(0, 1, m_grabbers[0].color); render_grabbers_connection(0, 1, m_grabbers[0].color);
shader->stop_using(); shader->stop_using();
} }
@ -238,22 +246,26 @@ void GLGizmoScale3D::on_render()
} }
else if ((m_hover_id == 2 || m_hover_id == 3) && m_grabbers[2].enabled && m_grabbers[3].enabled) { else if ((m_hover_id == 2 || m_hover_id == 3) && m_grabbers[2].enabled && m_grabbers[3].enabled) {
// draw connections // draw connections
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * m_grabbers_transform); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * m_grabbers_transform);
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = camera.get_viewport(); const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f); shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
render_grabbers_connection(2, 3, m_grabbers[2].color); render_grabbers_connection(2, 3, m_grabbers[2].color);
shader->stop_using(); shader->stop_using();
} }
@ -269,22 +281,26 @@ void GLGizmoScale3D::on_render()
} }
else if ((m_hover_id == 4 || m_hover_id == 5) && m_grabbers[4].enabled && m_grabbers[5].enabled) { else if ((m_hover_id == 4 || m_hover_id == 5) && m_grabbers[4].enabled && m_grabbers[5].enabled) {
// draw connections // draw connections
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * m_grabbers_transform); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * m_grabbers_transform);
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = camera.get_viewport(); const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f); shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
render_grabbers_connection(4, 5, m_grabbers[4].color); render_grabbers_connection(4, 5, m_grabbers[4].color);
shader->stop_using(); shader->stop_using();
} }
@ -300,22 +316,26 @@ void GLGizmoScale3D::on_render()
} }
else if (m_hover_id >= 6) { else if (m_hover_id >= 6) {
// draw connections // draw connections
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * m_grabbers_transform); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * m_grabbers_transform);
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = camera.get_viewport(); const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f); shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
render_grabbers_connection(6, 7, m_drag_color); render_grabbers_connection(6, 7, m_drag_color);
render_grabbers_connection(7, 8, m_drag_color); render_grabbers_connection(7, 8, m_drag_color);
render_grabbers_connection(8, 9, m_drag_color); render_grabbers_connection(8, 9, m_drag_color);

View File

@ -737,11 +737,7 @@ void GLGizmoSimplify::on_render()
const Transform3d trafo_matrix = selected_volume->world_matrix(); const Transform3d trafo_matrix = selected_volume->world_matrix();
auto* gouraud_shader = wxGetApp().get_shader("gouraud_light"); auto* gouraud_shader = wxGetApp().get_shader("gouraud_light");
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
bool depth_test_enabled = ::glIsEnabled(GL_DEPTH_TEST); bool depth_test_enabled = ::glIsEnabled(GL_DEPTH_TEST);
#else
glsafe(::glPushAttrib(GL_DEPTH_TEST));
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
gouraud_shader->start_using(); gouraud_shader->start_using();
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
@ -766,11 +762,9 @@ void GLGizmoSimplify::on_render()
contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix()); contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
const ColorRGBA color = glmodel.get_color(); const ColorRGBA color = glmodel.get_color();
glmodel.set_color(ColorRGBA::WHITE()); glmodel.set_color(ColorRGBA::WHITE());
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile())
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glLineWidth(1.0f));
#if !SLIC3R_OPENGL_ES #if !SLIC3R_OPENGL_ES
if (!OpenGLManager::get_gl_info().is_core_profile())
glsafe(::glLineWidth(1.0f));
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)); glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_LINE));
#endif // !SLIC3R_OPENGL_ES #endif // !SLIC3R_OPENGL_ES
glmodel.render(); glmodel.render();
@ -780,12 +774,8 @@ void GLGizmoSimplify::on_render()
glmodel.set_color(color); glmodel.set_color(color);
contour_shader->stop_using(); contour_shader->stop_using();
} }
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
if (depth_test_enabled) if (depth_test_enabled)
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
#else
glsafe(::glPopAttrib());
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
} }
} }

View File

@ -225,19 +225,11 @@ void InstancesHider::render_cut() const
else else
clipper->set_limiting_plane(ClippingPlane::ClipsNothing()); clipper->set_limiting_plane(ClippingPlane::ClipsNothing());
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
bool depth_test_enabled = ::glIsEnabled(GL_DEPTH_TEST); bool depth_test_enabled = ::glIsEnabled(GL_DEPTH_TEST);
#else
glsafe(::glPushAttrib(GL_DEPTH_TEST));
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
clipper->render_cut(mv->is_model_part() ? ColorRGBA(0.8f, 0.3f, 0.0f, 1.0f) : color_from_model_volume(*mv)); clipper->render_cut(mv->is_model_part() ? ColorRGBA(0.8f, 0.3f, 0.0f, 1.0f) : color_from_model_volume(*mv));
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
if (depth_test_enabled) if (depth_test_enabled)
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
#else
glsafe(::glPopAttrib());
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
++clipper_id; ++clipper_id;
} }

View File

@ -1919,14 +1919,15 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
shader->start_using(); shader->start_using();
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
// Backup GL state // Backup GL state
GLenum last_active_texture; glsafe(::glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture)); GLenum last_active_texture; glsafe(::glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture));
GLuint last_program; glsafe(::glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program)); GLuint last_program; glsafe(::glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program));
GLuint last_texture; glsafe(::glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture)); GLuint last_texture; glsafe(::glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture));
GLuint last_array_buffer; glsafe(::glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer)); GLuint last_array_buffer; glsafe(::glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer));
GLuint last_vertex_array_object = 0; GLuint last_vertex_array_object = 0;
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile())
#endif // !SLIC3R_OPENGL_ES
glsafe(::glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object)); glsafe(::glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object));
GLint last_viewport[4]; glsafe(::glGetIntegerv(GL_VIEWPORT, last_viewport)); GLint last_viewport[4]; glsafe(::glGetIntegerv(GL_VIEWPORT, last_viewport));
GLint last_scissor_box[4]; glsafe(::glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box)); GLint last_scissor_box[4]; glsafe(::glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box));
@ -1951,25 +1952,6 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
glsafe(::glDisable(GL_STENCIL_TEST)); glsafe(::glDisable(GL_STENCIL_TEST));
glsafe(::glEnable(GL_SCISSOR_TEST)); glsafe(::glEnable(GL_SCISSOR_TEST));
#else
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
GLint last_texture; glsafe(::glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
GLint last_polygon_mode[2]; glsafe(::glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode));
GLint last_viewport[4]; glsafe(::glGetIntegerv(GL_VIEWPORT, last_viewport));
GLint last_scissor_box[4]; glsafe(::glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box));
GLint last_texture_env_mode; glsafe(::glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &last_texture_env_mode));
glsafe(::glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT));
glsafe(::glEnable(GL_BLEND));
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
glsafe(::glDisable(GL_CULL_FACE));
glsafe(::glDisable(GL_DEPTH_TEST));
glsafe(::glDisable(GL_STENCIL_TEST));
glsafe(::glEnable(GL_SCISSOR_TEST));
glsafe(::glEnable(GL_TEXTURE_2D));
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_FILL));
glsafe(::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE));
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
// Setup viewport, orthographic projection matrix // Setup viewport, orthographic projection matrix
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
@ -2001,13 +1983,15 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
const GLsizeiptr vtx_buffer_size = (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert); const GLsizeiptr vtx_buffer_size = (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert);
const GLsizeiptr idx_buffer_size = (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx); const GLsizeiptr idx_buffer_size = (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx);
#if ENABLE_GL_CORE_PROFILE
GLuint vao_id = 0; GLuint vao_id = 0;
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) { #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
glsafe(::glGenVertexArrays(1, &vao_id)); glsafe(::glGenVertexArrays(1, &vao_id));
glsafe(::glBindVertexArray(vao_id)); glsafe(::glBindVertexArray(vao_id));
#if !SLIC3R_OPENGL_ES
} }
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
GLuint vbo_id; GLuint vbo_id;
glsafe(::glGenBuffers(1, &vbo_id)); glsafe(::glGenBuffers(1, &vbo_id));
@ -2069,17 +2053,22 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
glsafe(::glDeleteBuffers(1, &ibo_id)); glsafe(::glDeleteBuffers(1, &ibo_id));
glsafe(::glDeleteBuffers(1, &vbo_id)); glsafe(::glDeleteBuffers(1, &vbo_id));
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
if (vao_id > 0) if (vao_id > 0)
glsafe(::glDeleteVertexArrays(1, &vao_id)); glsafe(::glDeleteVertexArrays(1, &vao_id));
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
} }
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
// Restore modified GL state // Restore modified GL state
glsafe(::glBindTexture(GL_TEXTURE_2D, last_texture)); glsafe(::glBindTexture(GL_TEXTURE_2D, last_texture));
glsafe(::glActiveTexture(last_active_texture)); glsafe(::glActiveTexture(last_active_texture));
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile())
#endif // !SLIC3R_OPENGL_ES
glsafe(::glBindVertexArray(last_vertex_array_object)); glsafe(::glBindVertexArray(last_vertex_array_object));
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer));
glsafe(::glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha)); glsafe(::glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha));
@ -2091,16 +2080,6 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
if (last_enable_scissor_test) glsafe(::glEnable(GL_SCISSOR_TEST)); else glsafe(::glDisable(GL_SCISSOR_TEST)); if (last_enable_scissor_test) glsafe(::glEnable(GL_SCISSOR_TEST)); else glsafe(::glDisable(GL_SCISSOR_TEST));
glsafe(::glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3])); glsafe(::glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]));
glsafe(::glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3])); glsafe(::glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]));
#else
// Restore modified state
glsafe(::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, last_texture_env_mode));
glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture));
glsafe(::glPopAttrib());
glsafe(::glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]);
glsafe(::glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1])));
glsafe(::glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]));
glsafe(::glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]));
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
shader->stop_using(); shader->stop_using();

View File

@ -6,9 +6,9 @@
#include "OpenGLManager.hpp" #include "OpenGLManager.hpp"
#include "GUI.hpp" #include "GUI.hpp"
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
#include "GUI_Init.hpp" #include "GUI_Init.hpp"
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
#include "I18N.hpp" #include "I18N.hpp"
#include "3DScene.hpp" #include "3DScene.hpp"
#include "format.hpp" #include "format.hpp"
@ -207,9 +207,9 @@ std::string OpenGLManager::GLInfo::to_string(bool for_github) const
out << h2_start << "OpenGL installation" << h2_end << line_end; out << h2_start << "OpenGL installation" << h2_end << line_end;
out << b_start << "GL version: " << b_end << m_version << " (" << m_version_string << ")" << line_end; out << b_start << "GL version: " << b_end << m_version << " (" << m_version_string << ")" << line_end;
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
out << b_start << "Profile: " << b_end << (is_core_profile() ? "Core" : "Compatibility") << line_end; out << b_start << "Profile: " << b_end << (is_core_profile() ? "Core" : "Compatibility") << line_end;
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
out << b_start << "Vendor: " << b_end << m_vendor << line_end; out << b_start << "Vendor: " << b_end << m_vendor << line_end;
out << b_start << "Renderer: " << b_end << m_renderer << line_end; out << b_start << "Renderer: " << b_end << m_renderer << line_end;
out << b_start << "GLSL version: " << b_end << m_glsl_version << line_end; out << b_start << "GLSL version: " << b_end << m_glsl_version << line_end;
@ -219,13 +219,13 @@ std::string OpenGLManager::GLInfo::to_string(bool for_github) const
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES #endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
{ {
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
std::vector<std::string> extensions_list = get_extensions_list();
#else
const std::string extensions_str = gl_get_string_safe(GL_EXTENSIONS, ""); const std::string extensions_str = gl_get_string_safe(GL_EXTENSIONS, "");
std::vector<std::string> extensions_list; std::vector<std::string> extensions_list;
boost::split(extensions_list, extensions_str, boost::is_any_of(" "), boost::token_compress_on); boost::split(extensions_list, extensions_str, boost::is_any_of(" "), boost::token_compress_on);
#endif // ENABLE_GL_CORE_PROFILE #else
std::vector<std::string> extensions_list = get_extensions_list();
#endif // SLIC3R_OPENGL_ES
if (!extensions_list.empty()) { if (!extensions_list.empty()) {
if (for_github) if (for_github)
@ -246,7 +246,7 @@ std::string OpenGLManager::GLInfo::to_string(bool for_github) const
return out.str(); return out.str();
} }
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
std::vector<std::string> OpenGLManager::GLInfo::get_extensions_list() const std::vector<std::string> OpenGLManager::GLInfo::get_extensions_list() const
{ {
std::vector<std::string> ret; std::vector<std::string> ret;
@ -269,7 +269,7 @@ std::vector<std::string> OpenGLManager::GLInfo::get_extensions_list() const
return ret; return ret;
} }
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
OpenGLManager::GLInfo OpenGLManager::s_gl_info; OpenGLManager::GLInfo OpenGLManager::s_gl_info;
bool OpenGLManager::s_compressed_textures_supported = false; bool OpenGLManager::s_compressed_textures_supported = false;
@ -299,7 +299,7 @@ OpenGLManager::~OpenGLManager()
#endif //__APPLE__ #endif //__APPLE__
} }
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
#ifdef _WIN32 #ifdef _WIN32
static void APIENTRY CustomGLDebugOutput(GLenum source, GLenum type, unsigned int id, GLenum severity, GLsizei length, const char* message, const void* userParam) static void APIENTRY CustomGLDebugOutput(GLenum source, GLenum type, unsigned int id, GLenum severity, GLsizei length, const char* message, const void* userParam)
#else #else
@ -343,26 +343,22 @@ static void CustomGLDebugOutput(GLenum source, GLenum type, unsigned int id, GLe
out += "]:\n"; out += "]:\n";
std::cout << out << "(" << id << "): " << message << "\n\n"; std::cout << out << "(" << id << "): " << message << "\n\n";
} }
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
bool OpenGLManager::init_gl() bool OpenGLManager::init_gl()
{ {
if (!m_gl_initialized) { if (!m_gl_initialized) {
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
glewExperimental = true; glewExperimental = true;
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
GLenum err = glewInit(); GLenum err = glewInit();
if (err != GLEW_OK) { if (err != GLEW_OK) {
BOOST_LOG_TRIVIAL(error) << "Unable to init glew library: " << glewGetErrorString(err); BOOST_LOG_TRIVIAL(error) << "Unable to init glew library: " << glewGetErrorString(err);
return false; return false;
} }
#if ENABLE_GL_CORE_PROFILE
do { do {
// glewInit() generates an OpenGL GL_INVALID_ENUM error // glewInit() generates an OpenGL GL_INVALID_ENUM error
err = ::glGetError(); err = ::glGetError();
} while (err != GL_NO_ERROR); } while (err != GL_NO_ERROR);
#endif // ENABLE_GL_CORE_PROFILE
m_gl_initialized = true; m_gl_initialized = true;
@ -379,24 +375,19 @@ bool OpenGLManager::init_gl()
s_framebuffers_type = EFramebufferType::Unknown; s_framebuffers_type = EFramebufferType::Unknown;
#if SLIC3R_OPENGL_ES #if SLIC3R_OPENGL_ES
bool valid_version = s_gl_info.is_version_greater_or_equal_to(2, 0); bool valid_version = s_gl_info.is_version_greater_or_equal_to(3, 0);
#elif ENABLE_GL_CORE_PROFILE
const bool valid_version = s_gl_info.is_version_greater_or_equal_to(3, 2);
#else #else
bool valid_version = s_gl_info.is_version_greater_or_equal_to(2, 0); const bool valid_version = s_gl_info.is_version_greater_or_equal_to(3, 2);
#endif // SLIC3R_OPENGL_ES #endif // SLIC3R_OPENGL_ES
if (!valid_version) { if (!valid_version) {
// Complain about the OpenGL version. // Complain about the OpenGL version.
wxString message = format_wxstr( wxString message = format_wxstr(
#if SLIC3R_OPENGL_ES #if SLIC3R_OPENGL_ES
_L("PrusaSlicer requires OpenGL ES 2.0 capable graphics driver to run correctly, \n" _L("PrusaSlicer requires OpenGL ES 3.0 capable graphics driver to run correctly, \n"
"while OpenGL version %s, render %s, vendor %s was detected."), s_gl_info.get_version_string(), s_gl_info.get_renderer(), s_gl_info.get_vendor());
#elif ENABLE_GL_CORE_PROFILE
_L("PrusaSlicer requires OpenGL 3.2 capable graphics driver to run correctly,\n"
"while OpenGL version %s, render %s, vendor %s was detected."), s_gl_info.get_version_string(), s_gl_info.get_renderer(), s_gl_info.get_vendor()); "while OpenGL version %s, render %s, vendor %s was detected."), s_gl_info.get_version_string(), s_gl_info.get_renderer(), s_gl_info.get_vendor());
#else #else
_L("PrusaSlicer requires OpenGL 2.0 capable graphics driver to run correctly, \n" _L("PrusaSlicer requires OpenGL 3.2 capable graphics driver to run correctly,\n"
"while OpenGL version %s, render %s, vendor %s was detected."), s_gl_info.get_version_string(), s_gl_info.get_renderer(), s_gl_info.get_vendor()); "while OpenGL version %s, render %s, vendor %s was detected."), s_gl_info.get_version_string(), s_gl_info.get_renderer(), s_gl_info.get_vendor());
#endif // SLIC3R_OPENGL_ES #endif // SLIC3R_OPENGL_ES
message += "\n"; message += "\n";
@ -415,7 +406,7 @@ bool OpenGLManager::init_gl()
wxString message = format_wxstr(_L("Unable to load the following shaders:\n%s"), error); wxString message = format_wxstr(_L("Unable to load the following shaders:\n%s"), error);
wxMessageBox(message, wxString("PrusaSlicer - ") + _L("Error loading shaders"), wxOK | wxICON_ERROR); wxMessageBox(message, wxString("PrusaSlicer - ") + _L("Error loading shaders"), wxOK | wxICON_ERROR);
} }
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (m_debug_enabled && s_gl_info.is_version_greater_or_equal_to(4, 3) && GLEW_KHR_debug) { if (m_debug_enabled && s_gl_info.is_version_greater_or_equal_to(4, 3) && GLEW_KHR_debug) {
::glEnable(GL_DEBUG_OUTPUT); ::glEnable(GL_DEBUG_OUTPUT);
::glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); ::glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
@ -423,7 +414,7 @@ bool OpenGLManager::init_gl()
::glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE); ::glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
std::cout << "Enabled OpenGL debug output\n"; std::cout << "Enabled OpenGL debug output\n";
} }
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
} }
#ifdef _WIN32 #ifdef _WIN32
@ -449,19 +440,19 @@ bool OpenGLManager::init_gl()
return true; return true;
} }
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas)
#else
wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas, const std::pair<int, int>& required_opengl_version, bool enable_compatibility_profile, wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas, const std::pair<int, int>& required_opengl_version, bool enable_compatibility_profile,
bool enable_debug) bool enable_debug)
#else #endif // SLIC3R_OPENGL_ES
wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas)
#endif // ENABLE_GL_CORE_PROFILE
{ {
if (m_context == nullptr) { if (m_context == nullptr) {
#if SLIC3R_OPENGL_ES #if SLIC3R_OPENGL_ES
wxGLContextAttrs attrs; wxGLContextAttrs attrs;
attrs.PlatformDefaults().ES2().MajorVersion(2).EndList(); attrs.PlatformDefaults().ES2().MajorVersion(2).EndList();
m_context = new wxGLContext(&canvas, nullptr, &attrs); m_context = new wxGLContext(&canvas, nullptr, &attrs);
#elif ENABLE_GL_CORE_PROFILE #else
m_debug_enabled = enable_debug; m_debug_enabled = enable_debug;
const int gl_major = required_opengl_version.first; const int gl_major = required_opengl_version.first;
@ -531,8 +522,6 @@ wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas)
// if no valid context was created use the default one // if no valid context was created use the default one
m_context = new wxGLContext(&canvas, nullptr, &attrs); m_context = new wxGLContext(&canvas, nullptr, &attrs);
} }
#else
m_context = new wxGLContext(&canvas);
#endif // SLIC3R_OPENGL_ES #endif // SLIC3R_OPENGL_ES
#ifdef __APPLE__ #ifdef __APPLE__
@ -551,7 +540,6 @@ wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent, bool enable_auto_
wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent) wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent)
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES #endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
{ {
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
wxGLAttributes attribList; wxGLAttributes attribList;
#if ENABLE_OPENGL_AUTO_AA_SAMPLES #if ENABLE_OPENGL_AUTO_AA_SAMPLES
s_multisample = EMultisampleState::Disabled; s_multisample = EMultisampleState::Disabled;
@ -574,23 +562,6 @@ wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent)
// on MAC the method RGBA() has no effect // on MAC the method RGBA() has no effect
attribList.SetNeedsARB(true); attribList.SetNeedsARB(true);
#endif // __APPLE__ #endif // __APPLE__
#else
int attribList[] = {
WX_GL_RGBA,
WX_GL_DOUBLEBUFFER,
// RGB channels each should be allocated with 8 bit depth. One should almost certainly get these bit depths by default.
WX_GL_MIN_RED, 8,
WX_GL_MIN_GREEN, 8,
WX_GL_MIN_BLUE, 8,
// Requesting an 8 bit alpha channel. Interestingly, the NVIDIA drivers would most likely work with some alpha plane, but glReadPixels would not return
// the alpha channel on NVIDIA if not requested when the GL context is created.
WX_GL_MIN_ALPHA, 8,
WX_GL_DEPTH_SIZE, 24,
WX_GL_SAMPLE_BUFFERS, GL_TRUE,
WX_GL_SAMPLES, 4,
0
};
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
#if ENABLE_OPENGL_AUTO_AA_SAMPLES #if ENABLE_OPENGL_AUTO_AA_SAMPLES
if (s_multisample != EMultisampleState::Enabled) if (s_multisample != EMultisampleState::Enabled)
@ -600,7 +571,6 @@ wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent)
if (!can_multisample()) if (!can_multisample())
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES #endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
{ {
attribList.Reset(); attribList.Reset();
attribList.PlatformDefaults().RGBA().DoubleBuffer().MinRGBA(8, 8, 8, 8).Depth(24).EndList(); attribList.PlatformDefaults().RGBA().DoubleBuffer().MinRGBA(8, 8, 8, 8).Depth(24).EndList();
@ -611,19 +581,10 @@ wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent)
} }
return new wxGLCanvas(&parent, attribList, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS); return new wxGLCanvas(&parent, attribList, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
#else
attribList[12] = 0;
return new wxGLCanvas(&parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
} }
#if !ENABLE_OPENGL_AUTO_AA_SAMPLES #if !ENABLE_OPENGL_AUTO_AA_SAMPLES
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
void OpenGLManager::detect_multisample(const wxGLAttributes& attribList) void OpenGLManager::detect_multisample(const wxGLAttributes& attribList)
#else
void OpenGLManager::detect_multisample(int* attribList)
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
{ {
int wxVersion = wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + wxRELEASE_NUMBER; int wxVersion = wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + wxRELEASE_NUMBER;
bool enable_multisample = wxVersion >= 30003; bool enable_multisample = wxVersion >= 30003;

View File

@ -10,9 +10,7 @@
class wxWindow; class wxWindow;
class wxGLCanvas; class wxGLCanvas;
class wxGLContext; class wxGLContext;
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
class wxGLAttributes; class wxGLAttributes;
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@ -77,9 +75,9 @@ public:
// Otherwise HTML formatted for the system info dialog. // Otherwise HTML formatted for the system info dialog.
std::string to_string(bool for_github) const; std::string to_string(bool for_github) const;
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
std::vector<std::string> get_extensions_list() const; std::vector<std::string> get_extensions_list() const;
#endif // ENABLE_GL_CORE_PROFILE #endif // !SLIC3R_OPENGL_ES
private: private:
void detect() const; void detect() const;
@ -123,11 +121,11 @@ public:
~OpenGLManager(); ~OpenGLManager();
bool init_gl(); bool init_gl();
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
wxGLContext* init_glcontext(wxGLCanvas& canvas, const std::pair<int, int>& required_opengl_version, bool enable_compatibility_profile, bool enable_debug);
#else
wxGLContext* init_glcontext(wxGLCanvas& canvas); wxGLContext* init_glcontext(wxGLCanvas& canvas);
#endif // ENABLE_GL_CORE_PROFILE #else
wxGLContext* init_glcontext(wxGLCanvas& canvas, const std::pair<int, int>& required_opengl_version, bool enable_compatibility_profile, bool enable_debug);
#endif // SLIC3R_OPENGL_ES
GLShaderProgram* get_shader(const std::string& shader_name) { return m_shaders_manager.get_shader(shader_name); } GLShaderProgram* get_shader(const std::string& shader_name) { return m_shaders_manager.get_shader(shader_name); }
GLShaderProgram* get_current_shader() { return m_shaders_manager.get_current_shader(); } GLShaderProgram* get_current_shader() { return m_shaders_manager.get_current_shader(); }
@ -146,11 +144,7 @@ public:
private: private:
#if !ENABLE_OPENGL_AUTO_AA_SAMPLES #if !ENABLE_OPENGL_AUTO_AA_SAMPLES
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
static void detect_multisample(const wxGLAttributes& attribList); static void detect_multisample(const wxGLAttributes& attribList);
#else
static void detect_multisample(int* attribList);
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
#endif // !ENABLE_OPENGL_AUTO_AA_SAMPLES #endif // !ENABLE_OPENGL_AUTO_AA_SAMPLES
}; };

View File

@ -2267,15 +2267,14 @@ void Selection::render_bounding_box(const BoundingBoxf3& box, const Transform3d&
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
GLShaderProgram* shader = wxGetApp().get_shader("dashed_lines");
#else
if (!OpenGLManager::get_gl_info().is_core_profile()) if (!OpenGLManager::get_gl_info().is_core_profile())
glsafe(::glLineWidth(2.0f * m_scale_factor)); glsafe(::glLineWidth(2.0f * m_scale_factor));
GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat"); GLShaderProgram* shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
#else #endif // SLIC3R_OPENGL_ES
glsafe(::glLineWidth(2.0f * m_scale_factor));
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -2283,12 +2282,16 @@ void Selection::render_bounding_box(const BoundingBoxf3& box, const Transform3d&
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * trafo); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * trafo);
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#if ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
if (OpenGLManager::get_gl_info().is_core_profile()) {
#endif // !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = camera.get_viewport(); const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3]))); shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 1.5f); shader->set_uniform("width", 1.5f);
shader->set_uniform("gap_size", 0.0f); shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE #if !SLIC3R_OPENGL_ES
}
#endif // !SLIC3R_OPENGL_ES
m_box.set_color(to_rgba(color)); m_box.set_color(to_rgba(color));
m_box.render(); m_box.render();
shader->stop_using(); shader->stop_using();

View File

@ -59,10 +59,10 @@ static const std::string SEND_SYSTEM_INFO_DOMAIN = "prusa3d.com";
static const std::string SEND_SYSTEM_INFO_URL = "https://files." + SEND_SYSTEM_INFO_DOMAIN + "/wp-json/v1/ps"; static const std::string SEND_SYSTEM_INFO_URL = "https://files." + SEND_SYSTEM_INFO_DOMAIN + "/wp-json/v1/ps";
#if !ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
// Declaration of a free function defined in OpenGLManager.cpp: // Declaration of a free function defined in OpenGLManager.cpp:
std::string gl_get_string_safe(GLenum param, const std::string& default_value); std::string gl_get_string_safe(GLenum param, const std::string& default_value);
#endif // !ENABLE_GL_CORE_PROFILE #endif // SLIC3R_OPENGL_ES
// A dialog with the information text and buttons send/dont send/ask later. // A dialog with the information text and buttons send/dont send/ask later.
@ -513,13 +513,13 @@ static std::string generate_system_info_json()
opengl_node.put("Vendor", OpenGLManager::get_gl_info().get_vendor()); opengl_node.put("Vendor", OpenGLManager::get_gl_info().get_vendor());
opengl_node.put("Renderer", OpenGLManager::get_gl_info().get_renderer()); opengl_node.put("Renderer", OpenGLManager::get_gl_info().get_renderer());
// Generate list of OpenGL extensions: // Generate list of OpenGL extensions:
#if ENABLE_GL_CORE_PROFILE #if SLIC3R_OPENGL_ES
std::vector<std::string> extensions_list = OpenGLManager::get_gl_info().get_extensions_list();
#else
std::string extensions_str = gl_get_string_safe(GL_EXTENSIONS, ""); std::string extensions_str = gl_get_string_safe(GL_EXTENSIONS, "");
std::vector<std::string> extensions_list; std::vector<std::string> extensions_list;
boost::split(extensions_list, extensions_str, boost::is_any_of(" "), boost::token_compress_off); boost::split(extensions_list, extensions_str, boost::is_any_of(" "), boost::token_compress_off);
#endif // ENABLE_GL_CORE_PROFILE #else
std::vector<std::string> extensions_list = OpenGLManager::get_gl_info().get_extensions_list();
#endif // SLIC3R_OPENGL_ES
std::sort(extensions_list.begin(), extensions_list.end()); std::sort(extensions_list.begin(), extensions_list.end());
pt::ptree extensions_node; pt::ptree extensions_node;
for (const std::string& s : extensions_list) { for (const std::string& s : extensions_list) {