Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4031874
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:39:05+00:00 2026-05-20T11:39:05+00:00

this thing is making me crazy! I’m experimenting with Cocos2d (0.99.5) and Box2D, and

  • 0

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: 320×480

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:39:06+00:00Added an answer on May 20, 2026 at 11:39 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I have this bit of wild, crazy code, that is making the compiler
I have this thing working mostly. What I don't get is, if I have
I have this thing that i need to do and some advices will be
I'm new at this TDD thing but making a serious effort, so I'm hoping
Please help me with this code, it is making me crazy. This is a
This is a self-explanatory question: Why does this thing bubble into my try catch's
Why is this thing not working? [Database(Name=Relationships_Test)] [Table(Name = Order)] public class Order {
Why is this thing giving the message in the second line (i.e. list convertion)?
I am confused with this thing, is emulator safe from pc network's firewall like
I'm trying to get this thing to work in IE (any version - works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.