diff --git a/src/modelmeshbinder.cpp b/src/modelmeshbinder.cpp index de042297..81092da2 100644 --- a/src/modelmeshbinder.cpp +++ b/src/modelmeshbinder.cpp @@ -36,12 +36,12 @@ void ModelMeshBinder::exportMeshAsObj(const QString &filename) if (file.open(QIODevice::WriteOnly)) { QTextStream stream(&file); stream << "# " << Ds3FileReader::m_applicationName << endl; - for (std::vector::iterator it = m_mesh->vertices().begin() ; it != m_mesh->vertices().end(); ++it) { + for (std::vector::const_iterator it = m_mesh->vertices().begin() ; it != m_mesh->vertices().end(); ++it) { stream << "v " << (*it).x() << " " << (*it).y() << " " << (*it).z() << endl; } - for (std::vector>::iterator it = m_mesh->faces().begin() ; it != m_mesh->faces().end(); ++it) { + for (std::vector>::const_iterator it = m_mesh->faces().begin() ; it != m_mesh->faces().end(); ++it) { stream << "f"; - for (std::vector::iterator subIt = (*it).begin() ; subIt != (*it).end(); ++subIt) { + for (std::vector::const_iterator subIt = (*it).begin() ; subIt != (*it).end(); ++subIt) { stream << " " << (1 + *subIt); } stream << endl; @@ -107,12 +107,14 @@ void ModelMeshBinder::paint() if (m_showWireframes) { if (m_renderEdgeVertexCount > 0) { QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoEdge); - glDrawArrays(GL_LINES, 0, m_renderEdgeVertexCount); + QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); + f->glDrawArrays(GL_LINES, 0, m_renderEdgeVertexCount); } } if (m_renderTriangleVertexCount > 0) { QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoTriangle); - glDrawArrays(GL_TRIANGLES, 0, m_renderTriangleVertexCount); + QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); + f->glDrawArrays(GL_TRIANGLES, 0, m_renderTriangleVertexCount); } } diff --git a/src/modelofflinerender.cpp b/src/modelofflinerender.cpp index 3101b245..385186df 100644 --- a/src/modelofflinerender.cpp +++ b/src/modelofflinerender.cpp @@ -67,11 +67,11 @@ QImage ModelOfflineRender::toImage(const QSize &size) meshBinder.hideWireframes(); program->setUniformValue(program->lightPosLoc(), QVector3D(0, 0, 70)); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - glEnable(GL_LINE_SMOOTH); + + m_context->functions()->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + m_context->functions()->glEnable(GL_DEPTH_TEST); + m_context->functions()->glEnable(GL_CULL_FACE); + m_context->functions()->glEnable(GL_LINE_SMOOTH); camera.setToIdentity(); camera.translate(0, 0, -2.1); diff --git a/src/modelwidget.cpp b/src/modelwidget.cpp index 474154c6..92017c1c 100644 --- a/src/modelwidget.cpp +++ b/src/modelwidget.cpp @@ -9,7 +9,7 @@ // Modifed from http://doc.qt.io/qt-5/qtopengl-hellogl2-glwidget-cpp.html -bool ModelWidget::m_transparent = true; +bool ModelWidget::m_transparent = false; ModelWidget::ModelWidget(QWidget *parent) : QOpenGLWidget(parent), diff --git a/src/skeletongraphicswidget.h b/src/skeletongraphicswidget.h index 3d641bc2..a5f07ddb 100644 --- a/src/skeletongraphicswidget.h +++ b/src/skeletongraphicswidget.h @@ -13,6 +13,7 @@ #include "skeletondocument.h" #include "turnaroundloader.h" #include "theme.h" +#include "util.h" class SkeletonGraphicsSelectionItem : public QGraphicsRectItem { diff --git a/src/util.h b/src/util.h index 4f614e9b..841c717a 100644 --- a/src/util.h +++ b/src/util.h @@ -2,6 +2,11 @@ #define UTIL_H #include #include +#include + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif QString valueOfKeyInMapOrEmpty(const std::map &map, const QString &key); bool isTrueValueString(const QString &str);