Jump to content
  • Advertisement
Sign in to follow this  

Calculation for flipping y coordinates

This topic is 4798 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to use glScissor and am having trouble calculating the upside down y coordinate. Does anyone know of a formula to calculate what the flipped coordinate would be for a right side up y coordinate?

Share this post


Link to post
Share on other sites
Advertisement
I was actually looking for something much less complicated. Something like this:
inline int FlipY(int totalH, int y)
{
//return formula to flip y
}

Share this post


Link to post
Share on other sites
how is gluProject complicated? get the projection matrices and the viewport, and feed them in. Any function you use will need to take those into account anyway.

Share this post


Link to post
Share on other sites
I will use it later but right now I'm just in ortho mode and the viewport is the whole window. I think a simple formula will be much faster than gluProject.

Share this post


Link to post
Share on other sites
Quote:
Original post by aewarnick
I think a simple formula will be much faster than gluProject.

Faster? Are you really calling glScissor millions of times per frame? (if so.... don't! [smile)

Share this post


Link to post
Share on other sites
I need to call it for each control (just drawings on main window) in my window per frame otherwise they will draw out of bounds sometimes. I'd probably call it at most 300 times per frame which is the worst case scenerio.

Share this post


Link to post
Share on other sites
Actually this is a better function definition:
inline int FlipDown(int viewPortH, int rightSizeUpY)
{
//return formula to flip Y from right side up to up side down
}

Share this post


Link to post
Share on other sites
Kalidor, I think that is right but I had forgot one thing, I'm still drawing up side down so I added one more variable.
inline int FlipDown(int viewPortH, int rightSideUpY, int objHeight)
{
//gluProject
return viewPortH-rightSideUpY-objHeight;
}

I think the code is right but my scissor box isn't working correctly. Is there a problem when calling glScissor box serveral times before glFlush or glFinish is called?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!