mirror of https://github.com/CGAL/cgal
bug fix: confirmed that the previous opengl error was due to the inactive OpenGL context. Fixed it by moving the update function into paintGL(). This causes a delay when updating the approximation, will probably need multithreaded solution (low-priority / future work)
This commit is contained in:
parent
13111f4b9e
commit
a43389da33
|
|
@ -202,7 +202,8 @@ void Main_widget::initializeGL()
|
||||||
init_geometry();
|
init_geometry();
|
||||||
init_shader_programs();
|
init_shader_programs();
|
||||||
|
|
||||||
init_country_borders(0.001);
|
m_current_approx_error = 0.001;
|
||||||
|
init_country_borders(m_current_approx_error);
|
||||||
init_country_selection();
|
init_country_selection();
|
||||||
|
|
||||||
glClearColor(0, 0, 0, 1);
|
glClearColor(0, 0, 0, 1);
|
||||||
|
|
@ -213,6 +214,7 @@ void Main_widget::initializeGL()
|
||||||
m_timer.start(12, this);
|
m_timer.start(12, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Main_widget::init_camera()
|
void Main_widget::init_camera()
|
||||||
{
|
{
|
||||||
m_camera.set_pos(0, 0, 3);
|
m_camera.set_pos(0, 0, 3);
|
||||||
|
|
@ -224,8 +226,9 @@ void Main_widget::init_camera()
|
||||||
Message_manager::add("zoom_changed", [&]
|
Message_manager::add("zoom_changed", [&]
|
||||||
{
|
{
|
||||||
qDebug() << "ZOOM CHANGED!!!";
|
qDebug() << "ZOOM CHANGED!!!";
|
||||||
const auto error = compute_backprojected_error(0.5);
|
//const auto error = compute_backprojected_error(0.5);
|
||||||
qDebug() << "new error = " << error;
|
//qDebug() << "new error = " << error;
|
||||||
|
m_update_approx_error = true;
|
||||||
//qDebug() << "re-initializing the country borders..";
|
//qDebug() << "re-initializing the country borders..";
|
||||||
//init_country_borders(error);
|
//init_country_borders(error);
|
||||||
});
|
});
|
||||||
|
|
@ -404,9 +407,8 @@ void Main_widget::resizeGL(int w, int h)
|
||||||
const qreal z_near = 0.1, z_far = 100.0, fov = 45.0;
|
const qreal z_near = 0.1, z_far = 100.0, fov = 45.0;
|
||||||
m_camera.perspective(fov, aspect, z_near, z_far);
|
m_camera.perspective(fov, aspect, z_near, z_far);
|
||||||
|
|
||||||
// compute the world-space error for the given pixel-error
|
// signal to look into the approximation error
|
||||||
const auto err = compute_backprojected_error(0.5f);
|
m_update_approx_error = true;
|
||||||
std::cout << "error = " << err << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -418,6 +420,19 @@ void draw_safe(T& ptr)
|
||||||
|
|
||||||
void Main_widget::paintGL()
|
void Main_widget::paintGL()
|
||||||
{
|
{
|
||||||
|
if (m_update_approx_error)
|
||||||
|
{
|
||||||
|
const auto error = compute_backprojected_error(0.5);
|
||||||
|
qDebug() << "new approx error = " << error;
|
||||||
|
qDebug() << "current error = " << m_current_approx_error;
|
||||||
|
if(error < m_current_approx_error)
|
||||||
|
{
|
||||||
|
init_country_borders(error);
|
||||||
|
m_current_approx_error = error;
|
||||||
|
}
|
||||||
|
m_update_approx_error = false;
|
||||||
|
}
|
||||||
|
|
||||||
QMatrix4x4 model;
|
QMatrix4x4 model;
|
||||||
model.rotate(-90, 1,0,0); // this makes z-axes point upwards!
|
model.rotate(-90, 1,0,0); // this makes z-axes point upwards!
|
||||||
const auto view = m_camera.get_view_matrix();
|
const auto view = m_camera.get_view_matrix();
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,13 @@ private:
|
||||||
// view-port
|
// view-port
|
||||||
int m_vp_width = 0, m_vp_height = 0;
|
int m_vp_width = 0, m_vp_height = 0;
|
||||||
|
|
||||||
|
// After zooming in or making the viewport larger, the approximation-error
|
||||||
|
// needs to be updated and checked against the old value. If a lower approxi-
|
||||||
|
// mation error is needed the necessary graphics-side updates need to be made
|
||||||
|
// INSIDE the paintGL (or whereever the OpenGL context is active)!
|
||||||
|
bool m_update_approx_error = false;
|
||||||
|
float m_current_approx_error;
|
||||||
|
|
||||||
// Timer for continuous screen-updates
|
// Timer for continuous screen-updates
|
||||||
QBasicTimer m_timer;
|
QBasicTimer m_timer;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue