I am transposing a Cocos2D project to 2.0.
I have created a blank project using Cocos2D 2.0 template (the simple template without physics) and transferred all files from the old project to the blank project.
I have also converted that to ARC.
I compile and I see no errors. I run the app and it appears to be running correctly, but I have these errors on console...
MyApp[1266:707] cocos2d: animation stopped
MyApp[1266:707] cocos2d: animation started with frame interval: 60.00
MyApp[1266:707] cocos2d: surface size: 640x960
MyApp[1266:707] cocos2d: surface size: 640x960
MyApp[1266:707] cocos2d: animation stopped
MyApp[1266:707] cocos2d: animation started with frame interval: 60.00
MyApp[1266:707] failed to call context
MyApp[1266:707] cocos2d: surface size: 640x960
MyApp[1266:707] Failed to make complete framebuffer object 0x8CDD
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280
MyApp[1266:707] failed to call context
MyApp[1266:707] cocos2d: surface size: 640x960
MyApp[1266:707] Failed to make complete framebuffer object 0x8CDD
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280
As I said, this was created from a blank template.
how do I fix that?
OpenGL error 0x506 = GL_INVALID_FRAMEBUFFER_OPERATION
Main difference between Cocos2D 2.0 and Cocos2D 1.0 is OpenGLES version. Cocos2D 2.0 uses OpenGLES 2.0 and Cocos2D 1.0 uses OpenGLES 1.0.
I guess you may used API that is not found in OpenGLES2.0 that found in OpenGLES 1.0
Example:GLBegin(), GLLineWidth() etc
Use this draw function:
-(void) draw
{
[super draw];
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
kmGLPushMatrix();
self.world->DrawDebugData();
kmGLPopMatrix();
}
Instead of this:
-(void) draw
{
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
world->DrawDebugData();
// restore default GL states
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
Also use GLES-Render.h and GLES-Render.m from Cocos2D 2.0
Related
I am learning opengl on my mac using both glfw and sfml and meet some hurdle on the OpenGL version.
When I run the code:
printf ("Renderer: %s\n", glGetString (GL_RENDERER));
printf ("OpenGL version supported: %s\n", glGetString (GL_VERSION));
printf("glsl: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
on glfw
Renderer: Intel(R) Iris(TM) Graphics 6100
OpenGL version supported: 4.1 INTEL-10.22.25
glsl: 4.10
on sfml
Renderer: Intel(R) Iris(TM) Graphics 6100
OpenGL version supported: 2.1 INTEL-10.22.25
glsl: 1.20
Is it my setting on the xcode project or that is the default framework setting? Is there a way I can change sfml to work with OpenGL 4.1 so that I get glsl 4.1 too?
glfw have this settings:
glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 1);
Do sfml have something similar?
With SFML you can specify the OpenGL version using sf::ContextSettings.
sf::ContextSettings settings;
settings.depthBits = 24;
settings.stencilBits = 8;
settings.majorVersion = 4;
settings.minorVersion = 1;
settings.attributeFlags = sf::ContextSettings::Default;
Then you pass it to the sf:Window as you create it:
sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, settings);
Bottom line is that SFML needs a backwards compatibility context. Because internally SFML relies on some legacy OpenGL functionality.
So if you aren't using SFML for anything SFML specific. Then I recommend continuing to use GLFW.
I am testing some OpenGL code.Using OpenGL 4.3.Nvidia GTX960M GPU.Windows10 64bit.Driver version:364.72
Trying to debug with NVidia NSight (version:4.7).The app is running fine untill I open NSight graphics debuggig.(Running GL debug output,zero errors).But when NSight is being launched I am getting this error:
Source:OpenGL,type: Error, id: 1282, severity: High Message:
GL_INVALID_OPERATION error generated. Object is owned by another
context and may not be bound here.
Then NSight debug windows is freezing and the app crashes on the close.
Before that, I had also CUDA code there with some OpenGL resources mapped to CUDA context.So I assumed that maybe some CUDA resource still holds OpenGL texture or buffer.I deleted everything,wrote from scratch only GL part.Not a line of CUDA.The error still persists.
The rendering is just simple quad with texture mapping.Can it be a bug in NSight?
all.
I added my picture "Icon2222.png" into my project, and changed the name of picture from "grossini.png"(which is original) to "Icon2222.png",
but when I run the project, it crashed with the exception named NSInternalInconsistencyException and hint me that "Can't create Texture. UIImage is nil".
Where did I make a mistake? I just replaced a picture.
Thanks in advance.
2012-05-03 14:59:10.480 ActionManagerTest[3215:f803] cocos2d: cocos2d v1.0.1
2012-05-03 14:59:10.481 ActionManagerTest[3215:f803] cocos2d: Using Director Type:CCDirectorDisplayLink
2012-05-03 14:59:10.529 ActionManagerTest[3215:f803] cocos2d: OS version: 5.0 (0x05000000)
2012-05-03 14:59:10.529 ActionManagerTest[3215:f803] cocos2d: GL_VENDOR: Apple Computer, Inc.
2012-05-03 14:59:10.530 ActionManagerTest[3215:f803] cocos2d: GL_RENDERER: Apple Software Renderer
2012-05-03 14:59:10.531 ActionManagerTest[3215:f803] cocos2d: GL_VERSION: OpenGL ES-CM 1.1 APPLE
2012-05-03 14:59:10.531 ActionManagerTest[3215:f803] cocos2d: GL_MAX_TEXTURE_SIZE: 4096
2012-05-03 14:59:10.532 ActionManagerTest[3215:f803] cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
2012-05-03 14:59:10.532 ActionManagerTest[3215:f803] cocos2d: GL_MAX_SAMPLES: 4
2012-05-03 14:59:10.533 ActionManagerTest[3215:f803] cocos2d: GL supports PVRTC: YES
2012-05-03 14:59:10.533 ActionManagerTest[3215:f803] cocos2d: GL supports BGRA8888 textures: YES
2012-05-03 14:59:10.534 ActionManagerTest[3215:f803] cocos2d: GL supports NPOT textures: YES
2012-05-03 14:59:10.535 ActionManagerTest[3215:f803] cocos2d: GL supports discard_framebuffer: YES
2012-05-03 14:59:10.535 ActionManagerTest[3215:f803] cocos2d: compiled with NPOT support: NO
2012-05-03 14:59:10.536 ActionManagerTest[3215:f803] cocos2d: compiled with VBO support in TextureAtlas : YES
2012-05-03 14:59:10.536 ActionManagerTest[3215:f803] cocos2d: compiled with Affine Matrix transformation in CCNode : YES
2012-05-03 14:59:10.537 ActionManagerTest[3215:f803] cocos2d: compiled with Profiling Support: NO
2012-05-03 14:59:10.549 ActionManagerTest[3215:f803] Retina Display Not supported
2012-05-03 14:59:10.550 ActionManagerTest[3215:f803] cocos2d: CCTexture2D. Can't create Texture. UIImage is nil
2012-05-03 14:59:10.551 ActionManagerTest[3215:f803] cocos2d: deallocing
[Switching to process 3215 thread 0x12f0b]
2012-05-03 14:59:10.551 ActionManagerTest[3215:f803] cocos2d: Couldn't add image:Icon2222.png in CCTextureCache
2012-05-03 14:59:10.559 ActionManagerTest[3215:f803] cocos2d: deallocing
2012-05-03 14:59:10.559 ActionManagerTest[3215:f803] * Assertion failure in -[CCLayer addChild:], /Users/qusean/Downloads/cocos2d-iphone-1.0.1/cocos2d/CCNode.m:413
2012-05-03 14:59:10.561 ActionManagerTest[3215:f803] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Argument must be non-nil'
* First throw call stack:
(0x17de052 0x14ddd0a 0x1786a78 0x1e92db 0xb300 0x4546 0x4adb0e 0x4ae8a6 0x4bd743 0x4be1f8 0x4b1aa9 0x1ed4fa9 0x17b21c5 0x1717022 0x171590a 0x1714db4 0x1714ccb 0x4ae2a7 0x4afa9b 0x2581 0x2505 0x1)
terminate called throwing an exception
Here is my code:
1
CCSprite *child = [CCSprite spriteWithFile:#"Icon2222.png"];
[child setPosition:ccp(200,200)];
[layer addChild:child];
2
CGSize winSize = [[CCDirector sharedDirector] winSize];
CCSprite *player = [CCSprite spriteWithFile:#"Icon2222.png"
rect:CGRectMake(0, 0, 27, 40)];
player.position = ccp(player.contentSize.width/2, winSize.height/2);
[layer addChild:player];
Both of them crashed.
I met the problem before.
The same happened Cause i changed the png name in the finder many times.
Use the original output png name which created by your Graphic tools will be smooth going.
wish it will be helpful
Delete the file from the bundle, then bring it back in with the correct file name. You are only changing the name of the file within the local project, not within the project directory.
I suggest you to clean the build... Delete the app.. And run again... In case it doesn't solve your problem... Remove all resources and add again to project...
Hope this helps.. :)
I know this thread is rather old, but i ran into same problem and my solution might help future lost souls.
My problem was that the file was not attached to the target and hence was not included and could not be found.
I.e. remember to make sure that the file is checked to be in your target in the Utility tab, or when you import the file.
I am using following code:
// Add the stuff from below!
CCSprite* background = [CCSprite spriteWithFile:#"background-1.png"];
background.tag = 1;
background.anchorPoint = CGPointMake(0, 0);
[self addChild:background];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:
#"wave1.plist"];
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode
batchNodeWithFile:#"wave1.png"];
[self addChild:spriteSheet];
NSMutableArray *walkAnimFrames = [NSMutableArray array];
for(int i = 1; i <= 8; ++i) {
[walkAnimFrames addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"wave-r-l-000%d.png", i]]];
//wave-r-l-0001
}
CCAnimation *walkAnim = [CCAnimation
animationWithFrames:walkAnimFrames delay:0.1f];
CGSize winSize = [CCDirector sharedDirector].winSize;
self.bear = [CCSprite spriteWithSpriteFrameName:#"bear1.png"];
_bear.position = ccp(winSize.width/2, winSize.height/2);
self.walkAction = [CCRepeatForever actionWithAction:
[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
[_bear runAction:_walkAction];
[spriteSheet addChild:_bear];
But unfortunately it gives following error:
2011-07-12 09:43:33.471 TestBear[205:707] cocos2d: cocos2d v1.0.0-rc3
2011-07-12 09:43:33.479 TestBear[205:707] cocos2d: Using Director Type:CCDirectorDisplayLink
2011-07-12 09:43:33.650 TestBear[205:707] cocos2d: OS version: 4.3.1 (0x04030100)
2011-07-12 09:43:33.654 TestBear[205:707] cocos2d: GL_VENDOR: Imagination Technologies
2011-07-12 09:43:33.658 TestBear[205:707] cocos2d: GL_RENDERER: PowerVR SGX 535
2011-07-12 09:43:33.661 TestBear[205:707] cocos2d: GL_VERSION: OpenGL ES-CM 1.1 IMGSGX535-58.6
2011-07-12 09:43:33.667 TestBear[205:707] cocos2d: GL_MAX_TEXTURE_SIZE: 2048
2011-07-12 09:43:33.670 TestBear[205:707] cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
2011-07-12 09:43:33.674 TestBear[205:707] cocos2d: GL_MAX_SAMPLES: 4
2011-07-12 09:43:33.677 TestBear[205:707] cocos2d: GL supports PVRTC: YES
2011-07-12 09:43:33.680 TestBear[205:707] cocos2d: GL supports BGRA8888 textures: YES
2011-07-12 09:43:33.684 TestBear[205:707] cocos2d: GL supports NPOT textures: YES
2011-07-12 09:43:33.687 TestBear[205:707] cocos2d: GL supports discard_framebuffer: YES
2011-07-12 09:43:33.690 TestBear[205:707] cocos2d: compiled with NPOT support: NO
2011-07-12 09:43:33.694 TestBear[205:707] cocos2d: compiled with VBO support in TextureAtlas : NO
2011-07-12 09:43:33.697 TestBear[205:707] cocos2d: compiled with Affine Matrix transformation in CCNode : YES
2011-07-12 09:43:33.700 TestBear[205:707] cocos2d: compiled with Profiling Support: NO
2011-07-12 09:43:33.854 TestBear[205:707] cocos2d: CCSpriteFrameCache: Trying to use file 'wave1.png' as texture
2011-07-12 09:43:33.905 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.910 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.914 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.917 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.921 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.925 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.928 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.932 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.935 TestBear[205:707] cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist
2011-07-12 09:43:33.941 TestBear[205:707] cocos2d: CCSpriteFrameCache: Frame 'bear1.png' not found
2011-07-12 09:43:33.946 TestBear[205:707] *** Assertion failure in -[CCSprite initWithSpriteFrame:], /Users/shahbazali/Documents/TestBear/libs/cocos2d/CCSprite.m:229
2011-07-12 09:43:34.006 TestBear[205:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid spriteFrame for sprite'
*** Call stack at first throw:
(
0 CoreFoundation 0x31fbe64f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x31132c5d objc_exception_throw + 24
2 CoreFoundation 0x31fbe491 +[NSException raise:format:arguments:] + 68
3 Foundation 0x30c30573 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 62
4 TestBear 0x0008cf08 -[CCSprite initWithSpriteFrame:] + 200
5 TestBear 0x0008bfcc +[CCSprite spriteWithSpriteFrame:] + 88
6 TestBear 0x0008c098 +[CCSprite spriteWithSpriteFrameName:] + 120
7 TestBear 0x00003f04 -[HelloWorldLayer init] + 744
8 TestBear 0x00067bf0 +[CCNode node] + 76
9 TestBear 0x000041e4 +[HelloWorldLayer scene] + 100
10 TestBear 0x00003530 -[TestBearAppDelegate applicationDidFinishLaunching:] + 1028
11 UIKit 0x322f885d -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 832
12 UIKit 0x322f2b65 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 272
13 UIKit 0x322c77d7 -[UIApplication handleEvent:withNewEvent:] + 1114
14 UIKit 0x322c7215 -[UIApplication sendEvent:] + 44
15 UIKit 0x322c6c53 _UIApplicationHandleEvent + 5090
16 GraphicsServices 0x304a6e77 PurpleEventCallback + 666
17 CoreFoundation 0x31f95a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
18 CoreFoundation 0x31f9783f __CFRunLoopDoSource1 + 166
19 CoreFoundation 0x31f9860d __CFRunLoopRun + 520
20 CoreFoundation 0x31f28ec3 CFRunLoopRunSpecific + 230
21 CoreFoundation 0x31f28dcb CFRunLoopRunInMode + 58
22 UIKit 0x322f1d49 -[UIApplication _run] + 372
23 UIKit 0x322ef807 UIApplicationMain + 670
24 TestBear 0x000030b4 main + 100
25 TestBear 0x00003018 start + 52
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
Please help
I know the topic is a bit old but it might help some people.
The error comes from this line:
self.bear = [CCSprite spriteWithSpriteFrameName:#"bear1.png"];
TestBear[205:707] cocos2d: CCSpriteFrameCache: Frame 'bear1.png' not found
It means that the CCSpriteFrameCache does not containt sprime frame named "bear1.png". Here you add only 1 plist file ("wave1.plist") and and it contains no sprime frame named "bear1.png". So check you plist file and re-generate it if necessary.
An another common error is to use "spriteWithSpriteFrameName:" instead of "spriteWithFile:" if your sprite is not inside a spritesheet.
I hope i'll help.
this thing is making me crazy!
I'm experimenting with Cocos2d (0.99.5) and Box2D, and I have successfully created a scene with a layer and two bodies (actually a couple of bouncing balls). Now I would like to enable the DebugDrawing so I can see exactly what is happening. Consider that everything works with DebugDrawing disabled.
Talking about the code, in my init method I have this:
m_debugDraw = new GLESDebugDraw(PTM_RATIO);
uint32 flags;
flags = 0;
flags += 1 * b2DebugDraw::e_shapeBit;
flags += 1 * b2DebugDraw::e_jointBit;
flags += 1 * b2DebugDraw::e_aabbBit;
flags += 1 * b2DebugDraw::e_pairBit;
flags += 1 * b2DebugDraw::e_centerOfMassBit;
m_debugDraw->SetFlags(flags);
_world->SetDebugDraw(m_debugDraw);
My draw method is as follows:
-(void)draw {
[super draw];
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
_world->DrawDebugData(); // <------ here comes the problem
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
The problem is that when the program reaches the line
_world->DrawDebugData();
an EXC_BAD_ACCESS exception in thrown. The debugger shows the error here:
void b2World::DrawDebugData()
{
if (m_debugDraw == NULL)
{
return;
}
uint32 flags = m_debugDraw->GetFlags(); // <----- this is the row pointed by Xcode
if (flags & b2DebugDraw::e_shapeBit)
{
[...]
The error shown on the main window is: "Thread 1: Program received signal: 'EXC_BAD_ACCESS'". This is the output I get:
GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 8 00:31:48 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin --target=arm-apple-darwin".tty /dev/ttys000
target remote-mobile /tmp/.XcodeGDBRemote-191-40
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to thread 11779]
[Switching to thread 11779]
sharedlibrary apply-load-rules all
2011-03-03 22:10:36.477 MyApp[2738:707] cocos2d: cocos2d v0.99.5
2011-03-03 22:10:36.529 MyApp[2738:707] cocos2d: Using Director Type:CCDirectorDisplayLink
2011-03-03 22:10:36.936 MyApp[2738:707] cocos2d: OS version: 4.3 (0x04030000)
2011-03-03 22:10:36.943 MyApp[2738:707] cocos2d: GL_VENDOR: Imagination Technologies
2011-03-03 22:10:36.949 MyApp[2738:707] cocos2d: GL_RENDERER: PowerVR SGX 535
2011-03-03 22:10:36.956 MyApp[2738:707] cocos2d: GL_VERSION: OpenGL ES-CM 1.1 IMGSGX535-58.1
2011-03-03 22:10:36.966 MyApp[2738:707] cocos2d: GL_MAX_TEXTURE_SIZE: 2048
2011-03-03 22:10:36.973 MyApp[2738:707] cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
2011-03-03 22:10:36.979 MyApp[2738:707] cocos2d: GL_MAX_SAMPLES: 4
2011-03-03 22:10:37.020 MyApp[2738:707] cocos2d: GL supports PVRTC: YES
2011-03-03 22:10:37.026 MyApp[2738:707] cocos2d: GL supports BGRA8888 textures: YES
2011-03-03 22:10:37.033 MyApp[2738:707] cocos2d: GL supports NPOT textures: YES
2011-03-03 22:10:37.039 MyApp[2738:707] cocos2d: GL supports discard_framebuffer: YES
2011-03-03 22:10:37.060 MyApp[2738:707] cocos2d: compiled with NPOT support: NO
2011-03-03 22:10:37.066 MyApp[2738:707] cocos2d: compiled with VBO support in TextureAtlas : YES
2011-03-03 22:10:37.072 MyApp[2738:707] cocos2d: compiled with Affine Matrix transformation in CCNode : YES
2011-03-03 22:10:37.078 MyApp[2738:707] cocos2d: compiled with Profiling Support: NO
2011-03-03 22:10:44.375 MyApp[2738:707] cocos2d: Frame interval: 1
2011-03-03 22:10:44.420 MyApp[2738:707] cocos2d: surface size: 320x480
2011-03-03 22:10:44.654 MyApp[2738:707] Received memory warning. Level=1
2011-03-03 22:10:44.696 MyApp[2738:707] cocos2d: deallocing
"MenuBackGround.png",
"Star.png",
"fps_images.png"
)>
Current language: auto; currently c++
(gdb)
I have tried googling and I found out a lot of things about this error, still I can't solve it. It happens both on the simulator and on the iPhone. Someone on another discussion (sorry, lost the link) pointed out that it may be related to the compiler or the optimization, thus I tried different combinations switching from LLVM to GCC to LLVM-GCC and setting the optimization at different levels with no success.
Can someone point me in the right direction? Let me know if more information is needed.
Thanks you all,
Daniele Salatti
The only difference to the Cocos2D Box2D template is that you are calling SetDebugDraw after assigning the flags. It shouldn't make any difference but you might want to try it exactly like the Box2D template project does:
world = new b2World(gravity, doSleep);
world->SetContinuousPhysics(true);
// Debug Draw functions
m_debugDraw = new GLESDebugDraw( PTM_RATIO );
world->SetDebugDraw(m_debugDraw);
uint32 flags = 0;
flags += b2DebugDraw::e_shapeBit;
m_debugDraw->SetFlags(flags);
Update: I found another difference. In your draw method, you're calling [super draw]. The Box2D template project doesn't do that. Again, it should not make any difference but you never know. If it still crashes I recommend to compare your project with the Box2D template to find any other (possibly subtle) differences. In addition to the usual recommendations to exclude all compiler hiccups: cleaning all targets, deleting build folder, restarting Xcode (and entire machine), deleting the App from Simulator/Device (and rebooting device).
PS: I see you're using underscore prefixes as in: _world. Apple recommends not to do that since underscore prefixes are reserved for their own internal use, as well as some C style functions. In ObjC, if you must name member variables according to some scheme, prefer to use underscore suffixes as in world_->SetDebugDraw()
Personally I try to avoid these world, world or m_world naming schemes altogether, there's really no point in that other than tradition and conflicting function parameter names. Where necessary, I rather change the function parameter names to have a suffixed underscore.
Take a look at your world and debugDraw variables with debugger. Looks like one of them is corrupted