SFML community forums

Help => Graphics => Topic started by: AohmZ on August 05, 2012, 01:30:27 pm

Title: Making the draw origin in the bottom left
Post by: AohmZ on August 05, 2012, 01:30:27 pm
I have recently done an integration of Box2D into SFML, but working with the physics having an origin in the top left feels a bit... unnatural. I Googled around and found a post about changing the draw origin to the bottom left, and I was wondering if there has been any new development in doing so.

It's not really that big of a deal, but any help would be greatly appreciated. (This is with SFML 2)
Title: Re: Making the draw origin in the bottom left
Post by: eXpl0it3r on August 05, 2012, 03:38:01 pm
If I've understand you right, you want to have SFML a coordination system with a vertical y axis facing up and a horizontal x axis facing right, right? ;)

I think we've had this 'request' a few times and SFML won't nativly support this, that's mostly because it's very easy to do the correction yourself, just negate the y axis and you're good to go. ;)

(With a high enough abstraction level the physic part shouldn't even know anything about the graphics part, then you could easily swap the sign when updating the coordinates. ;) )
Title: Re: Making the draw origin in the bottom left
Post by: FRex on August 05, 2012, 05:29:07 pm
You can swap it. Just treat box2d coordinates like the sfml ones. The higher the y the lower the object is. Set your gravity to b2Vec2(0.f,9.8f), that way there is absolutely no +/- work to be done between box2d and sfml, but you still have to remember to convert meters to pixels and radians to degrees.
Title: Re: Making the draw origin in the bottom left
Post by: AohmZ on August 05, 2012, 07:41:26 pm
You can swap it. Just treat box2d coordinates like the sfml ones. The higher the y the lower the object is. Set your gravity to b2Vec2(0.f,9.8f), that way there is absolutely no +/- work to be done between box2d and sfml, but you still have to remember to convert meters to pixels and radians to degrees.

That's what I've already done, I was just wondering if I could do it differently.