cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.02k stars 7.05k forks source link

some suggestion for cocos v4.x #14290

Open youlanhai opened 8 years ago

youlanhai commented 8 years ago
  1. Use smart pointer instead of auto release. Because the smart pointer is more safe for memory management and threading. The reference counter of an object should start at zero, any creation function should return a smart pointer instead of raw pointer.
  2. Don't call any OpenGL function directly. Wrapper all OpenGL function with c++ class. (eg, VertexBuffer, IndexBuffer, RenderContext). We may need support OpenGL ES v2.x, ES v3.x, OpenGL, DirectX in the future. It's safe and convenience to use an abstract renderer layer.
  3. Add a thread safely reference class which inherited from Ref. The class overwrite retain and release method, and makes them thread safe.
  4. Support Tcp/IP

I'm sorry about that my English is so bad, the following is Chinese translation.

  1. 使用智能指针替代autorelease机制. 智能指针可以做到线程安全,并且在内存托管上更方便和安全,不仅能减少大量冗余的retain release代码,而且能确保你不会忘了调用release方法。目前很多成熟的商业引擎都在使用智能指针,我们没有理由不使用它。Ref类的引用计数应该从0开始,这样会更直观,所有创建函数都应该返回一个智能指针,这就避免了从0开始的可能引发的不安全因素。
  2. 避免直接调用OpenGL函数. 我们应该封装所有OpenGL操作,比如增加一些类:VertexBuffer, IndexBuffer, RenderContext等。这样不仅安全,而且使用起来更加方便,也便于移植。未来我们也许要支持OpenGL ES 3.x,OpenGL和DX(如果我们想要做一个真正的跨平台程序,这两个也是必备),封装会给我们带来非常大的收益。
  3. 增加一个线程安全的引用计数类,该类派生自Ref. 多线程是未来的趋势,线程安全是非常重要的。我们应该确保retain和release方法是线程安全的。
  4. 支持Tcp/IP协议.
pandamicro commented 8 years ago

@youlanhai Thank you very much for your suggestion, indeed, memory management, multi thread and portable renderer are all very important for Cocos2d to getting anywhere further. We will consider your suggestions for our v4

dungmv commented 8 years ago

cocos2d-x v4 seems to be frozen. so, when it will be resumed?

AlexanderBykin commented 8 years ago

@youlanhai TCP/IP implementation you can find here: https://github.com/AlexanderShniperson/cocos2dx_socket_example