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})) {
|
if (($preview != $self->{preview3D}) && ($preview != $self->{canvas3D})) {
|
||||||
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 0);
|
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 0);
|
||||||
Slic3r::GUI::_3DScene::set_active($self->{canvas3D}, 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');
|
$preview->OnActivate if $preview->can('OnActivate');
|
||||||
} elsif ($preview == $self->{preview3D}) {
|
} elsif ($preview == $self->{preview3D}) {
|
||||||
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 1);
|
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 1);
|
||||||
|
@ -279,7 +279,9 @@ sub reload_print {
|
|||||||
my ($self, $force) = @_;
|
my ($self, $force) = @_;
|
||||||
|
|
||||||
Slic3r::GUI::_3DScene::reset_volumes($self->canvas);
|
Slic3r::GUI::_3DScene::reset_volumes($self->canvas);
|
||||||
Slic3r::GUI::_3DScene::reset_current_canvas();
|
#==================================================================================================================
|
||||||
|
# Slic3r::GUI::_3DScene::reset_current_canvas();
|
||||||
|
#==================================================================================================================
|
||||||
$self->_loaded(0);
|
$self->_loaded(0);
|
||||||
|
|
||||||
if (! $self->IsShown && ! $force) {
|
if (! $self->IsShown && ! $force) {
|
||||||
|
@ -1754,15 +1754,17 @@ bool _3DScene::init(wxGLCanvas* canvas)
|
|||||||
return s_canvas_mgr.init(canvas);
|
return s_canvas_mgr.init(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _3DScene::set_current(wxGLCanvas* canvas, bool force)
|
//#################################################################################################################
|
||||||
{
|
//bool _3DScene::set_current(wxGLCanvas* canvas, bool force)
|
||||||
return s_canvas_mgr.set_current(canvas, force);
|
//{
|
||||||
}
|
// return s_canvas_mgr.set_current(canvas, force);
|
||||||
|
//}
|
||||||
void _3DScene::reset_current_canvas()
|
//
|
||||||
{
|
//void _3DScene::reset_current_canvas()
|
||||||
s_canvas_mgr.set_current(nullptr, false);
|
//{
|
||||||
}
|
// s_canvas_mgr.set_current(nullptr, false);
|
||||||
|
//}
|
||||||
|
//#################################################################################################################
|
||||||
|
|
||||||
void _3DScene::set_active(wxGLCanvas* canvas, bool active)
|
void _3DScene::set_active(wxGLCanvas* canvas, bool active)
|
||||||
{
|
{
|
||||||
|
@ -516,8 +516,10 @@ public:
|
|||||||
|
|
||||||
static bool init(wxGLCanvas* canvas);
|
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_active(wxGLCanvas* canvas, bool active);
|
||||||
static void set_as_dirty(wxGLCanvas* canvas);
|
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;
|
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_canvas(canvas)
|
||||||
, m_context(context)
|
//#################################################################################################################
|
||||||
|
, m_context(nullptr)
|
||||||
|
// , m_context(context)
|
||||||
|
//#################################################################################################################
|
||||||
, m_timer(nullptr)
|
, m_timer(nullptr)
|
||||||
, m_config(nullptr)
|
, m_config(nullptr)
|
||||||
, m_print(nullptr)
|
, m_print(nullptr)
|
||||||
@ -1433,8 +1439,16 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
|
|||||||
, m_drag_by("instance")
|
, m_drag_by("instance")
|
||||||
, m_reload_delayed(false)
|
, m_reload_delayed(false)
|
||||||
{
|
{
|
||||||
|
//#################################################################################################################
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr)
|
||||||
|
{
|
||||||
|
m_context = new wxGLContext(m_canvas);
|
||||||
m_timer = new wxTimer(m_canvas);
|
m_timer = new wxTimer(m_canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (m_canvas != nullptr)
|
||||||
|
// m_timer = new wxTimer(m_canvas);
|
||||||
|
//#################################################################################################################
|
||||||
}
|
}
|
||||||
|
|
||||||
GLCanvas3D::~GLCanvas3D()
|
GLCanvas3D::~GLCanvas3D()
|
||||||
@ -1447,6 +1461,14 @@ GLCanvas3D::~GLCanvas3D()
|
|||||||
m_timer = nullptr;
|
m_timer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#################################################################################################################
|
||||||
|
if (m_context != nullptr)
|
||||||
|
{
|
||||||
|
delete m_context;
|
||||||
|
m_context = nullptr;
|
||||||
|
}
|
||||||
|
//#################################################################################################################
|
||||||
|
|
||||||
_deregister_callbacks();
|
_deregister_callbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1455,6 +1477,11 @@ bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
|
|||||||
if (m_initialized)
|
if (m_initialized)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
//#################################################################################################################
|
||||||
|
if ((m_canvas == nullptr) || (m_context == nullptr))
|
||||||
|
return false;
|
||||||
|
//#################################################################################################################
|
||||||
|
|
||||||
::glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
::glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
::glClearDepth(1.0f);
|
::glClearDepth(1.0f);
|
||||||
|
|
||||||
@ -1520,14 +1547,27 @@ bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
|
|||||||
return true;
|
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 m_canvas->SetCurrent(*m_context);
|
||||||
|
}
|
||||||
return false;
|
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)
|
void GLCanvas3D::set_active(bool active)
|
||||||
{
|
{
|
||||||
m_active = active;
|
m_active = active;
|
||||||
@ -1549,7 +1589,10 @@ void GLCanvas3D::reset_volumes()
|
|||||||
if (!m_volumes.empty())
|
if (!m_volumes.empty())
|
||||||
{
|
{
|
||||||
// ensures this canvas is current
|
// 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;
|
return;
|
||||||
|
|
||||||
m_volumes.release_geometry();
|
m_volumes.release_geometry();
|
||||||
@ -1850,7 +1893,10 @@ void GLCanvas3D::render()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// ensures this canvas is current and initialized
|
// 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;
|
return;
|
||||||
|
|
||||||
if (m_force_zoom_to_bed_enabled)
|
if (m_force_zoom_to_bed_enabled)
|
||||||
@ -1933,7 +1979,10 @@ void GLCanvas3D::reload_scene(bool force)
|
|||||||
reset_volumes();
|
reset_volumes();
|
||||||
|
|
||||||
// ensures this canvas is current
|
// ensures this canvas is current
|
||||||
if (!_3DScene::set_current(m_canvas, true))
|
//#################################################################################################################
|
||||||
|
if (!set_current())
|
||||||
|
// if (!_3DScene::set_current(m_canvas, true))
|
||||||
|
//#################################################################################################################
|
||||||
return;
|
return;
|
||||||
|
|
||||||
set_bed_shape(dynamic_cast<const ConfigOptionPoints*>(m_config->option("bed_shape"))->values);
|
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()
|
void GLCanvas3D::load_print_toolpaths()
|
||||||
{
|
{
|
||||||
// ensures this canvas is current
|
// ensures this canvas is current
|
||||||
if (!_3DScene::set_current(m_canvas, true))
|
//#################################################################################################################
|
||||||
|
if (!set_current())
|
||||||
|
// if (!_3DScene::set_current(m_canvas, true))
|
||||||
|
//#################################################################################################################
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_print == nullptr)
|
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))
|
if ((m_canvas != nullptr) && (m_print != nullptr))
|
||||||
{
|
{
|
||||||
// ensures that this canvas is current
|
// ensures that this canvas is current
|
||||||
if (!_3DScene::set_current(m_canvas, true))
|
//#################################################################################################################
|
||||||
|
if (!set_current())
|
||||||
|
// if (!_3DScene::set_current(m_canvas, true))
|
||||||
|
//#################################################################################################################
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_volumes.empty())
|
if (m_volumes.empty())
|
||||||
@ -3019,7 +3074,10 @@ void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// ensures that this canvas is current
|
// 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);
|
::glViewport(0, 0, w, h);
|
||||||
|
|
||||||
::glMatrixMode(GL_PROJECTION);
|
::glMatrixMode(GL_PROJECTION);
|
||||||
|
@ -444,12 +444,18 @@ private:
|
|||||||
PerlCallback m_on_gizmo_scale_uniformly_callback;
|
PerlCallback m_on_gizmo_scale_uniformly_callback;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context);
|
//#################################################################################################################
|
||||||
|
GLCanvas3D(wxGLCanvas* canvas);
|
||||||
|
// GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context);
|
||||||
|
//#################################################################################################################
|
||||||
~GLCanvas3D();
|
~GLCanvas3D();
|
||||||
|
|
||||||
bool init(bool useVBOs, bool use_legacy_opengl);
|
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_active(bool active);
|
||||||
void set_as_dirty();
|
void set_as_dirty();
|
||||||
|
@ -114,8 +114,11 @@ std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool exten
|
|||||||
}
|
}
|
||||||
|
|
||||||
GLCanvas3DManager::GLCanvas3DManager()
|
GLCanvas3DManager::GLCanvas3DManager()
|
||||||
: m_context(nullptr)
|
//#################################################################################################################
|
||||||
, m_current(nullptr)
|
: m_current(nullptr)
|
||||||
|
// : m_context(nullptr)
|
||||||
|
// , m_current(nullptr)
|
||||||
|
//#################################################################################################################
|
||||||
, m_gl_initialized(false)
|
, m_gl_initialized(false)
|
||||||
, m_use_legacy_opengl(false)
|
, m_use_legacy_opengl(false)
|
||||||
, m_use_VBOs(false)
|
, m_use_VBOs(false)
|
||||||
@ -124,8 +127,10 @@ GLCanvas3DManager::GLCanvas3DManager()
|
|||||||
|
|
||||||
GLCanvas3DManager::~GLCanvas3DManager()
|
GLCanvas3DManager::~GLCanvas3DManager()
|
||||||
{
|
{
|
||||||
if (m_context != nullptr)
|
//#################################################################################################################
|
||||||
delete m_context;
|
// if (m_context != nullptr)
|
||||||
|
// delete m_context;
|
||||||
|
//#################################################################################################################
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLCanvas3DManager::add(wxGLCanvas* canvas)
|
bool GLCanvas3DManager::add(wxGLCanvas* canvas)
|
||||||
@ -136,14 +141,19 @@ bool GLCanvas3DManager::add(wxGLCanvas* canvas)
|
|||||||
if (_get_canvas(canvas) != m_canvases.end())
|
if (_get_canvas(canvas) != m_canvases.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_context == nullptr)
|
//#################################################################################################################
|
||||||
{
|
// if (m_context == nullptr)
|
||||||
m_context = new wxGLContext(canvas);
|
// {
|
||||||
if (m_context == nullptr)
|
// m_context = new wxGLContext(canvas);
|
||||||
return false;
|
// 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)
|
if (canvas3D == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -213,33 +223,35 @@ bool GLCanvas3DManager::init(wxGLCanvas* canvas)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLCanvas3DManager::set_current(wxGLCanvas* canvas, bool force)
|
//#################################################################################################################
|
||||||
{
|
//bool GLCanvas3DManager::set_current(wxGLCanvas* canvas, bool force)
|
||||||
// given canvas is already current, return
|
//{
|
||||||
if (m_current == canvas)
|
// // given canvas is already current, return
|
||||||
return true;
|
// if (m_current == canvas)
|
||||||
|
// return true;
|
||||||
if (canvas == nullptr)
|
//
|
||||||
{
|
// if (canvas == nullptr)
|
||||||
m_current = nullptr;
|
// {
|
||||||
return true;
|
// m_current = nullptr;
|
||||||
}
|
// return true;
|
||||||
|
// }
|
||||||
// set given canvas as current
|
//
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
// // set given canvas as current
|
||||||
if (it != m_canvases.end())
|
// CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
{
|
// if (it != m_canvases.end())
|
||||||
bool res = it->second->set_current(force);
|
// {
|
||||||
if (res)
|
// bool res = it->second->set_current(force);
|
||||||
{
|
// if (res)
|
||||||
m_current = canvas;
|
// {
|
||||||
return true;
|
// m_current = canvas;
|
||||||
}
|
// return true;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
m_current = nullptr;
|
//
|
||||||
return false;
|
// m_current = nullptr;
|
||||||
}
|
// return false;
|
||||||
|
//}
|
||||||
|
//#################################################################################################################
|
||||||
|
|
||||||
void GLCanvas3DManager::set_active(wxGLCanvas* canvas, bool active)
|
void GLCanvas3DManager::set_active(wxGLCanvas* canvas, bool active)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,9 @@ class GLCanvas3DManager
|
|||||||
|
|
||||||
typedef std::map<wxGLCanvas*, GLCanvas3D*> CanvasesMap;
|
typedef std::map<wxGLCanvas*, GLCanvas3D*> CanvasesMap;
|
||||||
|
|
||||||
wxGLContext* m_context;
|
//#################################################################################################################
|
||||||
|
// wxGLContext* m_context;
|
||||||
|
//#################################################################################################################
|
||||||
CanvasesMap m_canvases;
|
CanvasesMap m_canvases;
|
||||||
wxGLCanvas* m_current;
|
wxGLCanvas* m_current;
|
||||||
GLInfo m_gl_info;
|
GLInfo m_gl_info;
|
||||||
@ -70,7 +72,9 @@ public:
|
|||||||
|
|
||||||
bool init(wxGLCanvas* canvas);
|
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_active(wxGLCanvas* canvas, bool active);
|
||||||
void set_as_dirty(wxGLCanvas* canvas);
|
void set_as_dirty(wxGLCanvas* canvas);
|
||||||
|
|
||||||
|
@ -190,11 +190,6 @@ remove_all_canvases()
|
|||||||
CODE:
|
CODE:
|
||||||
_3DScene::remove_all_canvases();
|
_3DScene::remove_all_canvases();
|
||||||
|
|
||||||
void
|
|
||||||
reset_current_canvas()
|
|
||||||
CODE:
|
|
||||||
_3DScene::reset_current_canvas();
|
|
||||||
|
|
||||||
void
|
void
|
||||||
set_active(canvas, active)
|
set_active(canvas, active)
|
||||||
SV *canvas;
|
SV *canvas;
|
||||||
|
Loading…
Reference in New Issue
Block a user