QmlOgre is now a library

After some extensive refactoring, QmlOgre is now a library, making the integration of Ogre into Qt QML scenes even easier. The library comes with the original QmlOgre sample application, adapted to work with the new library code.

Let me know in the comments what you think. More updates to the code are on the way as time permits.

QmlOgre Screenshot


19 thoughts on “QmlOgre is now a library

  1. Hi Paulo, I want one too :p
    But seriously, I don’t have time to write something at the moment. On a very high level, what you’d do is download a copy of QmlOgre, compile it, then take the resulting library and use it with your code like any other shared library. Headers are available in the “lib“ folder of the project.

  2. Hi,

    I’m using Linux and i have errors when i try to compile.
    /usr/local/include/boost/system/error_code.hpp:222: error: undefined reference to `boost::system::generic_category()’

    When I ve looked into the lib.pro i ‘ve noticed that the included path and libs for boost was missing :
    So i ‘ve add :
    INCLUDEPATH += -L /usr/local/lib/
    LIBS += -lboost_system

    But now i ‘ve got new errors :

    : error: .obj/main.o: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv’
    : error: note: ‘_ZN5boost6system15system_categoryEv’ is defined in DSO /usr/local/lib/libboost_system.so.1.54.0 so try adding it to the linker command line

    Any Idea?



  3. Hi Hugox,

    The Linux builds don’t require Boost as far as I can tell, so there shouldn’t be any need to include it. Have you tried building without it? Furthermore, you are including version 1.54 while the original configuration uses 1.42 on OS X and Windows. Perhaps you also forgot to run qmake after changing the project file?

    If you still can’t find out why your build isn’t working, try asking on stackoverflow.com as your question appears independent of QmlOgre.

  4. I’m just curious – how likely is it that we’ll get this project with Direct3D9/11 support? Is anything in the works for this at all, or would one have to write that part on their own?

    I like that OpenGL is used for cross platform support, but it’d be neat if all I had to do to use DX was “flip a switch”.

  5. Hi Phillip,

    Even though Ogre offers Direct3D rendering, Qt is built upon OpenGL. To my knowledge there is no way to have Direct3D content rendered into OpenGL framebuffers, therefore the chances of seeing a QML Direct3D integration are practically zero.

    I don’t know the scope and stage of your project, however if you’re starting something new, you should seriously consider using OpenGL. At this point in time it will give you a _much_ larger market to address than building on Direct3D.

  6. Ok it’s me again….

    So I’ve found out why I had some error message like :

    : error: .obj/main.o: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv’
    : error: note: ‘_ZN5boost6system15system_categoryEv’ is defined in DSO /usr/local/lib/libboost_system.so.1.54.0 so try adding it to the linker command line

    It was because I was using boost 1.54 instead of boost 1.49….
    So the simplest way is to uninstall all the boost and Ogre version (manualy installed) you had and to get all the stuff (boost 1.49 and ogre 1.8) from dpkg….


    But depending of the machine you should problably have some problems…
    Because the .pro is made for the ogre version manualy installed…
    So if your on linux you could correct in a dirty way (I assume) :

    CONFIG += link_pkgconfig
    INCLUDEPATH += -L /usr/include/OGRE/

    instead of -L /usr/local/include/OGRE/

    and transform all the #include into #include ” /usr/include/OGRE/Ogre.h”

    I know that ‘s Horrible! And there is The other way… but This is a quick way to correct it….

    Also you will need to copy the resources.cfg and plugin.cfg into the build repertory

    I’ve still have a problem with the zip which seem to be not found….

    OGRE EXCEPTION(7:InternalErrorException): resources/data.zip – error whilst opening archive: Unable to read zip file. in ZipArchive::checkZzipError at /build/buildd/ogre-1.8-1.8.0+dfsg1/OgreMain/src/OgreZip.cpp (line 297)
    The program has unexpectedly finished.

    If anybody have an idea?

    I think it comes from the location of the data.zip (which contains all mesh and data) but I don’t know!

    Anyway! It works without the data! So thank you very much!!


  7. Hi Hugox,

    the data.zip file needs to be in the directory of the example application when you run it. You can copy it there manually or simply instruct Qt Creator to run the “make install“ step after a build finishes. This step is already configured in the example.pro file and will copy the file to the build output folder for you when executed.

    So, to add this step in Qt Creator, please see http://stackoverflow.com/a/11598991


  8. Hi Markus,

    this is really great work. I’ve successfully compiled your code, even though I need to do some other animation stuff inside the ogre scene and I need your help if possible. Can I contact you via email to ask some questions (because they may not be useful here) or would you prefer to post them here ?


  9. Hi Nedal,

    Thanks for your feedback.

    I prefer replying to comments or questions here as other people will be able to see the discussion, too. However, if your questions are not related to QmlOgre, your better choice is to post on stackoverflow.com or the Ogre forums.


  10. Hi Markus, it’s d3ce1t (or Jose Padilla) here. I forked your repository some months ago, did you remember?. Well, I’m in sync with your latest changes now. Nevertheless, this post wasn’t for saying this but next:

    Have you tried in OgreNode::updateFBO() (in ogrenode.cpp) to set a background 100% transparent? (I mean RGBA(0.0, 0.0, 0.0, 0.0) ). In an ideal world, we should get the color of any thing that is under it, isn’t it?. However, I always get a black background.

    I’ve tried to work it out but it seems that the only workaround is to use QQuickFramebufferObject instead of QQuickItem in OgreItem class and then render the Ogre texture inside of the QQuickFrameBufferObject provide FBO.

    I fixed this issue in my branch, but I’m not still sure if it’s a QQuickItem bug or something else.

  11. By the way, I can confirm that in order to build in Ubuntu 13.10 it’s required to add “LIBS += -lboost_system” in both lib.pro and example.pro. It seems that OGRE pkg_config doesn’t include Boost dependency anymore (I think it was included in previous version of Ubuntu, but I can’t tell).

  12. Hi Jose,

    Good point regarding transparency. I assume it has to do with https://github.com/advancingu/QmlOgre/blob/master/lib/ogrenode.cpp#L36-L37 . Also read the documentation on http://qt-project.org/doc/qt-5.1/qtquick/qsgopaquetexturematerial.html and http://qt-project.org/doc/qt-5.1/qtquick/qsgtexturematerial.html .

    I would guess the QSGOpaqueTextureMaterial will need to be skipped, using only QSGTextureMaterial or something similar. Perhaps you also need to set the QSGMaterial::Blending flag in http://qt-project.org/doc/qt-5.1/qtquick/qsgmaterial.html#Flag-enum .

    Hopefully this gets you somewhere. Let me know. Sorry I don’t have more time to look into it at the moment.


  13. Hi Markus,
    I’m currently trying to integrate QmlOgre as well, and I’m facing some difficulties (Please correct me if you see anything stupid) :

    So far, here is what I’ve understood:
    When initializing QT & Ogre’s GL contexts, i.e. during the initializeOgre method in the provided example, the program is in Qt’s Rendering thread. This is mandatory, since the 2 need to share textures etc…
    Adding stuff to the scene from any other thread is not possible, since it requires to have access to Ogre’s context (activateOgreContext/doneOgreContext from the example).

    However, one may want to add stuff to an Ogre scene at any point during the execution of the program (at startup, on user click,, etc…) and those mostly happen outside of that thread.

    Any idea on what would be the simplest solution to handle that ?
    I’m currently trying to switch to the proper thread when adding stuff/getting an event, but I’d like to know if there is an easier solution, as this is really not a convenient nor elegant solution.

    Appart from that, switching from my previous solution (a basic createRenderWindow) to QmlOgre was pretty smooth and works fine, so thanks for it 🙂

  14. Hi Antoine,

    Unfortunately there does not seem to be an easy way. I spent quite some time myself on this.

    What you will basically need to do is drop any scene-modifying command (objection creation, camera movement, etc.) triggered in the QML engine thread into a queue and only process that queue once you are in the rendering thread.

    In regard to camera movement, you can actually see this issue in the QmlOgre sample application: When you move the camera rapidly, it flickers for about one frame from time to time. This is a race condition between the two threads as the sample application modifies camera data directly from QML. If you use a command queue instead as described above, this issue will go away. The downside is that it is not that easy to implement.

    Hope this helps.

  15. Hi and thanks for the reply;

    Oh that’s not a bad idea at all ! Actually, I already have a command manager for undo/redos, so it could be quite easy to handle with it.

    Just for the record, another solution I found is to disable the threaded rendering by setting the QSG_RENDER_LOOP environment variable to “basic”. It shouldn’t have much impact in applications with small rendering loops, and it’s already disabled on some OS’s. Working fine for now, but I’ll definitly go for the command manager solution one day.

    Thanks again

  16. Hi, I’m trying to compile the library with Qt Creator. I get the .dll file, but there is no .lib file required to compile the example… Am I doing something wrong? Could you help?

    Thanks in advance.

  17. Hi Markus,

    I’m having warnings, due to double usage of opengl, when including and ogre GL related stuff :
    > #warning qopenglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
    > #warning To use GLEW with Qt, do not include or after glew.h

    do you think those can be troublesome later ? I can’t really think of any way to remove them, as both of them are required.
    Also, did you have any issues when trying qmlogre on multiple platforms ?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s