SFML community forums

Help => Graphics => Topic started by: greenmuzz on September 14, 2010, 06:08:38 pm

Title: render text at opengl coords
Post by: greenmuzz 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)?
Title: render text at opengl coords
Post by: Laurent 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?).
Title: render text at opengl coords
Post by: greenmuzz on September 14, 2010, 07:02:28 pm
cheers,
I can do the conversion happily enough, just hoped I wouldn't have too. :)