globally defined world

I'm making a game and I want a function that does the level loading. The thing is it can't initialize the physics part because I can't define the world as a global since it has some params. And I can't pass it as a param either cause I get a "send/don't send" error. Any idea how I could do this? 😐
What language are you using?
VC++ 2005
1. that's not a language, but an IDE / compiler
2. looks like you're using C++, is that right?
3. you shouldn't use global variables at all, that screws up code in big projects.
4. could you please show us some code which doesn't work for you?
Quote:
you shouldn't use global variables at all, that screws up code in big projects.


But it sure makes tiny projects easier. 😛 The problem is knowing ahead of time whether a small project will balloon into a big one. But I don't think worrying about global variables should come before learning how to make an object with no default constructor.
yeah, C++.
Code:
void test_load(b2World world)
{
   //din box
   b2BodyDef bodyDef;
   bodyDef.position.Set(15.0f, 3.0f);
   //bodyDef.angle=0;
   //bodyDef.fixedRotation=1;
   b2Body* body2 = world.CreateBody(&bodyDef);

   b2PolygonDef shapeDef;
   shapeDef.SetAsBox(3.20f, 2.20f);
   shapeDef.density = 1.0f;
   shapeDef.friction = 0.1f;
   //shapeDef.restitution=0.1f;
   //body2->CreateShape(&shapeDef);

   // Now tell the dynamic body to compute it's mass properties base
   // on its shape.
   //body2->SetMassFromShapes();
}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreviousInstance,LPSTR lpcmdline,int nCmdShow)
{
......
void test_load(world);
......
}


@shaktool: then tell me how to do that with the b2d world 😛


what I'd want is to somehow define the world as a global, but I can't since there's the b2AABB thing....ideas?
pass a pointer / reference of world to the function, not the world itself 🙂
thanks! it worked! but it's odd....I did that a while ago and it didn't work 😕 ....anyway, it works 😀 Thanks a lot 🙂

Original thread: https://box2d.org/forum/viewtopic.php?t=1342