Search code examples
cocos2d-iphonensthreadkobold2d

CCMask and threads


I am using Gilles Lesire's CCMask class in my Kobold2d 2.0.3 (cocos2d-iphone v2.0 and OpenGL ES 2.0) game, but calling "createMaskForObject:withMask:" I get the following error:

-[CCRenderTexture initWithWidth:height:pixelFormat:depthStencilFormat:] : cocos2d: WARNING. CCRenderTexture is running on its own thread. Make sure that an OpenGL context is being used on this thread!

I don't really understand how to work with threads/opengl, but I was hoping someone would know how to fix this.


Solution

  • I see this as well for cocos2d 2.0. I don't think there is anything to fix. If you look at line 81 of CCRenderTexture.m you will see:

    if( [director runningThread] != [NSThread currentThread] )
    

    If that is false, the warning is given.

    But, if you're creating textures before the game/app is running, the background thread for CVDisplayLink doesn't look like it has been created yet. [director runningThread] (the thread for the CVDisplayLink) returns nil. So that "if" statement will always be false.