qtquick2 - QtQuick custom OpenGL rendering -


i using qtquick custom opengl renderer (custom point of view of qtquick openscenegraph). in order create custom qquickitem inheriting qquickframebufferobject , in turns creates custom renderer inheriting qquickframebufferobject::renderer in qquickframebufferobject::createrenderer(). documented , there no problem these steps.

now happens in order later accessed, renderer created in qquickframebufferobject::createrenderer() cached (it instantiated in qquickframebufferobject constructor , returned in qquickframebufferobject::createrenderer(). works fine , can see no straightforward other way code created renderer later used react events such geometrychanged or mousepressevent, e.g.

//////////////////////////////////////////////////////////////////////////////// void osgitem::geometrychanged(const qrectf& newgeometry, const qrectf& oldgeometry) {     if (m_renderer)         m_renderer->m_window->geteventqueue()->windowresize(newgeometry.x(), newgeometry.y(), newgeometry.width(), newgeometry.height());       qquickframebufferobject::geometrychanged(newgeometry, oldgeometry); }  //////////////////////////////////////////////////////////////////////////////// void osgitem::mousepressevent(qmouseevent *event) {     m_renderer->m_window->geteventqueue()->mousebuttonpress(event->x(), event->y(), button(*event));      update(); } 

, osgitem custom qquickframebufferobject , m_renderer custom qquickframebufferobject::renderer.

the problem createrenderer() const (which not invitation cache things), , this paper states renderer should not cached -(although not stated in official doc).

what's catch here? there have missed? can see clean way code things?

velkan provided principle of integrating raw/custom opengl qquickframebufferobject. have finished project integrates osg , qtquick, i'd share of our experiences.

yes of course, should never cache renderer. createrenderer const reason, , that's how qt team designed classes. according our experiments, createrenderer function may called multiple times.

to sync between qquickframebufferobject , renderer, add qqueue in qquickframebufferobject, , when events interested happen, put them in queue. , in renderer, when synchronize called, copy queue fbo renderer, , execute operations in render function.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -