Sign in to follow this  
jwezorek

supporting multiple coordinate systems

Recommended Posts

I'm working on a 2D game framework that is currently on top of SFML. I want to add a feature to my framework in which the user can select at start-up between what the framework will refer to as "coordinate systems": (1) TopLeftOriginDescendingY, (2) BottomLeftOriginAscendingY, or (3) CenterOriginAscendingY.
 
The idea being that SFML uses (1), all flavors of cocos2d-x use (2) and I personally think (3) makes a lot of sense because of philosophic alignment with mathematics and makes sense practically for handling multiple screen size and aspect ratios.
 
I figured this would be an easy thing to do because I could just roll into my "coordinate mapping matrix, which transforms "logical coordinates" into screen coordinates another transformation that handles the 3 systems above in cases (2) and (3) doing a scale by (1.0, -1.0) to flip the vertical axis because SFML uses (1) by default. The problem with this, I realize now, is that scaling by (1.0, -1.0) will cause all of my sprites to be upside down. I could handle that by flipping the textures in memory if in inverted-y modes but it seems kind of inelegant. I am planning to eventually break my dependency on SFML and re-implement the part of SFML I am using directly on top of OpenGL so am now leaning towards not doing  "coordinate systems" right now but implementing it when I remove the SFML dependency.
 
My question is basically is there a more elegant way to do what I want to do in SFML that I am not seeing? Perhaps using the sf::view class which I havent touched before? If not am I right in assuming that allowing this feature in a direct OpenGL implementation will  admit a solution that does not involve me flipping texture raster lines?
Edited by jwezorek

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this