Loading CCTMXTiledMap into a pthread

Hey guys,
I’m new on the forum, so don’t throw rocks at me if that topic as been discussed before. Didn’t find anything on google either.
I’m working on a games using tile maps. but we want these stages to be really big (i.e. 450 x 450, maybe even more). Tiles size are 48x48.

To avoid performance issues, we want to split each stage into 3 sections (150,150). When we would reach a certain point in the game, we want to start loading the next sections in the background.
while loading, we need the game to be playable. So we thought about loading the tile map into a thread and simply add it to the game once it’s ready.

How feasible is that?

We are aware of that EAGLview problem in cocos2d where you can’t call opengl calls in a thread.

Any input/ advice would be appreciated.

Thanks.

Oh And I forgot to say, I’m working on Android.

I know that iOS has a way to share the OpenGL context … but I haven’t found anything for android.

Hi Vince.

I’ve been looking into this as well and started a similar post here: http://www.cocos2d-x.org/boards/6/topics/23278?r=24132#message-24132

It seems as though from a thread you cannot call any functions which invokes CCObject::retain(), CCObject::release() or CCObject::autorelease(), because CCAutoreleasePool are not thread-safe.
as stated on the wiki here: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_use_pthread

That seems to make the idea of loading CCTMXTiledMap from a thread impossible.

I was thinking of creating the CCTMXTiledmap from a thread and only calling it’s autorelease once the thread merged, but this may not work because of all of the CCSprites that the CCTMXTiledMap creates. The sprites in turn would call their autorelease while in the thread.

Maybe the CCTMXTileMap and CCTMXLayer class can be remade to use oldschool memory management and this would make them threadsafe; providing the only caveat is the autorelease pool.

Let me know if you figure out any solutions to this.