I just completed a quick 1st draft prototype of a cocos2d iPad app. I have not modified the
The app runs fine when I leave
[director_ setDisplayStats:YES] in the
AppDelegate, but if I remove that line or substitute
[director_setDisplayStats:NO], it crashes in
-(void) drawNumberOfQuads: (NSUInteger) n fromIndex: (NSUInteger) start on line 522, which reads:
glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices)) );
[director_ setDisplayStats:YES] is on line 154 of
The entire sourcecode for the app prototype is located here:
For a little bit of context for those who might look at the code, after tapping Start,
BoardLayer is the primary node that coordinates most of the work and what shows on the screen.
For the life of me, I can't figure out what I'm doing that is causing this to be a problem. At first, I suspected that my use of
[[CCTextureCache sharedCache] removeUnusedTextures] (in 'BoardLayer') was a problem, but now I think that it doesn't make a difference.
This is the call stack that appears in Xcode:
Any ideas about how I can fix this problem?
Well, i would be careful before setting cleanup to NO (leaks lurk big time if you are not careful). I was able to run your app without FPS when (in ccConfig.h) i change
#define CC_ENABLE_GL_STATE_CACHE 1
#define CC_ENABLE_GL_STATE_CACHE 0
per your above answer, there seems to exist a nasty coupling here at the GL level. I dont think that this optimization (state cache) would impact very noticeably (if at all) the perceived performance of your type of app.
ps: nice graphics, will probably become a favourite for many 7-77 yr old kids.
BoardLayer.m, I was using
[self removeAllChildrenWithCleanup:YES], which seemed to be causing the problem. When I changed it to simply
[self removeAllChildren], everything works as expected when
[director_ setShowStats:NO] is in place.
I'm not sure what the nature of this conflict is -- it appears to be at a low OpenGL level -- but it's fixed in my code.