I have been trying to get world coordinates of the cursor position for a program by:

  1. getting the top and left position of the client of the window
  2. getting the global position of the cursor (GetCursorPos())
  3. cursor x - client left and cursor y - client top
  4. zoom x and y = client width and height / 100 (the openGL world size in the program)
  5. divide cursor pos x and y by zoom x and y

I made it up myself so it may have major errors.
it doesn't work, but am I along the right lines or is there an obvious reason for it not working?

Recommended Answers

All 2 Replies

Can you follow up the GetCursorPos() with a call to ScreenToClient()?

yes I will try that...
done, it works exactly the same, but with less code so thanks.
but the problem is the same, am I doing it right?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.