1st attempt to fix opengl initialization on linux

This commit is contained in:
Enrico Turri 2018-06-04 13:15:28 +02:00
parent adca3035f9
commit ac47ba5864
7 changed files with 119 additions and 51 deletions

View file

@ -575,7 +575,7 @@ bool GLCanvas3D::LayersEditing::init(const std::string& vertex_shader_filename,
bool GLCanvas3D::LayersEditing::is_allowed() const
{
return m_use_legacy_opengl && m_shader.is_initialized();
return !m_use_legacy_opengl && m_shader.is_initialized();
}
void GLCanvas3D::LayersEditing::set_use_legacy_opengl(bool use_legacy_opengl)
@ -943,7 +943,10 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
, m_print(nullptr)
, m_dirty(true)
, m_use_VBOs(false)
, m_late_init(false)
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
, m_first_render(true)
// , m_late_init(false)
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
, m_apply_zoom_to_volumes_filter(false)
, m_hover_volume_id(-1)
, m_warning_texture_enabled(false)
@ -970,8 +973,10 @@ GLCanvas3D::~GLCanvas3D()
bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
{
if (!set_current())
return false;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// if (!set_current())
// return false;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
::glClearDepth(1.0f);
@ -1022,8 +1027,19 @@ bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
if (useVBOs && !m_layers_editing.init("variable_layer_height.vs", "variable_layer_height.fs"))
return false;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// This is a special path for wxWidgets on GTK, where an OpenGL context is initialized
// first when an OpenGL widget is shown for the first time. How ugly.
// In that case the volumes are wainting to be moved to Vertex Buffer Objects
// after the OpenGL context is being initialized.
#if defined(__LINUX__)
if (use_VBOs && (m_volumes != nullptr))
m_volumes->finalize_geometry(use_VBOs);
#endif // __LINUX__
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
m_use_VBOs = useVBOs;
m_layers_editing.set_use_legacy_opengl(!use_legacy_opengl);
m_layers_editing.set_use_legacy_opengl(use_legacy_opengl);
return true;
}
@ -1264,8 +1280,17 @@ void GLCanvas3D::render()
if (!set_current())
return;
if (!m_late_init)
_late_init();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if (!_3DScene::init(m_canvas))
return;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if (m_first_render)
_before_first_render();
// if (!m_late_init)
// _late_init();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
_camera_tranform();
@ -1719,19 +1744,27 @@ Point GLCanvas3D::get_local_mouse_position() const
return Point(mouse_pos.x, mouse_pos.y);
}
void GLCanvas3D::_late_init()
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void GLCanvas3D::_before_first_render()
//void GLCanvas3D::_late_init()
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
{
// This is a special path for wxWidgets on GTK, where an OpenGL context is initialized
// first when an OpenGL widget is shown for the first time.How ugly.
// In that case the volumes are wainting to be moved to Vertex Buffer Objects
// after the OpenGL context is being initialized.
#if defined(__LINUX__)
if (m_use_VBOs && (m_volumes != nullptr))
m_volumes->finalize_geometry(m_use_VBOs);
#endif // __LINUX__
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// // This is a special path for wxWidgets on GTK, where an OpenGL context is initialized
// // first when an OpenGL widget is shown for the first time. How ugly.
// // In that case the volumes are wainting to be moved to Vertex Buffer Objects
// // after the OpenGL context is being initialized.
//#if defined(__LINUX__)
// if (m_use_VBOs && (m_volumes != nullptr))
// m_volumes->finalize_geometry(m_use_VBOs);
//#endif // __LINUX__
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
zoom_to_bed();
m_late_init = true;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
m_first_render = false;
// m_late_init = true;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}
void GLCanvas3D::_resize(unsigned int w, unsigned int h)