Projects > cpp > Issues > Refactor #2460

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

Unify the codes for desktop

Refactor #2460 [Closed]
zhangxm 2013-08-01 04:01 . Updated about 3 years ago

We should decide to use GLFW v3 or SDL2 v2 to simplify the code for desktop.

zhangxm 2013-08-01 04:02
  • Description updated (diff)
ricardo 2013-08-01 05:15

More information:

Another alternative is:

GLFW seems to be the more lightweight (something that we care about)

ricardo 2013-08-01 06:17

And this URL shows how to use SDL, SFML and GLFW:

quiet_readonly 2013-08-02 04:23

On Windows, SDL2 as dynamic library takes 800 KB for x86 and 1MB for x64. Static library is about 100KB, because SDLmain and SDLtest will be not used in cocos2dx anyway. Full distribution with headers, dynamic and static lib is ~5 MB. So there are no real advantages of lesser size of GLFW: it just have lesser features.

On the other hand, SDL2 used in Valve games, fixes real disadvantages of SDL 1.2 like not working global hotkeys in fullscreen windows on Linux, adds support for multiple mouses and touches (touches support is useful if it works with OSX ClickPad).

Qt5 has a quite big size (a few megabytes for each module) and LGPL license does not allow easy static linking; it does not affect nor development neither Ubuntu distribution, but distributing games on OSX and Windows will hurt.

Iā€™m ready to implement unified backend for SDL2 or GLFW and test it on Windows 7, OSX 10.8, Ubuntu 13.10.

zhangxm 2013-08-02 08:51
  • Priority changed from Normal to High
dabingnn 2013-08-08 09:45

**Using GLFW instead of SDL is better for our projects:
1. GLFW is more lightweight than SDL, and its main focus is windows handling and openGL context wrapping.The functions in GLFW are very useful in our engine. SDL has too much function, lots of which are overlapping with our engine.
2. The GLFW has more clear header files. When SDL has a long list of include file, GLFW has only two files.
As far as I know, SDL is also ok for unify the desktop code. But GLFW may be more suitable for our situation.
Can someone give more suggestions? Any reply about this is appreciated!

dabingnn 2013-09-16 11:15
  • Status changed from New to Resolved
zhangxm 2013-09-16 13:15
  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100

Atom PDF

Start date:2013-08-01
Due date:
% Done:


Category:linux, mac, windows
Target version:3.0-alpha0

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.