Skip to content

Commit

Permalink
Add patch for OpenGL ES
Browse files Browse the repository at this point in the history
  • Loading branch information
davidk committed Sep 23, 2024
1 parent 4da5a94 commit 2b6b568
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 26 deletions.
99 changes: 99 additions & 0 deletions patches/version_2.8.1/0001-Patch-OpenGL-ES.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
From 1ceec265dd3bddea8382c4a6c7d7309ce28ca663 Mon Sep 17 00:00:00 2001
From: nobody <nobody>
Date: Mon, 23 Sep 2024 03:52:16 +0000
Subject: [PATCH] Patch PrusaSlicer for OpenGL ES

---
src/libvgcode/glad/include/glad/gles2.h | 4 ++++
src/libvgcode/src/ViewerImpl.cpp | 10 +++++-----
src/libvgcode/src/ViewerImpl.hpp | 2 +-
src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp | 4 +++-
4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/libvgcode/glad/include/glad/gles2.h b/src/libvgcode/glad/include/glad/gles2.h
index 2983e1d..5691317 100644
--- a/src/libvgcode/glad/include/glad/gles2.h
+++ b/src/libvgcode/glad/include/glad/gles2.h
@@ -87,6 +87,10 @@ extern "C" {
#endif
#endif

+#ifndef GLAD_GLES2_USE_SYSTEM_EGL
+ #define GLAD_GLES2_USE_SYSTEM_EGL 1
+#endif
+
#ifndef GLAD_PLATFORM_UWP
#if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
#ifdef __has_include
diff --git a/src/libvgcode/src/ViewerImpl.cpp b/src/libvgcode/src/ViewerImpl.cpp
index e2a0093..65e6a28 100644
--- a/src/libvgcode/src/ViewerImpl.cpp
+++ b/src/libvgcode/src/ViewerImpl.cpp
@@ -903,7 +903,7 @@ void ViewerImpl::reset()
using Vec4 = std::array<float, 4>;

static void extract_pos_and_or_hwa(const std::vector<PathVertex>& vertices, float travels_radius, float wipes_radius, BitSet<>& valid_lines_bitset,
- std::vector<Vec4>* positions = nullptr, std::vector<Vec4>* heights_widths_angles = nullptr, bool update_bitset = false) {
+ std::vector<Vec3>* positions = nullptr, std::vector<Vec3>* heights_widths_angles = nullptr, bool update_bitset = false) {
static constexpr const Vec3 ZERO = { 0.0f, 0.0f, 0.0f };
if (positions == nullptr && heights_widths_angles == nullptr)
return;
@@ -938,7 +938,7 @@ static void extract_pos_and_or_hwa(const std::vector<PathVertex>& vertices, floa

if (positions != nullptr) {
// the last component is a dummy float to comply with GL_RGBA32F format
- Vec4 position = { v.position[0], v.position[1], v.position[2], 0.0f };
+ Vec3 position = { v.position[0], v.position[1], v.position[2] };
if (move_type == EMoveType::Extrude)
// push down extrusion vertices by half height to render them at the right z
position[2] -= 0.5f * v.height;
@@ -962,7 +962,7 @@ static void extract_pos_and_or_hwa(const std::vector<PathVertex>& vertices, floa
}
// the last component is a dummy float to comply with GL_RGBA32F format
heights_widths_angles->push_back({ height, width,
- std::atan2(prev_line[0] * this_line[1] - prev_line[1] * this_line[0], dot(prev_line, this_line)), 0.0f });
+ std::atan2(prev_line[0] * this_line[1] - prev_line[1] * this_line[0], dot(prev_line, this_line)) });
}
}
}
@@ -1042,8 +1042,8 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)

// buffers to send to gpu
// the last component is a dummy float to comply with GL_RGBA32F format
- std::vector<Vec4> positions;
- std::vector<Vec4> heights_widths_angles;
+ std::vector<Vec3> positions;
+ std::vector<Vec3> heights_widths_angles;
positions.reserve(m_vertices.size());
heights_widths_angles.reserve(m_vertices.size());
extract_pos_and_or_hwa(m_vertices, m_travels_radius, m_wipes_radius, m_valid_lines_bitset, &positions, &heights_widths_angles, true);
diff --git a/src/libvgcode/src/ViewerImpl.hpp b/src/libvgcode/src/ViewerImpl.hpp
index 8e112dc..ded7101 100644
--- a/src/libvgcode/src/ViewerImpl.hpp
+++ b/src/libvgcode/src/ViewerImpl.hpp
@@ -463,4 +463,4 @@ private:

} // namespace libvgcode

-#endif // VGCODE_VIEWERIMPL_HPP
\ No newline at end of file
+#endif // VGCODE_VIEWERIMPL_HPP
diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp
index 48b952a..d91807c 100644
--- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp
+++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp
@@ -1565,8 +1565,10 @@ void GLGizmoMeasure::render_dimensioning()
const Vec3d label_position_world = Geometry::translation_transform(center) * (draw_radius * (Eigen::Quaternion<double>(Eigen::AngleAxisd(step * 0.5 * double(resolution), normal)) * e1_unit));

// label screen coordinates
+#if !SLIC3R_OPENGL_ES
const std::array<int, 4>& viewport = camera.get_viewport();
- const Vec2d label_position_ss = TransformHelper::world_to_ss(label_position_world,
+#endif
+ const Vec2d label_position_ss = TransformHelper::world_to_ss(label_position_world,
camera.get_projection_matrix().matrix() * camera.get_view_matrix().matrix(), viewport);

ImGuiPureWrap::set_next_window_pos(label_position_ss.x(), viewport[3] - label_position_ss.y(), ImGuiCond_Always, 0.0f, 1.0f);
--
2.39.5

26 changes: 0 additions & 26 deletions patches/version_2.8.1/0001-Set-GLAD_GLES2_USE_SYSTEM_EGL.patch

This file was deleted.

0 comments on commit 2b6b568

Please sign in to comment.