mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Use an unique opengl context
This commit is contained in:
parent
f31cf684cb
commit
96745e12d7
8 changed files with 91 additions and 7 deletions
|
@ -113,13 +113,29 @@ std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool exten
|
|||
GLCanvas3DManager::EMultisampleState GLCanvas3DManager::s_multisample = GLCanvas3DManager::MS_Unknown;
|
||||
|
||||
GLCanvas3DManager::GLCanvas3DManager()
|
||||
#if ENABLE_USE_UNIQUE_GLCONTEXT
|
||||
: m_context(nullptr)
|
||||
, m_current(nullptr)
|
||||
#else
|
||||
: m_current(nullptr)
|
||||
#endif // ENABLE_USE_UNIQUE_GLCONTEXT
|
||||
, m_gl_initialized(false)
|
||||
, m_use_legacy_opengl(false)
|
||||
, m_use_VBOs(false)
|
||||
{
|
||||
}
|
||||
|
||||
#if ENABLE_USE_UNIQUE_GLCONTEXT
|
||||
GLCanvas3DManager::~GLCanvas3DManager()
|
||||
{
|
||||
if (m_context != nullptr)
|
||||
{
|
||||
delete m_context;
|
||||
m_context = nullptr;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_USE_UNIQUE_GLCONTEXT
|
||||
|
||||
bool GLCanvas3DManager::add(wxGLCanvas* canvas)
|
||||
{
|
||||
if (canvas == nullptr)
|
||||
|
@ -133,6 +149,18 @@ bool GLCanvas3DManager::add(wxGLCanvas* canvas)
|
|||
return false;
|
||||
|
||||
canvas3D->bind_event_handlers();
|
||||
|
||||
#if ENABLE_USE_UNIQUE_GLCONTEXT
|
||||
if (m_context == nullptr)
|
||||
{
|
||||
m_context = new wxGLContext(canvas);
|
||||
if (m_context == nullptr)
|
||||
return false;
|
||||
}
|
||||
|
||||
canvas3D->set_context(m_context);
|
||||
#endif // ENABLE_USE_UNIQUE_GLCONTEXT
|
||||
|
||||
m_canvases.insert(CanvasesMap::value_type(canvas, canvas3D));
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue