how to use multi-thread load texture in cocos2d

how to use multi-thread load texture in cocos2d
0.0 0


In an attempt to create a loading bar for an game,
I wanted to use a multithreaded approach.

One thread shows a loading screen and runs the main application event loop
while a new thread silently loads all the Sprites in the background
and then adds them to a layer.

The problem I’m facing is that any OpenGL calls in the new thread die with a BUS ERROR or memory access error of some sort.
I’m assuming this is because both threads are attempting to make OpenGL calls at the same time or the new thread is unaware of the OpenGL context.

What has to be done to allow multiple threads to make OpenGL calls


I don’t understand why not use CCScheduler?


zhao lin, OpenGL has its state machine, you cannot call gl functions in different thread which misorder the state machine.
We planned to implement multi-thread in the coming version, and we will give a sample code of loading texture asynchronously. It’s a bit complex if we don’t wrap this feature.

Before the version release, you can use schedule update to load textures step by step. I wrote the sample code in this thread


Walzer Wang,
I wanna know when cocos2d-x will surpport multi-thread?


Yeah, Minggo just implemented it in the last week. Feature #854 is resolved, and feature #465 can work now. You can check out the edge version from github and try it.


[URL=]sports chiropractic specialist in Newport Beach[/URL] who we should visit.