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

Author Topic: render text at opengl coords  (Read 1657 times)

0 Members and 1 Guest are viewing this topic.

greenmuzz

  • Newbie
  • *
  • Posts: 4
    • View Profile
render text at opengl coords
« on: September 14, 2010, 06:08:38 pm »
Hello,

Say my openGL coordinate system is not the same as the window coordinate system, and I've used various glTranslates etc to move to a specific part of the screen. Can I get SFML to write text at that location (the location where a glVertex would draw a point), or do I need to manually convert the coordinates?

e.g. Maybe I have a window of 800x600, and have used a glOrtho2D(0,50,50,0,-10,10), done a glTranslate off to (8,27), and want to draw some text there (a label on a bounding box). Do I need to manually convert that (8,27) to pixel coordinates in the 800x600 window, or can I directly get SFML to draw text at (8,27)?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
render text at opengl coords
« Reply #1 on: September 14, 2010, 06:39:00 pm »
You need to convert, but it's not very hard, you simply needs to multiply your point by the model-view and projection matrices (and adjust by the viewport if it's different from the window area).

I think there's even a function in GL or GLU to do that (gluProject maybe?).
Laurent Gomila - SFML developer

greenmuzz

  • Newbie
  • *
  • Posts: 4
    • View Profile
render text at opengl coords
« Reply #2 on: September 14, 2010, 07:02:28 pm »
cheers,
I can do the conversion happily enough, just hoped I wouldn't have too. :)

 

anything