summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/qgltf/qgltf.cpp42
1 files changed, 28 insertions, 14 deletions
diff --git a/tools/qgltf/qgltf.cpp b/tools/qgltf/qgltf.cpp
index 562e50911..91ecd5ba2 100644
--- a/tools/qgltf/qgltf.cpp
+++ b/tools/qgltf/qgltf.cpp
@@ -216,7 +216,9 @@ static inline QVector<float> ai2qt(const aiMatrix4x4 &matrix)
struct Options {
QString outDir;
+#ifndef QT_BOOTSTRAPPED
bool genBin;
+#endif
bool compact;
bool compress;
bool genTangents;
@@ -2450,23 +2452,31 @@ void GltfExporter::save(const QString &inputFilename)
QString gltfName = opts.outDir + basename + QStringLiteral(".qgltf");
f.setFileName(gltfName);
+
+#ifndef QT_BOOTSTRAPPED
if (opts.showLog)
qDebug().noquote() << (opts.genBin ? "Writing (binary JSON)" : "Writing") << gltfName;
- if (opts.genBin) {
- if (f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
- m_files.insert(QFileInfo(f.fileName()).fileName());
- QByteArray json = m_doc.toBinaryData();
- f.write(json);
- f.close();
- }
- } else {
- if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
- m_files.insert(QFileInfo(f.fileName()).fileName());
- QByteArray json = m_doc.toJson(opts.compact ? QJsonDocument::Compact : QJsonDocument::Indented);
- f.write(json);
- f.close();
- }
+ const QIODevice::OpenMode openMode = opts.genBin
+ ? (QIODevice::WriteOnly | QIODevice::Truncate)
+ : (QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
+ const QByteArray json = opts.genBin
+ ? m_doc.toBinaryData()
+ : m_doc.toJson(opts.compact ? QJsonDocument::Compact : QJsonDocument::Indented);
+#else
+ if (opts.showLog)
+ qDebug().noquote() << "Writing" << gltfName;
+
+ const QIODevice::OpenMode openMode
+ = QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text;
+ const QByteArray json
+ = m_doc.toJson(opts.compact ? QJsonDocument::Compact : QJsonDocument::Indented);
+#endif
+
+ if (f.open(openMode)) {
+ m_files.insert(QFileInfo(f.fileName()).fileName());
+ f.write(json);
+ f.close();
}
QString qrcName = opts.outDir + basename + QStringLiteral(".qrc");
@@ -2509,8 +2519,10 @@ int main(int argc, char **argv)
cmdLine.setApplicationDescription(QString::fromUtf8(description));
QCommandLineOption outDirOpt(QStringLiteral("d"), QStringLiteral("Place all output data into <dir>"), QStringLiteral("dir"));
cmdLine.addOption(outDirOpt);
+#ifndef QT_BOOTSTRAPPED
QCommandLineOption binOpt(QStringLiteral("b"), QStringLiteral("Store binary JSON data in the .qgltf file"));
cmdLine.addOption(binOpt);
+#endif
QCommandLineOption compactOpt(QStringLiteral("m"), QStringLiteral("Store compact JSON in the .qgltf file"));
cmdLine.addOption(compactOpt);
QCommandLineOption compOpt(QStringLiteral("c"), QStringLiteral("qCompress() vertex/index data in the .bin file"));
@@ -2533,7 +2545,9 @@ int main(int argc, char **argv)
cmdLine.addOption(silentOpt);
cmdLine.process(app);
opts.outDir = cmdLine.value(outDirOpt);
+#ifndef QT_BOOTSTRAPPED
opts.genBin = cmdLine.isSet(binOpt);
+#endif
opts.compact = cmdLine.isSet(compactOpt);
opts.compress = cmdLine.isSet(compOpt);
opts.genTangents = cmdLine.isSet(tangentOpt);