mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 15:45:52 +08:00
Tech ENABLE_OPENGL_ES replaced by build option SLIC3R_OPENGL_ES
This commit is contained in:
parent
dbeea5dd0e
commit
1112fca688
@ -41,7 +41,11 @@ option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1)
|
|||||||
option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 1)
|
option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 1)
|
||||||
option(SLIC3R_ASAN "Enable ASan on Clang and GCC" 0)
|
option(SLIC3R_ASAN "Enable ASan on Clang and GCC" 0)
|
||||||
option(SLIC3R_UBSAN "Enable UBSan on Clang and GCC" 0)
|
option(SLIC3R_UBSAN "Enable UBSan on Clang and GCC" 0)
|
||||||
option(SLIC3R_ENABLE_FORMAT_STEP "Enable compilation of STEP file support" 1)
|
option(SLIC3R_ENABLE_FORMAT_STEP "Enable compilation of STEP file support" ON)
|
||||||
|
|
||||||
|
# SLIC3R_OPENGL_ES can be enabled only if SLIC3R_GUI is enabled.
|
||||||
|
CMAKE_DEPENDENT_OPTION(SLIC3R_OPENGL_ES "Compile PrusaSlicer targeting OpenGL ES" OFF "SLIC3R_GUI" OFF)
|
||||||
|
|
||||||
# If SLIC3R_FHS is 1 -> SLIC3R_DESKTOP_INTEGRATION is always 0, otherwise variable.
|
# If SLIC3R_FHS is 1 -> SLIC3R_DESKTOP_INTEGRATION is always 0, otherwise variable.
|
||||||
CMAKE_DEPENDENT_OPTION(SLIC3R_DESKTOP_INTEGRATION "Allow perfoming desktop integration during runtime" 1 "NOT SLIC3R_FHS" 0)
|
CMAKE_DEPENDENT_OPTION(SLIC3R_DESKTOP_INTEGRATION "Allow perfoming desktop integration during runtime" 1 "NOT SLIC3R_FHS" 0)
|
||||||
|
|
||||||
@ -98,6 +102,10 @@ if (SLIC3R_GUI)
|
|||||||
add_definitions(-DSLIC3R_GUI)
|
add_definitions(-DSLIC3R_GUI)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (SLIC3R_OPENGL_ES)
|
||||||
|
add_definitions(-DSLIC3R_OPENGL_ES)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(SLIC3R_DESKTOP_INTEGRATION)
|
if(SLIC3R_DESKTOP_INTEGRATION)
|
||||||
add_definitions(-DSLIC3R_DESKTOP_INTEGRATION)
|
add_definitions(-DSLIC3R_DESKTOP_INTEGRATION)
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -47,10 +47,8 @@
|
|||||||
// Enable smoothing of objects normals
|
// Enable smoothing of objects normals
|
||||||
#define ENABLE_SMOOTH_NORMALS 0
|
#define ENABLE_SMOOTH_NORMALS 0
|
||||||
|
|
||||||
// Enable OpenGL ES
|
|
||||||
#define ENABLE_OPENGL_ES 0
|
|
||||||
// Enable OpenGL core profile context (tested against Mesa 20.1.8 on Windows)
|
// Enable OpenGL core profile context (tested against Mesa 20.1.8 on Windows)
|
||||||
#define ENABLE_GL_CORE_PROFILE (1 && !ENABLE_OPENGL_ES)
|
#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
|
||||||
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13)
|
|||||||
project(libvgcode)
|
project(libvgcode)
|
||||||
|
|
||||||
# glad library
|
# glad library
|
||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN OR SLIC3R_OPENGL_ES)
|
||||||
set(GLAD_SOURCES
|
set(GLAD_SOURCES
|
||||||
glad/include/glad/gles2.h
|
glad/include/glad/gles2.h
|
||||||
glad/include/KHR/khrplatform.h
|
glad/include/KHR/khrplatform.h
|
||||||
@ -64,7 +64,7 @@ set(LIBVGCODE_SOURCES
|
|||||||
|
|
||||||
add_library(libvgcode STATIC ${LIBVGCODE_SOURCES})
|
add_library(libvgcode STATIC ${LIBVGCODE_SOURCES})
|
||||||
|
|
||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN OR SLIC3R_OPENGL_ES)
|
||||||
add_compile_definitions(ENABLE_OPENGL_ES)
|
add_compile_definitions(ENABLE_OPENGL_ES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ int GLVolumeCollection::load_object_volume(
|
|||||||
return int(this->volumes.size() - 1);
|
return int(this->volumes.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
int GLVolumeCollection::load_wipe_tower_preview(
|
int GLVolumeCollection::load_wipe_tower_preview(
|
||||||
float pos_x, float pos_y, float width, float depth, const std::vector<std::pair<float, float>>& z_and_depth_pairs, float height, float cone_angle,
|
float pos_x, float pos_y, float width, float depth, const std::vector<std::pair<float, float>>& z_and_depth_pairs, float height, float cone_angle,
|
||||||
float rotation_angle, bool size_unknown, float brim_width, TriangleMesh* out_mesh)
|
float rotation_angle, bool size_unknown, float brim_width, TriangleMesh* out_mesh)
|
||||||
@ -501,7 +501,7 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
|||||||
int GLVolumeCollection::load_wipe_tower_preview(
|
int GLVolumeCollection::load_wipe_tower_preview(
|
||||||
float pos_x, float pos_y, float width, float depth, const std::vector<std::pair<float, float>>& z_and_depth_pairs, float height, float cone_angle,
|
float pos_x, float pos_y, float width, float depth, const std::vector<std::pair<float, float>>& z_and_depth_pairs, float height, float cone_angle,
|
||||||
float rotation_angle, bool size_unknown, float brim_width)
|
float rotation_angle, bool size_unknown, float brim_width)
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
{
|
{
|
||||||
if (height == 0.0f)
|
if (height == 0.0f)
|
||||||
height = 0.1f;
|
height = 0.1f;
|
||||||
@ -588,10 +588,10 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
|||||||
|
|
||||||
volumes.emplace_back(new GLVolume(color));
|
volumes.emplace_back(new GLVolume(color));
|
||||||
GLVolume& v = *volumes.back();
|
GLVolume& v = *volumes.back();
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
if (out_mesh != nullptr)
|
if (out_mesh != nullptr)
|
||||||
*out_mesh = mesh;
|
*out_mesh = mesh;
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
v.model.init_from(mesh);
|
v.model.init_from(mesh);
|
||||||
v.model.set_color(color);
|
v.model.set_color(color);
|
||||||
v.mesh_raycaster = std::make_unique<GUI::MeshRaycaster>(std::make_shared<const TriangleMesh>(mesh));
|
v.mesh_raycaster = std::make_unique<GUI::MeshRaycaster>(std::make_shared<const TriangleMesh>(mesh));
|
||||||
|
@ -409,13 +409,13 @@ public:
|
|||||||
int volume_idx,
|
int volume_idx,
|
||||||
int instance_idx);
|
int instance_idx);
|
||||||
|
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
int load_wipe_tower_preview(
|
int load_wipe_tower_preview(
|
||||||
float pos_x, float pos_y, float width, float depth, const std::vector<std::pair<float, float>>& z_and_depth_pairs, float height, float cone_angle, float rotation_angle, bool size_unknown, float brim_width, TriangleMesh* out_mesh = nullptr);
|
float pos_x, float pos_y, float width, float depth, const std::vector<std::pair<float, float>>& z_and_depth_pairs, float height, float cone_angle, float rotation_angle, bool size_unknown, float brim_width, TriangleMesh* out_mesh = nullptr);
|
||||||
#else
|
#else
|
||||||
int load_wipe_tower_preview(
|
int load_wipe_tower_preview(
|
||||||
float pos_x, float pos_y, float width, float depth, const std::vector<std::pair<float, float>>& z_and_depth_pairs, float height, float cone_angle, float rotation_angle, bool size_unknown, float brim_width);
|
float pos_x, float pos_y, float width, float depth, const std::vector<std::pair<float, float>>& z_and_depth_pairs, float height, float cone_angle, float rotation_angle, bool size_unknown, float brim_width);
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
// Load SLA auxiliary GLVolumes (for support trees or pad).
|
// Load SLA auxiliary GLVolumes (for support trees or pad).
|
||||||
void load_object_auxiliary(
|
void load_object_auxiliary(
|
||||||
|
@ -1358,11 +1358,11 @@ bool GLCanvas3D::init()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
glsafe(::glClearColor(1.0f, 1.0f, 1.0f, 1.0f));
|
glsafe(::glClearColor(1.0f, 1.0f, 1.0f, 1.0f));
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
glsafe(::glClearDepthf(1.0f));
|
glsafe(::glClearDepthf(1.0f));
|
||||||
#else
|
#else
|
||||||
glsafe(::glClearDepth(1.0f));
|
glsafe(::glClearDepth(1.0f));
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
glsafe(::glDepthFunc(GL_LESS));
|
glsafe(::glDepthFunc(GL_LESS));
|
||||||
|
|
||||||
@ -2210,9 +2210,9 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||||||
if (volume->is_wipe_tower) {
|
if (volume->is_wipe_tower) {
|
||||||
// There is only one wipe tower.
|
// There is only one wipe tower.
|
||||||
assert(volume_idx_wipe_tower_old == -1);
|
assert(volume_idx_wipe_tower_old == -1);
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
m_wipe_tower_mesh.clear();
|
m_wipe_tower_mesh.clear();
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
volume_idx_wipe_tower_old = (int)volume_id;
|
volume_idx_wipe_tower_old = (int)volume_id;
|
||||||
}
|
}
|
||||||
if (!m_reload_delayed) {
|
if (!m_reload_delayed) {
|
||||||
@ -2394,15 +2394,15 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||||||
const double height = height_real < 0.f ? std::max(m_model->max_z(), 10.0) : height_real;
|
const double height = height_real < 0.f ? std::max(m_model->max_z(), 10.0) : height_real;
|
||||||
|
|
||||||
if (depth != 0.) {
|
if (depth != 0.) {
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
int volume_idx_wipe_tower_new = m_volumes.load_wipe_tower_preview(
|
int volume_idx_wipe_tower_new = m_volumes.load_wipe_tower_preview(
|
||||||
x, y, w, depth, z_and_depth_pairs, (float)height, ca, a, !print->is_step_done(psWipeTower),
|
x, y, w, depth, z_and_depth_pairs, (float)height, ca, a, !print->is_step_done(psWipeTower),
|
||||||
bw, &m_wipe_tower_mesh);
|
bw, &m_wipe_tower_mesh);
|
||||||
#else
|
#else
|
||||||
int volume_idx_wipe_tower_new = m_volumes.load_wipe_tower_preview(
|
int volume_idx_wipe_tower_new = m_volumes.load_wipe_tower_preview(
|
||||||
x, y, w, depth, z_and_depth_pairs, (float)height, ca, a, !print->is_step_done(psWipeTower),
|
x, y, w, depth, z_and_depth_pairs, (float)height, ca, a, !print->is_step_done(psWipeTower),
|
||||||
bw);
|
bw);
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
if (volume_idx_wipe_tower_old != -1)
|
if (volume_idx_wipe_tower_old != -1)
|
||||||
map_glvolume_old_to_new[volume_idx_wipe_tower_old] = volume_idx_wipe_tower_new;
|
map_glvolume_old_to_new[volume_idx_wipe_tower_old] = volume_idx_wipe_tower_new;
|
||||||
}
|
}
|
||||||
@ -5590,11 +5590,11 @@ void GLCanvas3D::_rectangular_selection_picking_pass()
|
|||||||
glsafe(::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, render_tex, 0));
|
glsafe(::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, render_tex, 0));
|
||||||
glsafe(::glGenRenderbuffers(1, &render_depth));
|
glsafe(::glGenRenderbuffers(1, &render_depth));
|
||||||
glsafe(::glBindRenderbuffer(GL_RENDERBUFFER, render_depth));
|
glsafe(::glBindRenderbuffer(GL_RENDERBUFFER, render_depth));
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
glsafe(::glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height));
|
glsafe(::glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height));
|
||||||
#else
|
#else
|
||||||
glsafe(::glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height));
|
glsafe(::glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height));
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
glsafe(::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, render_depth));
|
glsafe(::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, render_depth));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -506,9 +506,9 @@ private:
|
|||||||
bool m_event_handlers_bound{ false };
|
bool m_event_handlers_bound{ false };
|
||||||
|
|
||||||
GLVolumeCollection m_volumes;
|
GLVolumeCollection m_volumes;
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
TriangleMesh m_wipe_tower_mesh;
|
TriangleMesh m_wipe_tower_mesh;
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
GCodeViewer m_gcode_viewer;
|
GCodeViewer m_gcode_viewer;
|
||||||
|
|
||||||
RenderTimer m_render_timer;
|
RenderTimer m_render_timer;
|
||||||
|
@ -108,7 +108,6 @@ void GLModel::Geometry::add_vertex(const Vec3f& position, const Vec3f& normal, c
|
|||||||
vertices.emplace_back(tex_coord.y());
|
vertices.emplace_back(tex_coord.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
void GLModel::Geometry::add_vertex(const Vec3f& position, const Vec3f& normal, const Vec3f& extra)
|
void GLModel::Geometry::add_vertex(const Vec3f& position, const Vec3f& normal, const Vec3f& extra)
|
||||||
{
|
{
|
||||||
assert(format.vertex_layout == EVertexLayout::P3N3E3);
|
assert(format.vertex_layout == EVertexLayout::P3N3E3);
|
||||||
@ -122,7 +121,6 @@ void GLModel::Geometry::add_vertex(const Vec3f& position, const Vec3f& normal, c
|
|||||||
vertices.emplace_back(extra.y());
|
vertices.emplace_back(extra.y());
|
||||||
vertices.emplace_back(extra.z());
|
vertices.emplace_back(extra.z());
|
||||||
}
|
}
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
|
|
||||||
void GLModel::Geometry::add_vertex(const Vec4f& position)
|
void GLModel::Geometry::add_vertex(const Vec4f& position)
|
||||||
{
|
{
|
||||||
@ -279,9 +277,7 @@ size_t GLModel::Geometry::vertex_stride_floats(const Format& format)
|
|||||||
case EVertexLayout::P3T2: { return 5; }
|
case EVertexLayout::P3T2: { return 5; }
|
||||||
case EVertexLayout::P3N3: { return 6; }
|
case EVertexLayout::P3N3: { return 6; }
|
||||||
case EVertexLayout::P3N3T2: { return 8; }
|
case EVertexLayout::P3N3T2: { return 8; }
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P3N3E3: { return 9; }
|
case EVertexLayout::P3N3E3: { return 9; }
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P4: { return 4; }
|
case EVertexLayout::P4: { return 4; }
|
||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
@ -296,12 +292,8 @@ size_t GLModel::Geometry::position_stride_floats(const Format& format)
|
|||||||
case EVertexLayout::P3:
|
case EVertexLayout::P3:
|
||||||
case EVertexLayout::P3T2:
|
case EVertexLayout::P3T2:
|
||||||
case EVertexLayout::P3N3:
|
case EVertexLayout::P3N3:
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P3N3T2:
|
case EVertexLayout::P3N3T2:
|
||||||
case EVertexLayout::P3N3E3: { return 3; }
|
case EVertexLayout::P3N3E3: { return 3; }
|
||||||
#else
|
|
||||||
case EVertexLayout::P3N3T2: { return 3; }
|
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P4: { return 4; }
|
case EVertexLayout::P4: { return 4; }
|
||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
@ -317,9 +309,7 @@ size_t GLModel::Geometry::position_offset_floats(const Format& format)
|
|||||||
case EVertexLayout::P3T2:
|
case EVertexLayout::P3T2:
|
||||||
case EVertexLayout::P3N3:
|
case EVertexLayout::P3N3:
|
||||||
case EVertexLayout::P3N3T2:
|
case EVertexLayout::P3N3T2:
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P3N3E3:
|
case EVertexLayout::P3N3E3:
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P4: { return 0; }
|
case EVertexLayout::P4: { return 0; }
|
||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
@ -330,12 +320,8 @@ size_t GLModel::Geometry::normal_stride_floats(const Format& format)
|
|||||||
switch (format.vertex_layout)
|
switch (format.vertex_layout)
|
||||||
{
|
{
|
||||||
case EVertexLayout::P3N3:
|
case EVertexLayout::P3N3:
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P3N3T2:
|
case EVertexLayout::P3N3T2:
|
||||||
case EVertexLayout::P3N3E3: { return 3; }
|
case EVertexLayout::P3N3E3: { return 3; }
|
||||||
#else
|
|
||||||
case EVertexLayout::P3N3T2: { return 3; }
|
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -345,12 +331,8 @@ size_t GLModel::Geometry::normal_offset_floats(const Format& format)
|
|||||||
switch (format.vertex_layout)
|
switch (format.vertex_layout)
|
||||||
{
|
{
|
||||||
case EVertexLayout::P3N3:
|
case EVertexLayout::P3N3:
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P3N3T2:
|
case EVertexLayout::P3N3T2:
|
||||||
case EVertexLayout::P3N3E3: { return 3; }
|
case EVertexLayout::P3N3E3: { return 3; }
|
||||||
#else
|
|
||||||
case EVertexLayout::P3N3T2: { return 3; }
|
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -377,7 +359,6 @@ size_t GLModel::Geometry::tex_coord_offset_floats(const Format& format)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
size_t GLModel::Geometry::extra_stride_floats(const Format& format)
|
size_t GLModel::Geometry::extra_stride_floats(const Format& format)
|
||||||
{
|
{
|
||||||
switch (format.vertex_layout)
|
switch (format.vertex_layout)
|
||||||
@ -395,7 +376,6 @@ size_t GLModel::Geometry::extra_offset_floats(const Format& format)
|
|||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
|
|
||||||
size_t GLModel::Geometry::index_stride_bytes(const Geometry& data)
|
size_t GLModel::Geometry::index_stride_bytes(const Geometry& data)
|
||||||
{
|
{
|
||||||
@ -418,9 +398,7 @@ bool GLModel::Geometry::has_position(const Format& format)
|
|||||||
case EVertexLayout::P3T2:
|
case EVertexLayout::P3T2:
|
||||||
case EVertexLayout::P3N3:
|
case EVertexLayout::P3N3:
|
||||||
case EVertexLayout::P3N3T2:
|
case EVertexLayout::P3N3T2:
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P3N3E3:
|
case EVertexLayout::P3N3E3:
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P4: { return true; }
|
case EVertexLayout::P4: { return true; }
|
||||||
default: { assert(false); return false; }
|
default: { assert(false); return false; }
|
||||||
};
|
};
|
||||||
@ -436,12 +414,8 @@ bool GLModel::Geometry::has_normal(const Format& format)
|
|||||||
case EVertexLayout::P3T2:
|
case EVertexLayout::P3T2:
|
||||||
case EVertexLayout::P4: { return false; }
|
case EVertexLayout::P4: { return false; }
|
||||||
case EVertexLayout::P3N3:
|
case EVertexLayout::P3N3:
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P3N3T2:
|
case EVertexLayout::P3N3T2:
|
||||||
case EVertexLayout::P3N3E3: { return true; }
|
case EVertexLayout::P3N3E3: { return true; }
|
||||||
#else
|
|
||||||
case EVertexLayout::P3N3T2: { return true; }
|
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
default: { assert(false); return false; }
|
default: { assert(false); return false; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -456,15 +430,12 @@ bool GLModel::Geometry::has_tex_coord(const Format& format)
|
|||||||
case EVertexLayout::P2:
|
case EVertexLayout::P2:
|
||||||
case EVertexLayout::P3:
|
case EVertexLayout::P3:
|
||||||
case EVertexLayout::P3N3:
|
case EVertexLayout::P3N3:
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P3N3E3:
|
case EVertexLayout::P3N3E3:
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
case EVertexLayout::P4: { return false; }
|
case EVertexLayout::P4: { return false; }
|
||||||
default: { assert(false); return false; }
|
default: { assert(false); return false; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
bool GLModel::Geometry::has_extra(const Format& format)
|
bool GLModel::Geometry::has_extra(const Format& format)
|
||||||
{
|
{
|
||||||
switch (format.vertex_layout)
|
switch (format.vertex_layout)
|
||||||
@ -480,7 +451,6 @@ bool GLModel::Geometry::has_extra(const Format& format)
|
|||||||
default: { assert(false); return false; }
|
default: { assert(false); return false; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
|
|
||||||
#if ENABLE_GLMODEL_STATISTICS
|
#if ENABLE_GLMODEL_STATISTICS
|
||||||
GLModel::Statistics GLModel::s_statistics;
|
GLModel::Statistics GLModel::s_statistics;
|
||||||
@ -788,9 +758,7 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
|||||||
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);
|
||||||
const bool tex_coord = Geometry::has_tex_coord(data.format);
|
const bool tex_coord = Geometry::has_tex_coord(data.format);
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
const bool extra = Geometry::has_extra(data.format);
|
const bool extra = Geometry::has_extra(data.format);
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
|
|
||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
|
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
|
||||||
@ -802,9 +770,7 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
|||||||
int position_id = -1;
|
int position_id = -1;
|
||||||
int normal_id = -1;
|
int normal_id = -1;
|
||||||
int tex_coord_id = -1;
|
int tex_coord_id = -1;
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
int extra_id = -1;
|
int extra_id = -1;
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
|
|
||||||
if (position) {
|
if (position) {
|
||||||
position_id = shader->get_attrib_location("v_position");
|
position_id = shader->get_attrib_location("v_position");
|
||||||
@ -827,7 +793,6 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
|||||||
glsafe(::glEnableVertexAttribArray(tex_coord_id));
|
glsafe(::glEnableVertexAttribArray(tex_coord_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
if (extra) {
|
if (extra) {
|
||||||
extra_id = shader->get_attrib_location("v_extra");
|
extra_id = shader->get_attrib_location("v_extra");
|
||||||
if (extra_id != -1) {
|
if (extra_id != -1) {
|
||||||
@ -835,7 +800,6 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
|||||||
glsafe(::glEnableVertexAttribArray(extra_id));
|
glsafe(::glEnableVertexAttribArray(extra_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
|
|
||||||
shader->set_uniform("uniform_color", data.color);
|
shader->set_uniform("uniform_color", data.color);
|
||||||
|
|
||||||
@ -848,10 +812,8 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
|||||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||||
#endif // !ENABLE_GL_CORE_PROFILE
|
#endif // !ENABLE_GL_CORE_PROFILE
|
||||||
|
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
if (extra_id != -1)
|
if (extra_id != -1)
|
||||||
glsafe(::glDisableVertexAttribArray(extra_id));
|
glsafe(::glDisableVertexAttribArray(extra_id));
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
if (tex_coord_id != -1)
|
if (tex_coord_id != -1)
|
||||||
glsafe(::glDisableVertexAttribArray(tex_coord_id));
|
glsafe(::glDisableVertexAttribArray(tex_coord_id));
|
||||||
if (normal_id != -1)
|
if (normal_id != -1)
|
||||||
|
@ -47,9 +47,7 @@ namespace GUI {
|
|||||||
P3T2, // position 3 floats + texture coords 2 floats
|
P3T2, // position 3 floats + texture coords 2 floats
|
||||||
P3N3, // position 3 floats + normal 3 floats
|
P3N3, // position 3 floats + normal 3 floats
|
||||||
P3N3T2, // position 3 floats + normal 3 floats + texture coords 2 floats
|
P3N3T2, // position 3 floats + normal 3 floats + texture coords 2 floats
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
P3N3E3, // position 3 floats + normal 3 floats + extra 3 floats
|
P3N3E3, // position 3 floats + normal 3 floats + extra 3 floats
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
P4, // position 4 floats
|
P4, // position 4 floats
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -87,9 +85,7 @@ namespace GUI {
|
|||||||
vertices.insert(vertices.end(), normal.data(), normal.data() + 3);
|
vertices.insert(vertices.end(), normal.data(), normal.data() + 3);
|
||||||
}
|
}
|
||||||
void add_vertex(const Vec3f& position, const Vec3f& normal, const Vec2f& tex_coord); // EVertexLayout::P3N3T2
|
void add_vertex(const Vec3f& position, const Vec3f& normal, const Vec2f& tex_coord); // EVertexLayout::P3N3T2
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
void add_vertex(const Vec3f& position, const Vec3f& normal, const Vec3f& extra); // EVertexLayout::P3N3E3
|
void add_vertex(const Vec3f& position, const Vec3f& normal, const Vec3f& extra); // EVertexLayout::P3N3E3
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
void add_vertex(const Vec4f& position); // EVertexLayout::P4
|
void add_vertex(const Vec4f& position); // EVertexLayout::P4
|
||||||
|
|
||||||
void set_vertex(size_t id, const Vec3f& position, const Vec3f& normal); // EVertexLayout::P3N3
|
void set_vertex(size_t id, const Vec3f& position, const Vec3f& normal); // EVertexLayout::P3N3
|
||||||
@ -142,21 +138,17 @@ namespace GUI {
|
|||||||
static size_t tex_coord_offset_floats(const Format& format);
|
static size_t tex_coord_offset_floats(const Format& format);
|
||||||
static size_t tex_coord_offset_bytes(const Format& format) { return tex_coord_offset_floats(format) * sizeof(float); }
|
static size_t tex_coord_offset_bytes(const Format& format) { return tex_coord_offset_floats(format) * sizeof(float); }
|
||||||
|
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
static size_t extra_stride_floats(const Format& format);
|
static size_t extra_stride_floats(const Format& format);
|
||||||
static size_t extra_stride_bytes(const Format& format) { return extra_stride_floats(format) * sizeof(float); }
|
static size_t extra_stride_bytes(const Format& format) { return extra_stride_floats(format) * sizeof(float); }
|
||||||
static size_t extra_offset_floats(const Format& format);
|
static size_t extra_offset_floats(const Format& format);
|
||||||
static size_t extra_offset_bytes(const Format& format) { return extra_offset_floats(format) * sizeof(float); }
|
static size_t extra_offset_bytes(const Format& format) { return extra_offset_floats(format) * sizeof(float); }
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
|
|
||||||
static size_t index_stride_bytes(const Geometry& data);
|
static size_t index_stride_bytes(const Geometry& data);
|
||||||
|
|
||||||
static bool has_position(const Format& format);
|
static bool has_position(const Format& format);
|
||||||
static bool has_normal(const Format& format);
|
static bool has_normal(const Format& format);
|
||||||
static bool has_tex_coord(const Format& format);
|
static bool has_tex_coord(const Format& format);
|
||||||
#if ENABLE_OPENGL_ES
|
|
||||||
static bool has_extra(const Format& format);
|
static bool has_extra(const Format& format);
|
||||||
#endif // ENABLE_OPENGL_ES
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RenderData
|
struct RenderData
|
||||||
|
@ -84,7 +84,7 @@ namespace GUI {
|
|||||||
|
|
||||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
#if !ENABLE_OPENGL_ES
|
#if !SLIC3R_OPENGL_ES
|
||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
if (!core_profile) {
|
if (!core_profile) {
|
||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
@ -94,15 +94,15 @@ namespace GUI {
|
|||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#endif // !ENABLE_OPENGL_ES
|
#endif // !SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
#if ENABLE_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
|
#elif ENABLE_GL_CORE_PROFILE
|
||||||
GLShaderProgram* shader = core_profile ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = core_profile ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
|
||||||
#else
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ namespace GUI {
|
|||||||
m_rectangle.reset();
|
m_rectangle.reset();
|
||||||
|
|
||||||
GLModel::Geometry init_data;
|
GLModel::Geometry init_data;
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#if ENABLE_GL_CORE_PROFILE || 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);
|
||||||
@ -120,10 +120,10 @@ namespace GUI {
|
|||||||
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 || ENABLE_OPENGL_ES
|
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
// vertices
|
// vertices
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#if ENABLE_GL_CORE_PROFILE || 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;
|
||||||
@ -154,14 +154,14 @@ 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 || ENABLE_OPENGL_ES
|
#endif // ENABLE_GL_CORE_PROFILE || 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 ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
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);
|
||||||
#elif ENABLE_GL_CORE_PROFILE
|
#elif ENABLE_GL_CORE_PROFILE
|
||||||
@ -172,19 +172,19 @@ namespace GUI {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_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();
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !ENABLE_OPENGL_ES
|
#if !SLIC3R_OPENGL_ES
|
||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
if (!core_profile)
|
if (!core_profile)
|
||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
glsafe(::glPopAttrib());
|
glsafe(::glPopAttrib());
|
||||||
#endif // !ENABLE_OPENGL_ES
|
#endif // !SLIC3R_OPENGL_ES
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
|
@ -40,13 +40,13 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||||||
|
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
|
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
const std::string prefix = "ES/";
|
const std::string prefix = "ES/";
|
||||||
// used to render wireframed triangles
|
// used to render wireframed triangles
|
||||||
valid &= append_shader("wireframe", { prefix + "wireframe.vs", prefix + "wireframe.fs" });
|
valid &= append_shader("wireframe", { prefix + "wireframe.vs", prefix + "wireframe.fs" });
|
||||||
#else
|
#else
|
||||||
const std::string prefix = GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 1) ? "140/" : "110/";
|
const std::string prefix = GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 1) ? "140/" : "110/";
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
// imgui shader
|
// imgui shader
|
||||||
valid &= append_shader("imgui", { prefix + "imgui.vs", prefix + "imgui.fs" });
|
valid &= append_shader("imgui", { prefix + "imgui.vs", prefix + "imgui.fs" });
|
||||||
// basic shader, used to render all what was previously rendered using the immediate mode
|
// basic shader, used to render all what was previously rendered using the immediate mode
|
||||||
@ -57,14 +57,14 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||||||
valid &= append_shader("flat_texture", { prefix + "flat_texture.vs", prefix + "flat_texture.fs" });
|
valid &= append_shader("flat_texture", { prefix + "flat_texture.vs", prefix + "flat_texture.fs" });
|
||||||
// used to render 3D scene background
|
// used to render 3D scene background
|
||||||
valid &= append_shader("background", { prefix + "background.vs", prefix + "background.fs" });
|
valid &= append_shader("background", { prefix + "background.vs", prefix + "background.fs" });
|
||||||
#if ENABLE_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
|
#elif ENABLE_GL_CORE_PROFILE
|
||||||
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" });
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
// used to render toolpaths center of gravity
|
// used to render toolpaths center of gravity
|
||||||
valid &= append_shader("toolpaths_cog", { prefix + "toolpaths_cog.vs", prefix + "toolpaths_cog.fs" });
|
valid &= append_shader("toolpaths_cog", { prefix + "toolpaths_cog.vs", prefix + "toolpaths_cog.fs" });
|
||||||
// used to render bed axes and model, selection hints, gcode sequential view marker model, preview shells, options in gcode preview
|
// used to render bed axes and model, selection hints, gcode sequential view marker model, preview shells, options in gcode preview
|
||||||
|
@ -337,10 +337,10 @@ 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 && !ENABLE_OPENGL_ES
|
#if !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES
|
||||||
glsafe(::glEnable(GL_TEXTURE_2D));
|
glsafe(::glEnable(GL_TEXTURE_2D));
|
||||||
glsafe(::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE));
|
glsafe(::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE));
|
||||||
#endif // !ENABLE_GL_CORE_PROFILE && !ENABLE_OPENGL_ES
|
#endif // !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)tex_id));
|
glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)tex_id));
|
||||||
|
|
||||||
@ -373,9 +373,9 @@ 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 && !ENABLE_OPENGL_ES
|
#if !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES
|
||||||
glsafe(::glDisable(GL_TEXTURE_2D));
|
glsafe(::glDisable(GL_TEXTURE_2D));
|
||||||
#endif // !ENABLE_GL_CORE_PROFILE && !ENABLE_OPENGL_ES
|
#endif // !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES
|
||||||
glsafe(::glDisable(GL_BLEND));
|
glsafe(::glDisable(GL_BLEND));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,12 +158,12 @@ 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 || ENABLE_OPENGL_ES
|
#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
|
#else
|
||||||
const float radius = m_cursor_radius * float(wxGetApp().plater()->get_camera().get_zoom());
|
const float radius = m_cursor_radius * float(wxGetApp().plater()->get_camera().get_zoom());
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
if (!OpenGLManager::get_gl_info().is_core_profile())
|
if (!OpenGLManager::get_gl_info().is_core_profile())
|
||||||
@ -171,13 +171,13 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||||||
glsafe(::glLineWidth(1.5f));
|
glsafe(::glLineWidth(1.5f));
|
||||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
#if !ENABLE_GL_CORE_PROFILE && !ENABLE_OPENGL_ES
|
#if !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES
|
||||||
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 && !ENABLE_OPENGL_ES
|
#endif // !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
if (!m_circle.is_initialized() || std::abs(m_old_cursor_radius - radius) > EPSILON) {
|
if (!m_circle.is_initialized() || std::abs(m_old_cursor_radius - radius) > EPSILON) {
|
||||||
m_old_cursor_radius = radius;
|
m_old_cursor_radius = radius;
|
||||||
m_circle.reset();
|
m_circle.reset();
|
||||||
@ -186,10 +186,10 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||||||
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 || ENABLE_OPENGL_ES
|
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
GLModel::Geometry init_data;
|
GLModel::Geometry init_data;
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
const unsigned int StepsCount = (unsigned int)(2 * (4 + int(252 * (zoom - 1.0f) / (250.0f - 1.0f))));
|
const unsigned int StepsCount = (unsigned int)(2 * (4 + int(252 * (zoom - 1.0f) / (250.0f - 1.0f))));
|
||||||
const float StepSize = 2.0f * float(PI) / float(StepsCount);
|
const float StepSize = 2.0f * float(PI) / float(StepsCount);
|
||||||
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P2 };
|
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P2 };
|
||||||
@ -197,14 +197,14 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||||||
static const unsigned int StepsCount = 32;
|
static const unsigned int StepsCount = 32;
|
||||||
static const float StepSize = 2.0f * float(PI) / float(StepsCount);
|
static const float StepSize = 2.0f * float(PI) / float(StepsCount);
|
||||||
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 || ENABLE_OPENGL_ES
|
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
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(StepsCount);
|
||||||
init_data.reserve_indices(StepsCount);
|
init_data.reserve_indices(StepsCount);
|
||||||
|
|
||||||
// vertices + indices
|
// vertices + indices
|
||||||
for (unsigned int i = 0; i < StepsCount; ++i) {
|
for (unsigned int i = 0; i < StepsCount; ++i) {
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#if ENABLE_GL_CORE_PROFILE || 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) * StepSize;
|
||||||
@ -221,7 +221,7 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||||||
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 || ENABLE_OPENGL_ES
|
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
}
|
}
|
||||||
|
|
||||||
m_circle.init_from(std::move(init_data));
|
m_circle.init_from(std::move(init_data));
|
||||||
@ -234,13 +234,13 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#if ENABLE_GL_CORE_PROFILE || 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
|
#else
|
||||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_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();
|
||||||
@ -252,9 +252,9 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !ENABLE_GL_CORE_PROFILE && !ENABLE_OPENGL_ES
|
#if !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES
|
||||||
glsafe(::glPopAttrib());
|
glsafe(::glPopAttrib());
|
||||||
#endif // !ENABLE_GL_CORE_PROFILE && !ENABLE_OPENGL_ES
|
#endif // !ENABLE_GL_CORE_PROFILE && !SLIC3R_OPENGL_ES
|
||||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,7 +677,7 @@ void GLGizmoSimplify::update_model(const State::Data &data)
|
|||||||
auto color = glmodel.get_color();
|
auto color = glmodel.get_color();
|
||||||
// when not reset it keeps old shape
|
// when not reset it keeps old shape
|
||||||
glmodel.reset();
|
glmodel.reset();
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
GLModel::Geometry init_data;
|
GLModel::Geometry init_data;
|
||||||
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3E3 };
|
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3E3 };
|
||||||
init_data.reserve_vertices(3 * its.indices.size());
|
init_data.reserve_vertices(3 * its.indices.size());
|
||||||
@ -700,7 +700,7 @@ void GLGizmoSimplify::update_model(const State::Data &data)
|
|||||||
glmodel.init_from(std::move(init_data));
|
glmodel.init_from(std::move(init_data));
|
||||||
#else
|
#else
|
||||||
glmodel.init_from(its);
|
glmodel.init_from(its);
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
glmodel.set_color(color);
|
glmodel.set_color(color);
|
||||||
|
|
||||||
m_triangle_count += its.indices.size();
|
m_triangle_count += its.indices.size();
|
||||||
@ -737,11 +737,11 @@ 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 || ENABLE_OPENGL_ES
|
#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
|
#else
|
||||||
glsafe(::glPushAttrib(GL_DEPTH_TEST));
|
glsafe(::glPushAttrib(GL_DEPTH_TEST));
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#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();
|
||||||
@ -755,11 +755,11 @@ void GLGizmoSimplify::on_render()
|
|||||||
gouraud_shader->stop_using();
|
gouraud_shader->stop_using();
|
||||||
|
|
||||||
if (m_show_wireframe) {
|
if (m_show_wireframe) {
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
auto* contour_shader = wxGetApp().get_shader("wireframe");
|
auto* contour_shader = wxGetApp().get_shader("wireframe");
|
||||||
#else
|
#else
|
||||||
auto *contour_shader = wxGetApp().get_shader("mm_contour");
|
auto *contour_shader = wxGetApp().get_shader("mm_contour");
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
contour_shader->start_using();
|
contour_shader->start_using();
|
||||||
contour_shader->set_uniform("offset", OpenGLManager::get_gl_info().is_mesa() ? 0.0005 : 0.00001);
|
contour_shader->set_uniform("offset", OpenGLManager::get_gl_info().is_mesa() ? 0.0005 : 0.00001);
|
||||||
contour_shader->set_uniform("view_model_matrix", view_model_matrix);
|
contour_shader->set_uniform("view_model_matrix", view_model_matrix);
|
||||||
@ -770,22 +770,22 @@ void GLGizmoSimplify::on_render()
|
|||||||
if (!OpenGLManager::get_gl_info().is_core_profile())
|
if (!OpenGLManager::get_gl_info().is_core_profile())
|
||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
glsafe(::glLineWidth(1.0f));
|
glsafe(::glLineWidth(1.0f));
|
||||||
#if !ENABLE_OPENGL_ES
|
#if !SLIC3R_OPENGL_ES
|
||||||
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_LINE));
|
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_LINE));
|
||||||
#endif // !ENABLE_OPENGL_ES
|
#endif // !SLIC3R_OPENGL_ES
|
||||||
glmodel.render();
|
glmodel.render();
|
||||||
#if !ENABLE_OPENGL_ES
|
#if !SLIC3R_OPENGL_ES
|
||||||
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_FILL));
|
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_FILL));
|
||||||
#endif // !ENABLE_OPENGL_ES
|
#endif // !SLIC3R_OPENGL_ES
|
||||||
glmodel.set_color(color);
|
glmodel.set_color(color);
|
||||||
contour_shader->stop_using();
|
contour_shader->stop_using();
|
||||||
}
|
}
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#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
|
#else
|
||||||
glsafe(::glPopAttrib());
|
glsafe(::glPopAttrib());
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,19 +225,19 @@ void InstancesHider::render_cut() const
|
|||||||
else
|
else
|
||||||
clipper->set_limiting_plane(ClippingPlane::ClipsNothing());
|
clipper->set_limiting_plane(ClippingPlane::ClipsNothing());
|
||||||
|
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#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
|
#else
|
||||||
glsafe(::glPushAttrib(GL_DEPTH_TEST));
|
glsafe(::glPushAttrib(GL_DEPTH_TEST));
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#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 || ENABLE_OPENGL_ES
|
#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
|
#else
|
||||||
glsafe(::glPopAttrib());
|
glsafe(::glPopAttrib());
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
++clipper_id;
|
++clipper_id;
|
||||||
}
|
}
|
||||||
|
@ -1919,7 +1919,7 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
|
|||||||
|
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#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));
|
||||||
@ -1969,7 +1969,7 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
|
|||||||
glsafe(::glEnable(GL_TEXTURE_2D));
|
glsafe(::glEnable(GL_TEXTURE_2D));
|
||||||
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_FILL));
|
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_FILL));
|
||||||
glsafe(::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE));
|
glsafe(::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE));
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#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.
|
||||||
@ -2075,7 +2075,7 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
|
|||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_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));
|
||||||
@ -2100,7 +2100,7 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
|
|||||||
glsafe(::glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1])));
|
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(::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]));
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
|
|
||||||
|
@ -14,15 +14,6 @@
|
|||||||
#include <libvgcode/include/GCodeInputData.hpp>
|
#include <libvgcode/include/GCodeInputData.hpp>
|
||||||
#include <libvgcode/include/ColorRange.hpp>
|
#include <libvgcode/include/ColorRange.hpp>
|
||||||
|
|
||||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
||||||
//static_assert(VGCODE_ENABLE_OPENGL_ES == ENABLE_OPENGL_ES,
|
|
||||||
//#if ENABLE_OPENGL_ES
|
|
||||||
// "VGCODE_ENABLE_OPENGL_ES must be set to 1");
|
|
||||||
//#else
|
|
||||||
// "VGCODE_ENABLE_OPENGL_ES must be set to 0");
|
|
||||||
//#endif // ENABLE_OPENGL_ES
|
|
||||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
class Print;
|
class Print;
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
@ -150,16 +150,16 @@ static Semver parse_version_string(const std::string& version)
|
|||||||
if (tokens.empty())
|
if (tokens.empty())
|
||||||
return Semver::invalid();
|
return Semver::invalid();
|
||||||
|
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
const std::string version_container = (tokens.size() > 1 && boost::istarts_with(tokens[1], "ES")) ? tokens[2] : tokens[0];
|
const std::string version_container = (tokens.size() > 1 && boost::istarts_with(tokens[1], "ES")) ? tokens[2] : tokens[0];
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
std::vector<std::string> numbers;
|
std::vector<std::string> numbers;
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
boost::split(numbers, version_container, boost::is_any_of("."), boost::token_compress_on);
|
boost::split(numbers, version_container, boost::is_any_of("."), boost::token_compress_on);
|
||||||
#else
|
#else
|
||||||
boost::split(numbers, tokens[0], boost::is_any_of("."), boost::token_compress_on);
|
boost::split(numbers, tokens[0], boost::is_any_of("."), boost::token_compress_on);
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
unsigned int gl_major = 0;
|
unsigned int gl_major = 0;
|
||||||
unsigned int gl_minor = 0;
|
unsigned int gl_minor = 0;
|
||||||
@ -348,10 +348,10 @@ static void CustomGLDebugOutput(GLenum source, GLenum type, unsigned int id, GLe
|
|||||||
bool OpenGLManager::init_gl()
|
bool OpenGLManager::init_gl()
|
||||||
{
|
{
|
||||||
if (!m_gl_initialized) {
|
if (!m_gl_initialized) {
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
glewExperimental = true;
|
glewExperimental = true;
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#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;
|
||||||
@ -378,18 +378,18 @@ bool OpenGLManager::init_gl()
|
|||||||
else
|
else
|
||||||
s_framebuffers_type = EFramebufferType::Unknown;
|
s_framebuffers_type = EFramebufferType::Unknown;
|
||||||
|
|
||||||
#if ENABLE_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(2, 0);
|
||||||
#elif ENABLE_GL_CORE_PROFILE
|
#elif ENABLE_GL_CORE_PROFILE
|
||||||
const bool valid_version = s_gl_info.is_version_greater_or_equal_to(3, 2);
|
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);
|
bool valid_version = s_gl_info.is_version_greater_or_equal_to(2, 0);
|
||||||
#endif // ENABLE_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 ENABLE_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 2.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());
|
"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
|
#elif ENABLE_GL_CORE_PROFILE
|
||||||
@ -398,7 +398,7 @@ bool OpenGLManager::init_gl()
|
|||||||
#else
|
#else
|
||||||
_L("PrusaSlicer requires OpenGL 2.0 capable graphics driver to run correctly, \n"
|
_L("PrusaSlicer requires OpenGL 2.0 capable graphics driver to run correctly, \n"
|
||||||
"while OpenGL version %s, render %s, vendor %s was detected."), s_gl_info.get_version_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 // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
message += "\n";
|
message += "\n";
|
||||||
message += _L("You may need to update your graphics card driver.");
|
message += _L("You may need to update your graphics card driver.");
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -457,7 +457,7 @@ wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas)
|
|||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
{
|
{
|
||||||
if (m_context == nullptr) {
|
if (m_context == nullptr) {
|
||||||
#if ENABLE_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);
|
||||||
@ -533,7 +533,7 @@ wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
m_context = new wxGLContext(&canvas);
|
m_context = new wxGLContext(&canvas);
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets
|
// Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets
|
||||||
@ -551,7 +551,7 @@ 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 || ENABLE_OPENGL_ES
|
#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;
|
||||||
@ -590,7 +590,7 @@ wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent)
|
|||||||
WX_GL_SAMPLES, 4,
|
WX_GL_SAMPLES, 4,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#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 +600,7 @@ 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 || ENABLE_OPENGL_ES
|
#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();
|
||||||
@ -615,15 +615,15 @@ wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent)
|
|||||||
attribList[12] = 0;
|
attribList[12] = 0;
|
||||||
|
|
||||||
return new wxGLCanvas(&parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
|
return new wxGLCanvas(&parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#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 || ENABLE_OPENGL_ES
|
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
void OpenGLManager::detect_multisample(const wxGLAttributes& attribList)
|
void OpenGLManager::detect_multisample(const wxGLAttributes& attribList)
|
||||||
#else
|
#else
|
||||||
void OpenGLManager::detect_multisample(int* attribList)
|
void OpenGLManager::detect_multisample(int* attribList)
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#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;
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
class wxWindow;
|
class wxWindow;
|
||||||
class wxGLCanvas;
|
class wxGLCanvas;
|
||||||
class wxGLContext;
|
class wxGLContext;
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
class wxGLAttributes;
|
class wxGLAttributes;
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
@ -60,11 +60,11 @@ public:
|
|||||||
|
|
||||||
bool is_mesa() const;
|
bool is_mesa() const;
|
||||||
bool is_es() const {
|
bool is_es() const {
|
||||||
#if ENABLE_OPENGL_ES
|
#if SLIC3R_OPENGL_ES
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // SLIC3R_OPENGL_ES
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_max_tex_size() const;
|
int get_max_tex_size() const;
|
||||||
@ -146,11 +146,11 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
#if !ENABLE_OPENGL_AUTO_AA_SAMPLES
|
#if !ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||||
#if ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#if ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
static void detect_multisample(const wxGLAttributes& attribList);
|
static void detect_multisample(const wxGLAttributes& attribList);
|
||||||
#else
|
#else
|
||||||
static void detect_multisample(int* attribList);
|
static void detect_multisample(int* attribList);
|
||||||
#endif // ENABLE_GL_CORE_PROFILE || ENABLE_OPENGL_ES
|
#endif // ENABLE_GL_CORE_PROFILE || SLIC3R_OPENGL_ES
|
||||||
#endif // !ENABLE_OPENGL_AUTO_AA_SAMPLES
|
#endif // !ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user