Files
RedBear-OS/local/recipes/qt/qtbase/source/examples/vulkan/hellovulkancubes/mesh.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

52 lines
1.2 KiB
C++

// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mesh.h"
#include <QtConcurrentRun>
#include <QFile>
void Mesh::load(const QString &fn)
{
reset();
m_maybeRunning = true;
m_future = QtConcurrent::run([fn]() {
MeshData md;
QFile f(fn);
if (!f.open(QIODevice::ReadOnly)) {
qWarning("Failed to open %s", qPrintable(fn));
return md;
}
QByteArray buf = f.readAll();
const char *p = buf.constData();
quint32 format;
memcpy(&format, p, 4);
if (format != 1) {
qWarning("Invalid format in %s", qPrintable(fn));
return md;
}
int ofs = 4;
memcpy(&md.vertexCount, p + ofs, 4);
ofs += 4;
memcpy(md.aabb, p + ofs, 6 * 4);
ofs += 6 * 4;
const int byteCount = md.vertexCount * 8 * 4;
md.geom.resize(byteCount);
memcpy(md.geom.data(), p + ofs, byteCount);
return md;
});
}
MeshData *Mesh::data()
{
if (m_maybeRunning && !m_data.isValid())
m_data = m_future.result();
return &m_data;
}
void Mesh::reset()
{
*data() = MeshData();
m_maybeRunning = false;
}