Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Making the draw origin in the bottom left  (Read 3820 times)

0 Members and 1 Guest are viewing this topic.

AohmZ

  • Newbie
  • *
  • Posts: 4
    • View Profile
Making the draw origin in the bottom left
« 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)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Making the draw origin in the bottom left
« Reply #1 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. ;) )
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Making the draw origin in the bottom left
« Reply #2 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.
Back to C++ gamedev with SFML in May 2023

AohmZ

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Making the draw origin in the bottom left
« Reply #3 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.