1st attempt to fix opengl on ubuntu
This commit is contained in:
parent
645cc65d2b
commit
5c32347449
@ -204,7 +204,9 @@ sub new {
|
||||
if (($preview != $self->{preview3D}) && ($preview != $self->{canvas3D})) {
|
||||
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 0);
|
||||
Slic3r::GUI::_3DScene::set_active($self->{canvas3D}, 0);
|
||||
Slic3r::GUI::_3DScene::reset_current_canvas();
|
||||
#==================================================================================================================
|
||||
# Slic3r::GUI::_3DScene::reset_current_canvas();
|
||||
#==================================================================================================================
|
||||
$preview->OnActivate if $preview->can('OnActivate');
|
||||
} elsif ($preview == $self->{preview3D}) {
|
||||
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 1);
|
||||
|
@ -279,7 +279,9 @@ sub reload_print {
|
||||
my ($self, $force) = @_;
|
||||
|
||||
Slic3r::GUI::_3DScene::reset_volumes($self->canvas);
|
||||
Slic3r::GUI::_3DScene::reset_current_canvas();
|
||||
#==================================================================================================================
|
||||
# Slic3r::GUI::_3DScene::reset_current_canvas();
|
||||
#==================================================================================================================
|
||||
$self->_loaded(0);
|
||||
|
||||
if (! $self->IsShown && ! $force) {
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
//#################################################################################################################
|
||||
// if (m_context == nullptr)
|
||||
// {
|
||||
// m_context = new wxGLContext(canvas);
|
||||
// if (m_context == nullptr)
|
||||
// return false;
|
||||
// }
|
||||
//#################################################################################################################
|
||||
|
||||
GLCanvas3D* canvas3D = new GLCanvas3D(canvas, m_context);
|
||||
//#################################################################################################################
|
||||
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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
@ -190,11 +190,6 @@ remove_all_canvases()
|
||||
CODE:
|
||||
_3DScene::remove_all_canvases();
|
||||
|
||||
void
|
||||
reset_current_canvas()
|
||||
CODE:
|
||||
_3DScene::reset_current_canvas();
|
||||
|
||||
void
|
||||
set_active(canvas, active)
|
||||
SV *canvas;
|
||||
|
Loading…
Reference in New Issue
Block a user