Hello,
Searched the forums and read some posts about Box2D and iPhone but still don't understand how to get this working. Does anybody have a working version of Box2D for iPhone they could post and perhaps quick sample program?
Thank you.
AM
There are samples in GLBasic. Just look. :good:
You have to compile the Box2D project with GLBasic for iPhone, but before doing that, in the Project/Options menu select "iPhone" from the box and type:
-O2
in the box that says: "cmp". This diables the full optimization and bypasses the iPhone compiler bug.
Other than that, there is no other difference in the Windows version compile. Cool eh? :-[
Thanks for the replies. I did find out that -o2 is not the same as -O2. :)
Does work on this continue? I noticed several things seem to be missing like prismatic & pulley joints, motors, and callbacks. I wish I had the C background to do this, I'd really love to see a complete implementation of Box2D for GLB.
If anybody wants to finish this, I'd be willing to convert some of my Box2D demos from Darkbasic.
Cool. - Post the request in the Box2D thread.
http://www.glbasic.com/forum/index.php?topic=3561.0 (http://www.glbasic.com/forum/index.php?topic=3561.0)
I swear that this language will be the death of me. :rant:
Okay, my latest frustation involves trying to use box2d. Last night I was able to put together a small demo and it was working great. Today, I load up that same exact demo and lo and behold, it now wants to have errors.
Console output:
Wordcount:102 commands
compiling:
C:\Users\AM\AppData\Local\Temp\glbasic\gpc_temp1.cpp: In function `DGInt __GLBASIC__::b_CreatePoly(DGInt, DGInt, DGInt, DGInt, DGInt, DGInt, DGInt, __GLBASIC__::DGIntArray&)':
C:\Users\AM\AppData\Local\Temp\glbasic\gpc_temp1.cpp:550: error: no match for call to `(__GLBASIC__::DGIntArray) (int&, int)'
C:/Coding/GLBasic/Compiler/platform/Include/glb.h:402: note: candidates are: DGInt& __GLBASIC__::DGIntArray::operator()(int)
C:/Coding/GLBasic/Compiler/platform/Include/glb.h:442: note: __GLBASIC__::DGIntArray& __GLBASIC__::DGIntArray::operator()()
C:\Users\AM\AppData\Local\Temp\glbasic\gpc_temp1.cpp:550: error: no match for call to `(__GLBASIC__::DGIntArray) (int&, int)'
C:/Coding/GLBasic/Compiler/platform/Include/glb.h:402: note: candidates are: DGInt& __GLBASIC__::DGIntArray::operator()(int)
C:/Coding/GLBasic/Compiler/platform/Include/glb.h:442: note: __GLBASIC__::DGIntArray& __GLBASIC__::DGIntArray::operator()()
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Elapsed: 1.6 sec. Time: 20:13
Build: 0 succeeded.
*** 1 FAILED ***
and here is the code that it seems to be referring to...
//! Create a polygonal shaped object. The pts[] is a 2D array
//! that has the polygon points. The last point must not equal the first point.
//! pts[] must be clockwise points.
FUNCTION b_CreatePoly: mass, friction, restitution, lineardamp, angulardamp, x, y, pts[]
INLINE
b2BodyDef def;
def.position.Set(x,y);
def.linearDamping = lineardamp;
def.angularDamping = angulardamp;
b2Body* pBody = bWorld->CreateBody( &def );
b2PolygonDef poly;
poly.vertexCount = LEN(pts);
for(int i=0; i<LEN(pts); ++i)
{
poly.vertices[i] = b2Vec2(pts(i,0), pts(i,1));
}
if(mass>0.0) poly.density = mass;
poly.friction = friction;
poly.restitution = restitution;
pBody->CreateShape( &poly);
if(mass>0.0) pBody->SetMassFromShapes();
return b_NewObject(pBody, bBody);
ENDINLINE
ENDFUNCTION
If I remove this section from the included file, the program runs. Let me stress that it worked fine with this code last night.
WTH?
somewhere in your code write:
LOCAL a[]
DIM a[0][0]
-> This tells GLBasic that you are using arrays with at least 2 dimensions. If you only have 1D arrays, GLBasic uses a bit faster access functions. And the pre-compiler ignores INLINE code.
That should be done in the library (Box2D) you are using.