podsvirov / osgqtquick

Intergation OpenSceneGraph to Qt Quick
https://podsvirov.github.io/osgqtquick
MIT License
73 stars 32 forks source link

osgQtQuick can use .earth file, but when i use earth's some Advanced Features. find error #8

Open youngerking1985 opened 8 years ago

youngerking1985 commented 8 years ago

hi: osgQtQuick can use .earth file, but when I use earth's some Advanced Features. such as "terrain-gpu", or "terrain-drape", viewport don't display anything, just black。 with osgearth/tests/feature_draped_polygons.earth can reappear this issue.

thanks

podsvirov commented 8 years ago

Hello!

Give more information: the operating system, compiler, Qt version, OSG version, osgEarth version, osgQtQuick version?

Yes: osgQtQuick provide base osgEarth support. See earth.qml test script.

My test environment: Windows 7, Qt 5.3/5.5, OSG 3.4, osgEarth 2.7, osgQtQuick from develop.

For you examples, I get black screen too, but some other examples work good. Qt Quick it changes lately. It is necessary to improve the implementation of rendering in osgQtQuick.

youngerking1985 commented 8 years ago

Hi, podsvirov

Thanks for your prompt response.

My test environment: Windows7, Qt 5.5.1, OSG 3.4.0, osgEarth(Master), osgQtQuick from develop, visual studio 2012 x64 compiler.

Most osgEarth examples work good too. once use "terrain-gpu" or "terrain-drape", get black screen.

Thanks

podsvirov commented 8 years ago

Since Qt 5.5 on the windows (MSVC), I see the problem with the change of the window size. The application falls with an error memory reference in Qt5Gui library. I think that the need new improved rendering implementation based on FBO and multithreading support. I'm developing a project in their spare time and do not know how soon it will implement ...

youngerking1985 commented 8 years ago

Hi, podsvirov

The problem with the change of the window size, I meet too. It is caused by Qt modify default render mode. Qt has three render mode(..\qtdeclarative\src\quick\scenegraph\qsgrenderloop.cpp). BasicRenderLoop, ThreadedRenderLoop WindowsRenderLoop

Since Qt 5.5, default render mode is modified to "ThreadedRenderLoop", so when windows size changed, recreate fbo, will occur error.

I just continue use WindowsRenderLoop mode, can avoid this problem by add code before application created: qputenv("QSG_RENDER_LOOP", "windows");

podsvirov commented 8 years ago

Thank you for the valuable information. I do not find this documentation Qt (maybe bad looking). You can tell the address of the page with a description of environment variables affect the behavior of the Qt? As for the main issue, it is necessary to well understand the content to render through synchronization of the FBO in different Qt rendering loop. At the moment, we can not use the advanced capabilities of the osgEarth library. And ask you a question for me is difficult. For the osgEarth library is now implemented ErthManipulator class (import osgEarthUtil). There are more candidates in order of priority?

youngerking1985 commented 8 years ago

These render parts need to look over Qt source code because they are implemented in .cpp file _D:\Qt\Qt5.5.1x64\qt-everywhere-opensource-src-5.5.1\qtdeclarative\src\quick\scenegraph\qsgrenderloop.cpp You can look over this func: QSGRenderLoop::instance()

qsgthreadedrenderloop.cpp ---related to independent thread to render, this is default since Qt 5.5 qsgwindowsrenderloop.cpp ---render thread in main window thread, this is default before Qt 5.5

if use QSGThreadedRenderLoop, we can't get QOpenGLContext::currentContext() when window size changed, because window size changed event triggered by window thread. we can only get QOpenGLContext::currentContext() in QSGThreadedRender thread.

follow as function call when create QOpenGLFramebufferObject. QOpenGLFramebufferObject() QOpenGLFramebufferObjectPrivate::init QOpenGLFunctions::initializeOpenGLFunctions() qt_gl_functions-----> need currentContext()

static QOpenGLFunctionsPrivateEx qt_gl_functions(QOpenGLContext context = 0) { if (!context) context = QOpenGLContext::currentContext(); Q_ASSERT(context); QOpenGLFunctionsPrivateEx *funcs = qt_gl_functions_resource()->value(context); return funcs; }


black screen maybe caused by Quick don't work with the creation of the FBO :see:http://forum.osgearth.org/black-screen-with-drape-mode-in-a-QOpenGLWidget-td7588548.html

JD31 commented 8 years ago

Hi, I found an old discussion about OsgEarth and OsgQtQuick plugin integration on the old forum: https://forum.qt.io/topic/30707/demo-integrating-openscenegraph-with-qt-quick

Maybe this will help.

JD.

podsvirov commented 8 years ago

Hello! Thank you for the search, but the author of this debate - that's me :-) Although you can read for reference.

Today, I learned about another project - QtQuick2OSGItem. It is possible that this experience can be useful.

podsvirov commented 8 years ago

Temporary solution: Rendering Limitations

JD31 commented 8 years ago

Please, note also that i did a patch for the drape technique. It is not based on your project but it should fix the issue the same way. http://forum.osgearth.org/black-screen-with-drape-mode-in-a-QOpenGLWidget-td7588548.html

podsvirov commented 8 years ago

Hello @youngerking1985 and @JD31, please review v2.0.0.8 release. It's include RenderLoopType support (you can direcly set environment varibable QSG_RENDER_LOOP to basic, windows or threaded) It's work for me with MSVC2013 32/64bit, OSG3.4, osgEarth2.7 at DaD's House: dad-0.3.1-windows-vc12x64-testing.exe or dad-0.3.1-windows-vc12x86-testing.exe.

youngerking1985 commented 8 years ago

@podsvirov well done. v2.0.0.8 perfectly solved this problem by using ThreadedRenderLoop mode

youngerking1985 commented 8 years ago

@podsvirov I use d.renderLoopType = ThreadedRenderLoop; this version is work well in my notebook, graphics card is nvidia GT540M. however is not work in my desktop pc, graphics card is nvidia GT625, errors follow as:

Warning: detected OpenGL error 'invalid enumerant' after applying GLMode 0xb50 Warning: detected OpenGL error 'invalid enumerant' after applying GLMode 0x4000 Warning: detected OpenGL error 'invalid operation' after applying attribute Material 0000000002A0E1E0 Warning: detected OpenGL error 'invalid operation' after applying attribute LightModel 0000000004196F50 Warning: detected OpenGL error 'invalid enumerant' after applying GLMode 0xb50 Warning: detected OpenGL error 'invalid enumerant' after applying GLMode 0x4000 Warning: detected OpenGL error 'invalid enumerant' after applying attribute Material 0000000005D4FAB0 Warning: detected OpenGL error 'invalid operation' after applying attribute LightModel 0000000005CC12D0

podsvirov commented 8 years ago

Hello @youngerking1985, thanks for you expirience. Unfortunately now I am not an expert in the GL and Hardware. For me it's work on my old notebook, with graphics card is nvidia G102M. This also works for a number of today's desktops. You can try pre-built version of my installers listed above? Now it's based on MSVC2013 and Qt 5.7.

podsvirov commented 7 years ago

Ping. Any feedback.