3
\$\begingroup\$

I'm trying to make a GUI library with SFML, and everything's done except for one problem: making the interface stay still even when the camera moves or zooms in and out.

This would be easy to fix if zooming wasn't possible, but zooming out means having to scale the contents of the interface up so it doesn't shrink, which causes it's text/images to become blurry.

Does anyone have a way to get around this issue (preferably only using SFML as I don't want to make my library OpenGL-dependent)?

\$\endgroup\$

2 Answers 2

13
\$\begingroup\$

After you've rendered the world, reset the camera position to something more useful for UIs. Then render the UI. Next frame, put it back to the world position before rendering the world. And so forth.

By "camera position" I really mean "transformation matrix". Nobody says all rendering has to go through the world transformation.

\$\endgroup\$
2
  • 3
    \$\begingroup\$ +1 the last sentence should read: not all rendering should go through the same view/projection transformation, one can even switch between perspective and orthogonal view in the same render tick \$\endgroup\$ Commented Jul 30, 2011 at 10:31
  • 3
    \$\begingroup\$ @Maik Semder good point on noting the switch to orthogonal, which is likely to be what the OP needs for a UI. \$\endgroup\$
    – jv42
    Commented Jul 31, 2011 at 11:05
7
\$\begingroup\$

In SFML terms, you should be changing the active sf::View on your RenderTarget between rendering the world and the GUI. Your world View should be whatever is most convenient for your world rendering and centered on your player position; your UI View should be pixels or some standard resolution, rooted at the origin.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .