Canvas::Canvas(const QGLFormat& format, QWidget *parent)
: QGLWidget(format, parent), mesh(NULL),
- scale(1), tilt(90), yaw(0)
+ scale(1), tilt(90), yaw(0), status(" ")
{
// Nothing to do here
}
update();
}
+void Canvas::clear_status()
+{
+ status = "";
+ update();
+}
+
void Canvas::initializeGL()
{
mesh_shader.addShaderFromSourceFile(QGLShader::Vertex, ":/gl/mesh.vert");
backdrop->draw();
if (mesh) draw_mesh();
+ if (status.isNull()) return;
+
QPainter painter(this);
- if (!status.isNull())
- painter.drawText(10, height() - 10, status);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.drawText(10, height() - 10, status);
}
QMatrix4x4 m;
if (width() > height())
{
- m.scale(height() / float(width()), 1, 0.5);
+ m.scale(-height() / float(width()), 1, 0.5);
}
else
{
- m.scale(1, width() / float(height()), 0.5);
+ m.scale(-1, width() / float(height()), 0.5);
}
return m;
}
{
auto p = event->pos();
auto d = p - mouse_pos;
- yaw = fmod(yaw + d.x(), 360);
+ yaw = fmod(yaw - d.x(), 360);
tilt = fmax(0, fmin(180, tilt - d.y()));
mouse_pos = p;
update();