OpenGL and qml
Hi! I want to draw and object and then import it to qml, as the logic app is done in qml. I have read that to use OpenGL I can use Openglwidget or Openglwindow. I have tried which would be better to import to qml but I have found nothing. Someone know which one would be better to use?
I don't really understand what you're trying to do, but when I want to use some C++ & OpenGL code within a QML app, then I put the code in a
QQuickFramebufferObjectsubclass and register the type with
qmlRegisterType(and the app QML is hosted in a
QQuickFramebufferObjectis a little tricky to use due to the need to separate out a
QQuickFramebufferObject::Rendererand copy any needed state over to it to support QSG's separate render thread. Don't be tempted to take shortcuts, your code will crash.
@timday Hi! thank you for answering me. I'm new to Qt and I don't really know much so I've searching about what you told and I have come across this example
It's not exactly what you said but I don't find any other examples... Do you know some?
What I meant in my previous post is that I have an .obj that I want to draw, so I have created a class to read it and then a class to render it. What I didn't know was if it was better to put:
class Renderingwindow : public QOpenGLWindow, protected QOpenGLFunctions
or using QopenglWidget. Reading what you said maybe it isn't possible to do it my way and I have to try using QQuickFramebufferobject.
@Carolinabustillo Hmmm I'd have said that was the old and a bit limited way of doing things in early versions of Qt5 before QQuickFramebufferObject came along. See http://blog.qt.io/blog/2015/05/11/integrating-custom-opengl-rendering-with-qt-quick-via-qquickframebufferobject/ for a more modern and flexible approach (or at least I find it works for me better). I think there are a couple of examples linked from the "Mixing Scene Graph and OpenGL" section of http://doc.qt.io/qt-5/qtquick-visualcanvas-scenegraph.html