Box2D in GLBasic?

Previous topic - Next topic

Bluepixel

Hi there, I am working on a small physics based game and would love to add in Box2D physics, since that's the only physics library for GLBasic I could find, so I found a Box2D library in the showroom, downloaded it, and ran the example project. The example project ran fine, but after compiling it within the editor it simply stated; *1 FAILED*. I created a hello world project, took the Box2D library and included it into my project, I ran it and the project failed, which leads me to believe that it's probably outdated, which is unfortunate since I was really hoping I could get some physics working :blink:

Anyone that can help me with this?



:offtopic: PS. I am very sorry about my frequent posts, I am rather new to GLBasic, so I am very curious as to of how things work. I will try to do as much research as I can on my own before posting anything. :offtopic:
www.bluepixel-studios.net

There are two ways to write error-free programs; only the third one works.
(Alan J. Perlis)

MrPlow

Hi

I will try out the box2d library and see if I can spot the problem...I used it briefly before for an older project.
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Bluepixel

Ah thanks a lot, tell me when you found something! :)
www.bluepixel-studios.net

There are two ways to write error-free programs; only the third one works.
(Alan J. Perlis)

Schranz0r

Hi,

read down the topic here :)
You need the Headerfiles for GLBasic!
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

erico

Wasen´t there a bullet physics implementation somewhere on the forum?
I recall watching a video about it and taking part on the discussion but I can´t seem to find the post anymore.

Bluepixel

@Schranz0r

Hi there, thanks a lot for the reply!  :)

Exactly how should I use these files?  O_O

I am quite new for GLBasic, so im a bit confused as to of how things work, sorry for that!
www.bluepixel-studios.net

There are two ways to write error-free programs; only the third one works.
(Alan J. Perlis)

Bluepixel

@erico
I believe its this one:
https://www.glbasic.com/forum/index.php?topic=7757.0

however i think its been made for 3d games, im not too sure tho, i havent been able to find a download.
www.bluepixel-studios.net

There are two ways to write error-free programs; only the third one works.
(Alan J. Perlis)

erico

Yes, that one, thanks. (I searched for those words, maybe I didn´t search well enough)
For 3d yep, for 2d I guess the box one is the way to go.

Bluepixel

@erico
Sadly I havent been able to get Box2D working yet, do you know if there are any other 2d physics engines for GLBasic?
www.bluepixel-studios.net

There are two ways to write error-free programs; only the third one works.
(Alan J. Perlis)

erico

I can´t remember any out of my mind.
I guess a person could wrap one into it but it is a lower level complex stuff (I don´t know how to do it).
You can also write your own system in which depending on the nature of the project, may not be much work and all within standard basic.

What do you plan to use it with?
Can you describe how in-project you want it working?

Bluepixel

@erico
I will be creating a small physics sandbox with a level editor, for example you can build a small car contraption with boxes, and possibly polyvectors, and make it roll down a hill. Possibly some ragdolls in the game too, maybe not a "too" complex project, but afterwards I can add more gameplay mechanics to make the game more interesting. I think my biggest struggle with making my own physics engine is collision.
www.bluepixel-studios.net

There are two ways to write error-free programs; only the third one works.
(Alan J. Perlis)

erico

I see, that is more complex than I thought it would be.
Box 2d is probably a faster solution than creating a system on your own.
Did you make it work?




Bluepixel

@erico
sadly not, here is the error message;

Quote*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.15.394 SN:1e80bd95 - 3D, NET
"glbox2d.gbas"(35) warning : GPC1001 probably unassigned variable : screenWidth
"glbox2d.gbas"(35) warning : GPC1001 probably unassigned variable : screenHeight
"glbox2d.gbas"(43) warning : GPC1001 probably unassigned variable : mbr
Wordcount:68 commands
compiling:
In file included from C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\sim_box2d.cpp:11:0:
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Dynamics/Contacts/b2PolyContact.cpp: In member function 'virtual void b2PolygonContact::Evaluate(b2ContactListener*)':
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Dynamics/Contacts/b2PolyContact.cpp:53:45: error: 'memcpy' was not declared in this scope
  memcpy(&m0, &m_manifold, sizeof(b2Manifold));
                                             ^
In file included from C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\sim_box2d.cpp:12:0:
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Dynamics/Contacts/b2CircleContact.cpp: In member function 'virtual void b2CircleContact::Evaluate(b2ContactListener*)':
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Dynamics/Contacts/b2CircleContact.cpp:54:45: error: 'memcpy' was not declared in this scope
  memcpy(&m0, &m_manifold, sizeof(b2Manifold));
                                             ^
In file included from C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\sim_box2d.cpp:13:0:
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Dynamics/Contacts/b2PolyAndCircleContact.cpp: In member function 'virtual void b2PolyAndCircleContact::Evaluate(b2ContactListener*)':
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Dynamics/Contacts/b2PolyAndCircleContact.cpp:54:45: error: 'memcpy' was not declared in this scope
  memcpy(&m0, &m_manifold, sizeof(b2Manifold));
                                             ^
In file included from C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\sim_box2d.cpp:25:0:
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Common/b2BlockAllocator.cpp: In constructor 'b2BlockAllocator::b2BlockAllocator()':
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Common/b2BlockAllocator.cpp:63:52: error: 'memset' was not declared in this scope
  memset(m_chunks, 0, m_chunkSpace * sizeof(b2Chunk));
                                                    ^
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Common/b2BlockAllocator.cpp: In member function 'void* b2BlockAllocator::Allocate(int32)':
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Common/b2BlockAllocator.cpp:120:62: error: 'memcpy' was not declared in this scope
    memcpy(m_chunks, oldChunks, m_chunkCount * sizeof(b2Chunk));
                                                              ^
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Common/b2BlockAllocator.cpp:121:79: error: 'memset' was not declared in this scope
    memset(m_chunks + m_chunkCount, 0, b2_chunkArrayIncrement * sizeof(b2Chunk));
                                                                               ^
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Common/b2BlockAllocator.cpp: In member function 'void b2BlockAllocator::Clear()':
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Common/b2BlockAllocator.cpp:202:52: error: 'memset' was not declared in this scope
  memset(m_chunks, 0, m_chunkSpace * sizeof(b2Chunk));
                                                    ^
In file included from C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\sim_box2d.cpp:36:0:
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Collision/b2BroadPhase.cpp: In member function 'uint16 b2BroadPhase::CreateProxy(const b2AABB&, void*)':
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Collision/b2BroadPhase.cpp:260:100: error: 'memmove' was not declared in this scope
   memmove(bounds + upperIndex + 2, bounds + upperIndex, (boundCount - upperIndex) * sizeof(b2Bound));
                                                                                                    ^
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Collision/b2BroadPhase.cpp: In member function 'void b2BroadPhase::DestroyProxy(int32)':
C:\Users\Bluepixel\Desktop\box2dinterfaceinglbasic\box2dtest\Box2D/Source/Collision/b2BroadPhase.cpp:340:104: error: 'memmove' was not declared in this scope
   memmove(bounds + lowerIndex, bounds + lowerIndex + 1, (upperIndex - lowerIndex - 1) * sizeof(b2Bound));
                                                                                                        ^
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Elapsed: 13.4 sec. Time: 11:10
Build: 0 succeeded.
*** 1 FAILED ***
www.bluepixel-studios.net

There are two ways to write error-free programs; only the third one works.
(Alan J. Perlis)

matchy


Add the file source '.\Projects\Box2D\Box2D.gbas' to '.\Projects\YourApp'!  ;)

MrPlow

I was planning to have a look at converting 'Box2D Lite' - in the new year....
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs