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

Author Topic: Change origin  (Read 4497 times)

0 Members and 1 Guest are viewing this topic.

fkrauthan

  • Newbie
  • *
  • Posts: 4
    • MSN Messenger - fkrauthan@gmx.net
    • AOL Instant Messenger - fkrauthan
    • View Profile
    • http://games.fkrauthan.de
Change origin
« on: April 12, 2009, 07:39:01 pm »
Hello,
how can i change the origin of SFML from the upper left to the lower left like OpenGL Used it nativ?
fkrauthan

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
Change origin
« Reply #1 on: April 12, 2009, 07:56:36 pm »
use SetCenter() (by Center it really means origin).

fkrauthan

  • Newbie
  • *
  • Posts: 4
    • MSN Messenger - fkrauthan@gmx.net
    • AOL Instant Messenger - fkrauthan
    • View Profile
    • http://games.fkrauthan.de
Change origin
« Reply #2 on: April 12, 2009, 08:02:21 pm »
I'am new in SFML i get a View with sf::View& DefaultView = App.GetDefaultView();

ok? Then i set die Center at this View. Must i do somthin after that? Must i set the Center To 0,0 or to Window Height, 0 to have my orign aht the lower left corner?

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Change origin
« Reply #3 on: April 14, 2009, 01:49:56 am »
That's not possible at the moment. You have to calculate your coordinates on your own, like:

Code: [Select]
sf::Vector2f convertToX( const sf::Vector2f &src, const sf::RenderTarget &target ) {
return sf::Vector2f( src.x, target.GetHeight() - src.y );
}


Another possibility is to derive from sf::Sprite and reimplement Move()/SetPosition() etc. to use your own coordinate system.

Maybe you can also use some OpenGL functions to archieve that -- too bad my knowledge isn't that huge in that area. ;)

fkrauthan

  • Newbie
  • *
  • Posts: 4
    • MSN Messenger - fkrauthan@gmx.net
    • AOL Instant Messenger - fkrauthan
    • View Profile
    • http://games.fkrauthan.de
Change origin
« Reply #4 on: April 14, 2009, 11:03:32 am »
so you convert from OpenGL Coords to top left corner only at the move and setposition function or also at the Render function so that i translate it to my coords and in the render it would trasnlate to your coords? (Speed loos?)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Change origin
« Reply #5 on: April 14, 2009, 11:06:55 am »
Actually, the function to convert coordinates wouldn't be that simple. It would have to take in account the sprite's height and the target view (not the target window).
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Change origin
« Reply #6 on: April 15, 2009, 01:25:47 am »
...which keeps the function still simple. :)