Qt5 port update coming

Cocos2dx 3.0 alpha has experimental port to Qt5, as well as QtCreator integration for Linux. Right now I’m working on fixing this port in my personal repo [1], feel free to join. When all planned changes will be finished, I’ll make pull request to upstream repository [2].

Original Qt5 port created by other contributor who probably targeted it for Mer (or Jolla) devices. I’m going to make it usable also on desktop Linux, and save place for Ubuntu Phone port.

What’s done:
# Adjusted Qt5 for desktop Linux: added mouse and keyboard support (thanks to Carlos Ferney), added Desktop OpenGL support, made window not resizable;
# Implemented effect loop and gain in CocosDenshion (I personally prefer OpenAL instead of QtMultimedia, but not sure if Ubuntu Phone and Mer support OpenAL);
# Fixed issues in QtCreator project part for native Linux port (that uses SDL+OpenAL)
# Changed doxygen config to generate QtCreator help files: now you can go to ${cocos2d}/document directory, run command “doxygen doxygen.config” in terminal, wait until ${cocos2d}/document/qtcreator/cocos2dx.qch generated and than add it in QtCreator Options->Help page; after that you’ll be able to get cocos2dx API reference directly in QtCreator. Note that doxygen 1.8.x has bug which breaks QtCreator help generation; if you’re using Ubuntu 13.04 or 13.10, you can just uninstall doxygen and doxygen-gui packages, go to [3], download both built files (see page bottom) and install them in Software Center; you’ll get doxygen 1.7.x which doesn’t have this bug.
# Added QtCreator project for Qt5 and Linux Native platforms to template/multi-platform-cpp

TODO list:
# Add Travis CI scripts to ensure that Qt5 port will always build normally
# Add QtCreator project to template/multi-platform-lua and to template/multi-platform-js
# Port Qt5 platform backend to win32 and MacOSX, if possible
# Add win32 support to QtCreator project in template/multi-platform-cpp, if possible
# Write more documentation on Wiki, like [4]

[1] https://github.com/sergey-shambir/cocos2d-x/commits/qt_update
[2] https://github.com/cocos2d/cocos2d-x
[3] https://launchpad.net/ubuntu/+source/doxygen/1.7.6.1-2ubuntu1/+build/3392241
[4] http://cocos2d-x.org/projects/cocos2d-x/wiki/QtCreator_project_setup_on_Linux#QtCreator-project-setup-on-Linux

Sergey Shambir wrote:

Cocos2dx 3.0 alpha has experimental port to Qt5, as well as QtCreator integration for Linux. Right now I’m working on fixing this port in my personal repo [1], feel free to join. When all planned changes will be finished, I’ll make pull request to upstream repository [2].

Sounds great!

Good to be that there is cocos2d-x port for Linux but … It’s good idea mixup Qt5 code to BSD cocos2d-x project since Qt is uses GPL, LGPL and commercial (three-license) model and cocos2d-x is use BSD style license?

Please fix me if I’m wrong about this issue but I would like sure about this license mixup.

Olli-Pekka Wallin wrote:

Good to be that there is cocos2d-x port for Linux but … It’s good idea mixup Qt5 code to BSD cocos2d-x project since Qt is uses GPL, LGPL and commercial (three-license) model and cocos2d-x is use BSD style license?
>
Please fix me if I’m wrong about this issue but I would like sure about this license mixup.

You can’t statically link Qt to your binary the way you probably do with cocos2d-x; however, if the platform allows it (i.e. any platform but iOS), you can link Qt dynamically and still conform to the LGPL license.

I’m curious how Qt’s official iOS port handles this - my guess is you’ll have to purchase a license from Digia and statically link your iOS Qt executables.

Qt is great. However, I wonder what value brings into Cocos2d? Qt5 offers fairly advanced scene graph (QML) and cross platform support, though Cocos2d also does that. In the end you will be laying one platform abstraction (cocos2d) on top of another platform abstraction (Qt) on top of the real platform.

Though I haven’t successfully compiled cocos2d-x/qt5 yet (it complains about missing headers, haven’t had time to look into it yet), having cocos2d-x’s application object and event loop play nice with QApplication is probably going to save me a lot of work, since I’m implementing the level/asset editor for our cocos2d-x game in Qt.

Right now the Qt editor communicates with the cocos2d-x game engine using boost::ipc with shared memory and message passing, but it’d be nice to have both the editor and the game engine in the same process so they can share level data etc directly.

Has anyone ever successfully build cocos2d-x on Qt5?
I just test with the cocos2d-x-3.0alpha0 but it seem there is alot of issues for Qt5 port!

The code that is bundled in cocos2d-x v3.0-alpha0 is an old code.
Probably you should use Sergey’s patches instead.

There is most recent update: https://github.com/sergey-shambir/cocos2d-x/commits/qt_update_2

I’ve made pull request, but there was big change right after it. So at next week I’ll make another update with polishing build configuration.

great! Thanks sergey.

Sergey,

I’ve made a few modifications that allow the Qt port to compile and run on my Mac.

To incorporate my changes, do you want me to 1) put my tree in a github repo, so you can diff against it or I can send pull requests, or 2) describe the changes here or in private mail?

Sergey:

Do you think it would be a good idea to enable no_keywords in the Qt config? In my application, the “slots” keyword clashes with the spine extension, where a class Slot is defined. (I’ve solved it temporarily by putting “#undef slots” in the affected files).

Oh, yes, thanks for this hint. There also was issues with TestCpp sample game which uses “forever” as variable name, and no_keywords is much cleaner solutions for this.

And yes, please put mac port to github and describe here applied changes; it’s excellent job.

Ok! I’ll probably have time to work on this early next week, so I’ll let you know when my repo is ready for you to have look.

Hi, I’m new in ubuntu and in cocos2d-x also. cocos i downloaded from https://github.com/sergey-shambir/cocos2d-x/commits/qt_update_2
I’ve got a problem with compiling cocos2d-x on Qt.
in terminal i write ./make-all-linux-project.sh but while compiling i get an error

…/textures/CCTextureCache.cpp:105:99: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘std::Hashtable<std::basic_string, std::pair<const std::basic_string, cocos2d::Texture2D*>, std::allocator<std::pair<const std::basic_string, cocos2d::Texture2D**> >, std::*Select1st<std::pair<const std::basic_string, cocos2d::Texture2D*> >, std::equal_to<std::basic_string >, std::hash<std::basic_string >, std::*detail::*Mod_range_hashing, std::**detail::*Default_ranged_hash, std::*detail::_Prime_rehash_policy, true, false, true>::size_type {aka unsigned int}’ [-Werror=format]

could anybody help me? I would be pleased any help.
thanks.

How can i use Qt5 to run cocos2dx2.2?

Hi, brother.Had you tried to combined cocos2d opengl view with qmlview into one scene?
I had tried put cocos mainloop into a class which sub QQuickItem.
It looked well without other quickitems but gl texture missing with other items.