Forum > C++ > Cocos2d on Qt

Cocos2d on Qt

By q8phantom Posted 2012-02-08 14:54 Comments 30
q8phantom
  • Posts: 3

Hi there

this is it, no a complete cocos2d but some features ( Although the back-end is different, the front end is very similar)

http://projects.developer.nokia.com/cocos2d ( Full example is downloadable )

Why Cocos2d on Qt is important?

Qt now suuports most major platforms, so you properly going to have your game running on different platforms, writing your game once, without any modifications and releasing it to these OSes is simple, it supports

1 - Windows ( XP, Vista, 7, 8 … )
2 - Mac OSX
3 - Linux ( ubuntu, fedora )
4 - Symbian
5 - Android
6 - Windows CE
7 - iOS (iPhone, iPod and iPad)
8 - Coming soon ( Windows phone, yet not confirmed )

So why not, if this project gets larger and larger, we’ll have a great game engine, that you write your code once, and then deploy your game on different platforms with 0% port effort, I’ve personally tested the Qt port for iOS and Android, and I can tell that it’s amazing[]()

Best wishes
Ahmed

plicatibu
  • Posts: 111

#1 RE: 2012-02-11 01:41

Hi, Ahmed.

First of all I want to thank you for your effort. I really appreciate what you’re doing.

I saw the source code and it’s not in the same standard as other platforms on cocos2d-x.

Even the public interface used by developers to create games are different.

Shouldn’t you:

  • clone cocos2d-x source code

  • goto <COCOS2D-X ROOT>/cocos2dx/platform create a copy win32 folder and change it’s code to use QT APIs instead of win32 API?

This way:

  • you would have less code to develop (it would be possible to compile QT source to Symbian using Nokia’s SDK)

  • you would have more people interested to use your code.

  • it would let your code be integrated to official cocos2d-x source code tree.

Again, please, don’t get me wrong.

I know you’re putting a big effort and time to help community.

I’m just sharing my point of view because I’d like to see a QT port of cocos2d-x (you can see my idea about it here) but I wouldn’t want to learn another API and I guess many users think the same way.

Regards.


Please,

plicatibu
  • Posts: 111

#2 RE: 2012-02-11 02:01

Hi, Ahmed.

Just to complete my answer.

Suppose you’ve created a copy of

/cocos2dx/platform/win32

named

/cocos2dx/platform/qt

Then you would rename the _win32 part of the file names inside the qt folder:

CCAccelerometer_win32.h
CCApplication_win32.cpp
CCApplication_win32.h
CCEGLView_win32.cpp
CCEGLView_win32.h
CCFileUtils_win32.cpp
CCImage_win32.cpp

to

CCAccelerometer_qt.h
CCApplication_qt.cpp
CCApplication_qth
CCEGLView_qt.cpp
CCEGLView_qt.h
CCFileUtils_qt.cpp
CCImage_qt.cpp

and replace their implementation (that uses win32 API) with other that uses QT API.

Walzer and Minggo know better than me. They can correct me and guide you to the best way you can focus your efforts.

Regards.


Please,

q8phantom
  • Posts: 3

#3 RE: 2012-02-11 06:46

Hi Marcio,

I was trying to do what you’ve told me with no success because of my knowledge in OpenGL.

If you want to help me to try, let me know by adding me to a chat software like :

Skype:  q8spirit
MSN: q8.g@msn.Com

Or any other :)

bests :)
Ahmed

plicatibu
  • Posts: 111

#4 RE: 2012-02-11 15:57

Hi.

Unfortunately I’m not only a bad programmer that don’t know OpenGL.

I’m a bad programmer that don’t know OpenGL and that suffer with tendinitis.

Sorry.

Regards.


Please,

plicatibu
  • Posts: 111

#5 RE: 2012-02-11 20:46

Ahmed, there are two very interesting projects from BogDan Vatra:

Both projects are derived form QT lighthouse project.

As both projects have to deal with OpenGL integration, there are two possibilities:

1 - BogDan Vatra worked by himself to solve OpenGL integration;

2 - BogDan Vatra used something from lighthouse project to handle this.

Maybe it worth you ask him and check how these projects solved this OpenGL problem.

Regards.


Please,

walzer
  • Posts: 1735
  • Location: Xiamen, China

#6 RE: 2012-02-12 02:29

OK, guys, I have a cool stuff to show.
https://github.com/honghui/cocos2d-x/tree/QtPort
Honghui Zhang, one of my collaborator, is working on port cocos2d-x for Qt for several months, and our goal is to create an Editor with it eventually.
His Qt port is semi-finished, cocos2d-x/platform part is done while 3rd-party libraries are haven’t. This Qt port can run on windows now, linking 3rd-party libraries of win32 port.
We can continue the job from here :)

Less is More. Keep Focus.

plicatibu
  • Posts: 111

#7 RE: 2012-02-12 15:23

Walzer, you always have good news.

Sorry but I didn’t understand what you mean when you said:

our goal is to create an Editor with it eventually.

Do you want to create an editor (other than QtCreator) or do you want to create a project to use QtCreator ?

Regards.


Please,

Dany0
  • Posts: 94

#8 RE: 2012-02-12 18:25

Amazing Walzer! Can’t wait!

walzer
  • Posts: 1735
  • Location: Xiamen, China

#9 RE: 2012-02-13 01:02

@Marcio, I mean an action editor for cocos2d, it must can run on both windows + osx, and perhaps ubuntu.

Less is More. Keep Focus.

Dany0
  • Posts: 94

#10 RE: 2012-02-13 01:09

If you’re already doing OSXand win32, why ‘perhaps’ Ubuntu? If Qt is good in something it’s multiplatform compatibility. I wouldn’t hesitate if I were you.

Ubuntu QT port = awesome.

walzer
  • Posts: 1735
  • Location: Xiamen, China

#11 RE: 2012-02-13 01:17

Oh, that’s great. I’m not familiar with Qt and Ubuntu.
If Qt apps can run on these desktop systems seamlessly, it would be easy to distribute different versions, just like TileMap.

Less is More. Keep Focus.

winipcfg
  • Posts: 143

#12 RE: 2012-02-13 03:28

Is that meant we can debug on iphone in Windows platform, without the need of MacOS machine?
Thanks

walzer
  • Posts: 1735
  • Location: Xiamen, China

#13 RE: 2012-02-13 04:46

Cocos2d is a framework, so you still need a mac to build and distribute your ios game.

Less is More. Keep Focus.

winipcfg
  • Posts: 143

#14 RE: 2012-02-13 06:39

Walzer Wang wrote:

Cocos2d is a framework, so you still need a mac to build and distribute your ios game.

DragonFireSDK can do deploy in Windows and so I expected it could be done by other tools.
http://www.dragonfiresdk.com/docs.html

plicatibu
  • Posts: 111

#15 RE: 2012-02-13 11:52

`Walzer Instead of write on tile map editor, wouldn't be better to pick an existing one?

There is this one http://www.mapeditor.org/. It's writing with Qt so it can run on Windows, Mac and Linux.

Tiled is an open source project.

`Dany I agree with you.

Regards.


Please,

walzer
  • Posts: 1735
  • Location: Xiamen, China

#16 RE: 2012-02-13 13:26

@Marcio, you misunderstood my meaning. We gonna to make a n editor focus on layout and actions, and the final goal is to achieve skeleton animation feature. Without an editor, skeleton animation support in engine is meaningles. But the editor should run on windows and osx, so it should base on Qt.

Less is More. Keep Focus.

Dany0
  • Posts: 94

#17 RE: 2012-02-13 13:28

I think he means you will get a QT WYSIWYG editor where you can edit the way your game behaves.

plicatibu
  • Posts: 111

#18 RE: 2012-02-13 20:30

@Walzer Yes, I really misunderstood what you mean. Sorry.

Anyway, when multi-platform and C++ are requirements Qt is always the best choice ;)


Please,

li9s
  • Posts: 4

#19 RE: 2012-02-14 03:08

Great work Walzer!

Now I just want to make a tool both for windows and mac os. Now I’m trying to use QT for UI, and some cocos2d-x features.
I think the qt-port is really worth to do!
btw, what do you mean by the ‘action editor’? like animation editor? Can you explain it more?

winipcfg
  • Posts: 143

#20 RE: 2012-02-14 03:29

I suppose the Editor can be created based on Cocoshop

http://www.cocos2d-iphone.org/forum/topic/15668
https://github.com/andrew0/cocoshop

ex
  • Posts: 26

#21 RE: 2012-02-14 19:49

As always you guys amaze me :D
Great work Walzer and congrats to your team worker for pulling this off (y)

li9s
  • Posts: 4

#22 RE: 2012-02-20 16:36

I did a little test for demonstrating cocos2d-x for QT based on win32 :D
But I had to spend sometime to modify the latest code, like setting up the GLEW, and integrating the view with qt’s main window(ouch! I just want to make an editor, not only a game).

Now I’m looking forward to this port can be used on mac! Can’t wait!
Is there anything I can help for the qt porting work?

cc2xqt.png (248.2 kB)

moldovan_catalin
  • Posts: 15

#23 RE: 2012-03-19 18:32

Hi,

I’ve done a port of cocos2dx on Qt platform using OpenGL ES on all qt supported platforms. It is a bit messy for the third party libraries part but here’s what I found out doing the port:

  • on win32 using the PowerVR OpenGL ES drivers I got HelloWorld example to work ok, no issues. I’ve used the third party libraries from the native Win32 port.
  • on Symbian I had to port also the third party libraries (some of them reused from other open source projects with small changes e.g. libpng and libxml2). The issue here is that some of the required extensions are not available in the drivers (OES_framebuffer_object). Although the hardware has support because in OpenGL ES 2.0 this is standard, the OpenGL ES 1.1 drivers on the tested device (Nokia N8) don’t have the extension enabled (doesn’t appear in the GL_EXTENSIONS string and eglGetProcAddress returns NULL, and I tried getting them right, after setting the current GL context with eglMakeCurrent).
  • on Nokia N9 (MeeGo Harmattan), I could reuse some of the third party libraries that come with the Madde platform, but as with Symbian the OpenGL ES 1.1 drivers don’t have the framebuffer extension.
  • don’t know how it will fare on Mac OS X or Linux. On Linux I know that PowerVR have also a OpenGL ES 1.1 and 2.0 implementation, but don’t know about Mac OS X.

I’ve decided to use OpenGL ES on all platforms supported by Qt as it would have been easier to maintain, and this way it is a single code base for all these platforms, but unfortunately from my experiments it seems that on Symbian and MeeGo it is not working. I didn’t investigate further inside Cocos2Dx to see if that extension is essential or used only by few features of Cocos2Dx.
Maybe an OpenGL ES 2.0 port would seem more feasible for Qt as framebuffer functionality is standard in 2.0. An OpenGL ES 2.0 port on Qt would add Win32, Linux, (maybe Mac OS X), Symbian, MeeGo in the equation with a single code base.

Cheers,
Catalin

moldovan_catalin
  • Posts: 15

#24 RE: 2012-03-19 18:39

Forgot to mention that there are also unofficial ports of Qt to iOS and Android, and maybe even Windows Phone in the future as Ahmed stated previously so a Qt port would make it very easy to maintain the library and also the developer’s games. But from my point of view this would be feasible for an OpenGL ES 2.0 port of Cocos2Dx where current GL features required by Cocos2Dx are standard on all OpenGL ES 2.0 implementations.

plicatibu
  • Posts: 111

#25 RE: 2012-03-20 00:55

@Catalin Moldovan what you’ve accoplished is really great!

Now I hope cocos2d-x guys will merge your work ASAP :)

Thank you!

Regards.


Please,

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps