Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple quickwindow scenegraph couldn't render correct #80

Open
msinamsh opened this issue Feb 28, 2024 · 4 comments
Open

multiple quickwindow scenegraph couldn't render correct #80

msinamsh opened this issue Feb 28, 2024 · 4 comments

Comments

@msinamsh
Copy link

msinamsh commented Feb 28, 2024

@cinderblocks
@jcelerier
@jarkkokoivikko-code-q
@NielsMayer
i designed an app using scenegraph for rendering some 2d on qtquick and qml. My goal is render some 2d content on main window and another 2d content on a seprate window. I load my app from c++ with this code :
`
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#ifndef QNANO_USE_RHI
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
#endif
#endif

const QUrl url(u"qrc:/NoroView/Main.qml"_qs);
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
    &app, []() { QCoreApplication::exit(-1); },
    Qt::QueuedConnection);

engine.load(url);

return app.exec();

`

and
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);

is for set graphics api for using on scene graph and its ok.
like this photo:

Screen Shot 2024-01-30 at 2 17 59 AM

Everything goes fine with just one window(main window) but when i open another seprate window to render second content on it using ApplicationWindow from qml texts on the main window get unreadable and content on the second window turn into mono color(just green) and the texts will get completely unreadable as you can see in below image

Screen Shot 2024-01-30 at 2 20 09 AM

and i think its because i cant use setgraphicsapi for second window that i opened from qml with ApplicationWindow

.
and maybe its because i should render scenegraph with multithread according to this link:
https://doc.qt.io/qt-6/qtquick-visualcanvas-scenegraph.html#what-if-there-is-no-or-more-than-one-window-visible

but i dont know how can i

@msinamsh
Copy link
Author

@jcelerier
@NielsMayer
@jarkkokoivikko-code-q
@gunrot
@mariuszmaximus
@BaCaRoZzo
@kgron
@jarkkokoivikko-code-q
please help me i use qnanopainter and all thing is good but i just stoped my project because of this problem

@QUItCoding
Copy link
Owner

@msinamsh I tested this today and was able to reproduce the issue when RHI is not used (so it worked with QNANO_USE_RHI). I think the issue is not about setting the OpenGL for multiple windows, but sharing the same QNanoPainter instance. Added a new QNANO_ENABLE_PAINTER_SHARING define with the new commit e46cfaf . When I disable QNANO_ENABLE_PAINTER_SHARING, QNanoPainter works for me from multiple windows.

If someone has more time to debug this, why it happens, propose alternative fix with sharing enabled etc. please do 🙂

@msinamsh
Copy link
Author

msinamsh commented Mar 1, 2024

@QUItCoding oww thanks a lot sir you make my day.
thank you very very much!

QUItCoding pushed a commit that referenced this issue Mar 1, 2024
Disable QNANO_ENABLE_PAINTER_SHARING to not share the same QNanoPainter
instance between QNanoQuickItemPainters. This may be required in some
use cases if the sharing causes issues. See issue #80.
@hartcw
Copy link
Contributor

hartcw commented Apr 24, 2024

In Qt, if you want to share OpenQL objects (textures etc) across multiple QOpenGLContexts, then you have to enable the Qt::AA_ShareOpenGLContexts attribute early when your app starts up.

QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);

For the QNanoWidget path, because each QNanoWidget gets its own QOpenGLContext instance, but the QNanoPainter is a global singleton, the app must enable this attribute if they use more than one QNanoWidget.

I'm not sure about the QNanoQuickItemPainter code paths, but maybe it is affected by the same issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants