Files
RedBear-OS/recipes/wip/qt/qtquick3d/source/tools/lightmapviewer/lightmapviewer.cpp
T
vasilito ff4ff35918 feat: track all source trees in git — full fork offline-first model
Red Bear OS is a full fork. All sources must be available from git clone
with zero network access. Removed gitignore rules that excluded fetched
source trees under recipes/*/source/, local/recipes/kde/*/source/,
local/recipes/qt/*/source/, and vendor source trees.

Build artifacts (target/, build/, source.tar, *.o, *.so) remain excluded.

127291 files added — kernel, relibc, base, bootloader, pkgar, all KDE/Qt
frameworks, mesa, wayland, DRM drivers, and every other recipe source.
2026-05-14 10:55:53 +01:00

76 lines
2.7 KiB
C++

// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "lightmapfile.h"
#include "lightmapimageprovider.h"
#include "lightmapviewerhelpers.h"
#include <QCoreApplication>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QDebug>
int main(int argc, char *argv[])
{
QString input;
// We Handle all the command line parts first in its own QCoreApplication
// since we don't want to create a gui application which would not work if
// running through ssh for instance.
{
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationName("Qt LightmapViewer");
QCoreApplication::setApplicationVersion("1.0");
QCommandLineParser parser;
parser.setApplicationDescription("A tool for viewing Qt's baked lightmaps");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption printOption("print", "Print the content of the lightmap");
QCommandLineOption extractOption("extract", "Extract the lightmap contents into the current working directory");
parser.addOption(printOption);
parser.addOption(extractOption);
parser.addPositionalArgument("input", "Optional path to lightmap");
parser.process(app);
bool doPrint = parser.isSet(printOption);
bool doExtract = parser.isSet(extractOption);
const QStringList positionalArgs = parser.positionalArguments();
input = positionalArgs.isEmpty() ? QString() : positionalArgs.first();
if (doPrint && input.isEmpty()) {
qFatal() << "Print option selected with no lightmap.";
return 1;
}
if (doExtract && input.isEmpty()) {
qFatal() << "Extract option selected with no lightmap.";
return 1;
}
if (doPrint || doExtract)
return !LightmapViewerHelpers::processLightmap(input, doPrint, doExtract);
}
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, &app, []() { QCoreApplication::exit(-1); }, Qt::QueuedConnection);
LightmapFile *file = new LightmapFile();
if (!input.isEmpty())
file->setSource(QUrl::fromLocalFile(input));
file->loadData();
qmlRegisterSingletonInstance("LightmapFile", 1, 0, "LightmapFile", file);
LightmapImageProvider *provider = new LightmapImageProvider;
engine.addImageProvider(QLatin1String("lightmaps"), provider);
engine.loadFromModule("QtQuick3D.lightmapviewer", "LightmapViewer");
return app.exec();
}