Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/xs
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2018-06-27 12:31:11 +0300
committerEnrico Turri <enricoturri@seznam.cz>2018-06-27 12:31:11 +0300
commit5c323474499b133d7994da296b1d906bbc1e656a (patch)
treeb3f8156011cf00c0c12657e4910a120374dc450e /xs
parent645cc65d2b340752f390359ce3ed09a49b463588 (diff)
1st attempt to fix opengl on ubuntu
Diffstat (limited to 'xs')
-rw-r--r--xs/src/slic3r/GUI/3DScene.cpp20
-rw-r--r--xs/src/slic3r/GUI/3DScene.hpp6
-rw-r--r--xs/src/slic3r/GUI/GLCanvas3D.cpp80
-rw-r--r--xs/src/slic3r/GUI/GLCanvas3D.hpp10
-rw-r--r--xs/src/slic3r/GUI/GLCanvas3DManager.cpp90
-rw-r--r--xs/src/slic3r/GUI/GLCanvas3DManager.hpp8
-rw-r--r--xs/xsp/GUI_3DScene.xsp5
7 files changed, 149 insertions, 70 deletions
diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp
index a499825a4..556be56bc 100644
--- a/xs/src/slic3r/GUI/3DScene.cpp
+++ b/xs/src/slic3r/GUI/3DScene.cpp
@@ -1754,15 +1754,17 @@ bool _3DScene::init(wxGLCanvas* canvas)
return s_canvas_mgr.init(canvas);
}
-bool _3DScene::set_current(wxGLCanvas* canvas, bool force)
-{
- return s_canvas_mgr.set_current(canvas, force);
-}
-
-void _3DScene::reset_current_canvas()
-{
- s_canvas_mgr.set_current(nullptr, false);
-}
+//#################################################################################################################
+//bool _3DScene::set_current(wxGLCanvas* canvas, bool force)
+//{
+// return s_canvas_mgr.set_current(canvas, force);
+//}
+//
+//void _3DScene::reset_current_canvas()
+//{
+// s_canvas_mgr.set_current(nullptr, false);
+//}
+//#################################################################################################################
void _3DScene::set_active(wxGLCanvas* canvas, bool active)
{
diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp
index f45bab276..a375bd756 100644
--- a/xs/src/slic3r/GUI/3DScene.hpp
+++ b/xs/src/slic3r/GUI/3DScene.hpp
@@ -516,8 +516,10 @@ public:
static bool init(wxGLCanvas* canvas);
- static bool set_current(wxGLCanvas* canvas, bool force);
- static void reset_current_canvas();
+//#################################################################################################################
+// static bool set_current(wxGLCanvas* canvas, bool force);
+// static void reset_current_canvas();
+//#################################################################################################################
static void set_active(wxGLCanvas* canvas, bool active);
static void set_as_dirty(wxGLCanvas* canvas);
diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp
index 2148579e8..04b134b41 100644
--- a/xs/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp
@@ -1408,9 +1408,15 @@ GLGizmoBase* GLCanvas3D::Gizmos::_get_current() const
return (it != m_gizmos.end()) ? it->second : nullptr;
}
-GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
+//#################################################################################################################
+GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
+//GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
+//#################################################################################################################
: m_canvas(canvas)
- , m_context(context)
+//#################################################################################################################
+ , m_context(nullptr)
+// , m_context(context)
+//#################################################################################################################
, m_timer(nullptr)
, m_config(nullptr)
, m_print(nullptr)
@@ -1433,8 +1439,16 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
, m_drag_by("instance")
, m_reload_delayed(false)
{
+//#################################################################################################################
if (m_canvas != nullptr)
+ {
+ m_context = new wxGLContext(m_canvas);
m_timer = new wxTimer(m_canvas);
+ }
+
+// if (m_canvas != nullptr)
+// m_timer = new wxTimer(m_canvas);
+//#################################################################################################################
}
GLCanvas3D::~GLCanvas3D()
@@ -1447,6 +1461,14 @@ GLCanvas3D::~GLCanvas3D()
m_timer = nullptr;
}
+//#################################################################################################################
+ if (m_context != nullptr)
+ {
+ delete m_context;
+ m_context = nullptr;
+ }
+//#################################################################################################################
+
_deregister_callbacks();
}
@@ -1455,6 +1477,11 @@ bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
if (m_initialized)
return true;
+//#################################################################################################################
+ if ((m_canvas == nullptr) || (m_context == nullptr))
+ return false;
+//#################################################################################################################
+
::glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
::glClearDepth(1.0f);
@@ -1520,14 +1547,27 @@ bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
return true;
}
-bool GLCanvas3D::set_current(bool force)
+//#################################################################################################################
+bool GLCanvas3D::set_current()
{
- if ((force || m_active) && (m_canvas != nullptr) && (m_context != nullptr))
+ if ((m_canvas != nullptr) && (m_context != nullptr))
+// if (m_active && (m_canvas != nullptr) && (m_context != nullptr))
+ {
+ std::cout << "set_current: " << (void*)m_canvas << " - " << (void*)m_context << std::endl;
return m_canvas->SetCurrent(*m_context);
-
+ }
return false;
}
+//bool GLCanvas3D::set_current(bool force)
+//{
+// if ((force || m_active) && (m_canvas != nullptr) && (m_context != nullptr))
+// return m_canvas->SetCurrent(*m_context);
+//
+// return false;
+//}
+//#################################################################################################################
+
void GLCanvas3D::set_active(bool active)
{
m_active = active;
@@ -1549,7 +1589,10 @@ void GLCanvas3D::reset_volumes()
if (!m_volumes.empty())
{
// ensures this canvas is current
- if ((m_canvas == nullptr) || !_3DScene::set_current(m_canvas, true))
+//#################################################################################################################
+ if (!set_current())
+// if ((m_canvas == nullptr) || !_3DScene::set_current(m_canvas, true))
+//#################################################################################################################
return;
m_volumes.release_geometry();
@@ -1850,7 +1893,10 @@ void GLCanvas3D::render()
return;
// ensures this canvas is current and initialized
- if (!_3DScene::set_current(m_canvas, false) || !_3DScene::init(m_canvas))
+//#################################################################################################################
+ if (!set_current() || !_3DScene::init(m_canvas))
+// if (!_3DScene::set_current(m_canvas, false) || !_3DScene::init(m_canvas))
+//#################################################################################################################
return;
if (m_force_zoom_to_bed_enabled)
@@ -1933,7 +1979,10 @@ void GLCanvas3D::reload_scene(bool force)
reset_volumes();
// ensures this canvas is current
- if (!_3DScene::set_current(m_canvas, true))
+//#################################################################################################################
+ if (!set_current())
+// if (!_3DScene::set_current(m_canvas, true))
+//#################################################################################################################
return;
set_bed_shape(dynamic_cast<const ConfigOptionPoints*>(m_config->option("bed_shape"))->values);
@@ -2008,7 +2057,10 @@ void GLCanvas3D::reload_scene(bool force)
void GLCanvas3D::load_print_toolpaths()
{
// ensures this canvas is current
- if (!_3DScene::set_current(m_canvas, true))
+//#################################################################################################################
+ if (!set_current())
+// if (!_3DScene::set_current(m_canvas, true))
+//#################################################################################################################
return;
if (m_print == nullptr)
@@ -2376,7 +2428,10 @@ void GLCanvas3D::load_gcode_preview(const GCodePreviewData& preview_data, const
if ((m_canvas != nullptr) && (m_print != nullptr))
{
// ensures that this canvas is current
- if (!_3DScene::set_current(m_canvas, true))
+//#################################################################################################################
+ if (!set_current())
+// if (!_3DScene::set_current(m_canvas, true))
+//#################################################################################################################
return;
if (m_volumes.empty())
@@ -3019,7 +3074,10 @@ void GLCanvas3D::_resize(unsigned int w, unsigned int h)
return;
// ensures that this canvas is current
- _3DScene::set_current(m_canvas, false);
+//#################################################################################################################
+ set_current();
+// _3DScene::set_current(m_canvas, false);
+//#################################################################################################################
::glViewport(0, 0, w, h);
::glMatrixMode(GL_PROJECTION);
diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp
index 237044e83..181f5d1ac 100644
--- a/xs/src/slic3r/GUI/GLCanvas3D.hpp
+++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp
@@ -444,12 +444,18 @@ private:
PerlCallback m_on_gizmo_scale_uniformly_callback;
public:
- GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context);
+//#################################################################################################################
+ GLCanvas3D(wxGLCanvas* canvas);
+// GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context);
+//#################################################################################################################
~GLCanvas3D();
bool init(bool useVBOs, bool use_legacy_opengl);
- bool set_current(bool force);
+//#################################################################################################################
+ bool set_current();
+// bool set_current(bool force);
+//#################################################################################################################
void set_active(bool active);
void set_as_dirty();
diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp
index 62d17827a..0021f13eb 100644
--- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp
+++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp
@@ -114,8 +114,11 @@ std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool exten
}
GLCanvas3DManager::GLCanvas3DManager()
- : m_context(nullptr)
- , m_current(nullptr)
+//#################################################################################################################
+ : m_current(nullptr)
+// : m_context(nullptr)
+// , m_current(nullptr)
+//#################################################################################################################
, m_gl_initialized(false)
, m_use_legacy_opengl(false)
, m_use_VBOs(false)
@@ -124,8 +127,10 @@ GLCanvas3DManager::GLCanvas3DManager()
GLCanvas3DManager::~GLCanvas3DManager()
{
- if (m_context != nullptr)
- delete m_context;
+//#################################################################################################################
+// if (m_context != nullptr)
+// delete m_context;
+//#################################################################################################################
}
bool GLCanvas3DManager::add(wxGLCanvas* canvas)
@@ -136,14 +141,19 @@ bool GLCanvas3DManager::add(wxGLCanvas* canvas)
if (_get_canvas(canvas) != m_canvases.end())
return false;
- if (m_context == nullptr)
- {
- m_context = new wxGLContext(canvas);
- if (m_context == nullptr)
- return false;
- }
-
- GLCanvas3D* canvas3D = new GLCanvas3D(canvas, m_context);
+//#################################################################################################################
+// if (m_context == nullptr)
+// {
+// m_context = new wxGLContext(canvas);
+// if (m_context == nullptr)
+// return false;
+// }
+//#################################################################################################################
+
+//#################################################################################################################
+ GLCanvas3D* canvas3D = new GLCanvas3D(canvas);
+// GLCanvas3D* canvas3D = new GLCanvas3D(canvas, m_context);
+//#################################################################################################################
if (canvas3D == nullptr)
return false;
@@ -213,33 +223,35 @@ bool GLCanvas3DManager::init(wxGLCanvas* canvas)
return false;
}
-bool GLCanvas3DManager::set_current(wxGLCanvas* canvas, bool force)
-{
- // given canvas is already current, return
- if (m_current == canvas)
- return true;
-
- if (canvas == nullptr)
- {
- m_current = nullptr;
- return true;
- }
-
- // set given canvas as current
- CanvasesMap::iterator it = _get_canvas(canvas);
- if (it != m_canvases.end())
- {
- bool res = it->second->set_current(force);
- if (res)
- {
- m_current = canvas;
- return true;
- }
- }
-
- m_current = nullptr;
- return false;
-}
+//#################################################################################################################
+//bool GLCanvas3DManager::set_current(wxGLCanvas* canvas, bool force)
+//{
+// // given canvas is already current, return
+// if (m_current == canvas)
+// return true;
+//
+// if (canvas == nullptr)
+// {
+// m_current = nullptr;
+// return true;
+// }
+//
+// // set given canvas as current
+// CanvasesMap::iterator it = _get_canvas(canvas);
+// if (it != m_canvases.end())
+// {
+// bool res = it->second->set_current(force);
+// if (res)
+// {
+// m_current = canvas;
+// return true;
+// }
+// }
+//
+// m_current = nullptr;
+// return false;
+//}
+//#################################################################################################################
void GLCanvas3DManager::set_active(wxGLCanvas* canvas, bool active)
{
diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp
index 35a1db206..57e6f503d 100644
--- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp
+++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp
@@ -43,7 +43,9 @@ class GLCanvas3DManager
typedef std::map<wxGLCanvas*, GLCanvas3D*> CanvasesMap;
- wxGLContext* m_context;
+//#################################################################################################################
+// wxGLContext* m_context;
+//#################################################################################################################
CanvasesMap m_canvases;
wxGLCanvas* m_current;
GLInfo m_gl_info;
@@ -70,7 +72,9 @@ public:
bool init(wxGLCanvas* canvas);
- bool set_current(wxGLCanvas* canvas, bool force);
+//#################################################################################################################
+// bool set_current(wxGLCanvas* canvas, bool force);
+//#################################################################################################################
void set_active(wxGLCanvas* canvas, bool active);
void set_as_dirty(wxGLCanvas* canvas);
diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp
index 8ee88543d..d46c06120 100644
--- a/xs/xsp/GUI_3DScene.xsp
+++ b/xs/xsp/GUI_3DScene.xsp
@@ -191,11 +191,6 @@ remove_all_canvases()
_3DScene::remove_all_canvases();
void
-reset_current_canvas()
- CODE:
- _3DScene::reset_current_canvas();
-
-void
set_active(canvas, active)
SV *canvas;
bool active;