SFML community forums

Help => Window => Topic started by: fkrauthan on April 12, 2009, 07:39:01 pm

Title: Change origin
Post by: fkrauthan 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
Title: Change origin
Post by: Astrof on April 12, 2009, 07:56:36 pm
use SetCenter() (by Center it really means origin).
Title: Change origin
Post by: fkrauthan 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?
Title: Change origin
Post by: Tank 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. ;)
Title: Change origin
Post by: fkrauthan 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?)
Title: Change origin
Post by: Laurent 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).
Title: Change origin
Post by: Tank on April 15, 2009, 01:25:47 am
...which keeps the function still simple. :)