只要.qml文件加入到qrc文件中(Qt for Android推荐使用qrc),在qml设置如source的路径时,非远程(http等)和非file:///开头的,都从qrc资源文件里面找。如果非从sdcard中加载,就用file:///开头。
osg整合到QtQuick确实有点复杂,要了解Quick渲染的实现机制,官方文件也说了支持在Quick加混合使用OpenGL,但有一些要注意的地方,一些官方原文抄录如下:
Integration with OpenGL
It is possible to integrate OpenGL calls directly into the QQuickWindow using the same OpenGL context as the Qt Quick Scene Graph. This is done by connecting to the QQuickWindow::beforeRendering() or QQuickWindow::afterRendering() signal.
Note: When using QQuickWindow::beforeRendering(), make sure to disable clearing before rendering with QQuickWindow::setClearBeforeRendering().
Warning: It is crucial that OpenGL operations and interaction with the scene graph happens exclusively on the rendering thread, primarily during the updatePaintNode() phase.
Warning: As signals related to rendering might be emitted from the rendering thread, connections should be made using Qt::DirectConnection.
因我之前没做过类似的东西,所以无法给你提供更详细的帮助,但我觉得官方文档这几点“注意”是很重要的。还有例子源代码中有这一句:
void frame() {
if (!compositeViewer.valid()) return;
// Qt bug!?
QOpenGLContext::currentContext()->functions()->glUseProgram(0); //这里是否必要??
compositeViewer->frame();
}