2D physics in OpenGL (Visual C++ 2010)?

I've been studying C++ for quite a while now and I can assure you that I'm not even close to fully mastering it.
However, I decided to learn something about OpenGL and have followed a series of tutorials on how to use it.
I can draw shapes, map textures, map heights, apply light et cetera, yet I can not figure out how to work with 2D physics.
I've been searching all over Google for it, but all I get is one or two tutorials on 3D physics, which to me are not that relevant without a proper explanation.
I ought to admit that I have some issues with the utilisation of mathematical logic in my programming, but this might be due to the fact that I have never really had the need to utilise it and I have not yet seen any good examples on this specific subject.
I hope somebody can supply me with (a) tutorial(s) and/or examples.
Thanks in advance.

I've been searching all over Google for it, but all I get is one or two tutorials on 3D physics, which to me are not that relevant without a proper explanation.

The same things that apply to 3D apply to 2D as well. Physics are really are nothing more than rules you personally set. So the question I have to ask is, what is it that you want to do? There is no thing as "this is how you do physics in a program", it all depends on you.
Of course they want rigid dynamics... Um, just learn about linear algebra. Vectors! Quaternions! Cross products! Dot products! YAY SO FUN !!
Linear Algebra is magic.

I learned the basics (and I mean basic basics) and implemented it in my 2D game engine and it makes things soooo much easier.

Or at least, it's easier after you understand it. Understanding it is difficult XP
Disch, if you don't mind (I don't know, while we already are at maths and stuff): I am trying to get the formula for the intersection of two lines (guess what, for a game engine). I did actually already find the formula on some other site, but when I try it myself I always get a slightly different one...

If I'd write out my steps in latex, would you mind looking into them and telling me where I go wrong? Knowing where my formulas come from is a big deal for me.
Last edited on
I love how you said 'Linear Algebra is magic'. That just made my day.
Disch, if you please want to look into it -
http://tinyurl.com/6cmcrk9

That's my derivation of the intersection formula, but it doesn't seem to be quite right, at least not according to this:
http://paulbourke.net/geometry/lineline2d/lineline2.gif

There is a plus in my denominator where there is a minus in the formula I found. Otherwise my formula is identical to the other one, so I really have no idea as to what I could have done wrong.

EDIT: Oh, never mind. The formulas are actually completely identical, it's just that his derivation was probably a little bit different, so he ended up with a different order for the polynomials, so he had -(B-A)(C-D) and i had (A-B)(C-D) instead lol
Last edited on
Sorry I didn't get to this yesterday.

Glad you got it figured out!
Topic archived. No new replies allowed.