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

Author Topic: World to Window Coordinate Conversion?  (Read 1288 times)

0 Members and 1 Guest are viewing this topic.

TheDistur

  • Newbie
  • *
  • Posts: 8
    • View Profile
World to Window Coordinate Conversion?
« on: June 09, 2011, 10:29:39 pm »
Is there a function to convert a world coordinate to a window coordinate? I want to be able to use RenderWindow.SetCursorPosition() to set the cursor to a world coordinate. If there is not a function, does anyone have a preferred method of doing this?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
World to Window Coordinate Conversion?
« Reply #1 on: June 09, 2011, 10:55:36 pm »
This function doesn't exist. The conversion is not complicated (in SFML 1.6), a sf::View only has a position and a size; you just need to apply the inverse operation.

Out of curiosity... what are you doing? So far, I've only seen people using SetCursorPosition to implement first person camera movement.
Laurent Gomila - SFML developer

TheDistur

  • Newbie
  • *
  • Posts: 8
    • View Profile
World to Window Coordinate Conversion?
« Reply #2 on: June 09, 2011, 11:11:11 pm »
I'm using box2d with sfml and I'm creating objects by clicking and dragging the mouse. When dragging I don't want the cursor to go past the corner of the ghost object when it hits another object (checked using box2d). Otherwise the cursor keeps going past the corner of the ghost and I think that looks strange. It's not really that important though.

 

anything