Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking collision between two glutSolidCube objects

I am implementing a small blocks stacking game in opengl with c++. I have to use glutSolidCube objects of random sizes which will fall from the top of the screen towards a floor and if they collide with some other glutSolidCube object which is already on the floor, they will be stacked above the other object or else they will come to rest when they hit the floor. I cant find any possibility to check when one glutSolidCube object collides with the other, does anyone have any idea how this could be done?

like image 995
Muhammad Omer Avatar asked May 07 '26 09:05

Muhammad Omer


1 Answers

OpenGL is just a fancy triangle rasterizer. glutSolidCube() draws some triangles that happen to look like a cube. There are no "objects" to test for collision, just pixels in a framebuffer.

You'll have to implement your own collision detection system independent of OpenGL.

Or use something off the shelf.

like image 145
genpfault Avatar answered May 08 '26 22:05

genpfault



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!