Open
Description
- 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.
- 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.
- Add a thread safely reference class which inherited from
Ref
. The class overwriteretain
andrelease
method, and makes them thread safe. - Support Tcp/IP
I'm sorry about that my English is so bad, the following is Chinese translation.
- 使用智能指针替代autorelease机制. 智能指针可以做到线程安全,并且在内存托管上更方便和安全,不仅能减少大量冗余的retain release代码,而且能确保你不会忘了调用release方法。目前很多成熟的商业引擎都在使用智能指针,我们没有理由不使用它。Ref类的引用计数应该从0开始,这样会更直观,所有创建函数都应该返回一个智能指针,这就避免了从0开始的可能引发的不安全因素。
- 避免直接调用OpenGL函数. 我们应该封装所有OpenGL操作,比如增加一些类:VertexBuffer, IndexBuffer, RenderContext等。这样不仅安全,而且使用起来更加方便,也便于移植。未来我们也许要支持OpenGL ES 3.x,OpenGL和DX(如果我们想要做一个真正的跨平台程序,这两个也是必备),封装会给我们带来非常大的收益。
- 增加一个线程安全的引用计数类,该类派生自
Ref
. 多线程是未来的趋势,线程安全是非常重要的。我们应该确保retain和release方法是线程安全的。 - 支持Tcp/IP协议.