0
\$\begingroup\$

By that, I mean that SFML has an abstraction for OpenGL? Sort of like SDL's blit functions, but using OpenGL internally?

"Yes SFML uses OpenGL for all the graphical stuff. "

Received this comment in an earlier question, which sort of baffled me since I find nothing about it.

\$\endgroup\$
6
\$\begingroup\$

Yes, it does use OpenGL for some operations. You can get the full list from the source code. The major uses are, as of SFML 1.6:

  • RenderTarget.cpp: set up render targets, clear screen, set matrix mode etc.
  • PostFX.cpp: postprocess manager
  • Image.cpp and Sprite.cpp: texture and sprite handling
  • String.cpp: text writing

In the upcoming SFML 2.0, some of this is slightly modified because of the support for the fully programmable pipeline. For instance, Sprite.cpp no longer uses OpenGL directly, and instead fills vertex buffers for rendering by RenderTarget.cpp instead.

It is possible to use SFML without the application having knowledge of OpenGL, but its features will be pretty limited (basic sprite and text rendering, some post-process effects). The more common use case is to use SFML to create a GL context.

\$\endgroup\$
7
  • \$\begingroup\$ This question of mine came up when I was wondering how to use OpenGL in SDL, since using SDL's blitSurface quickly slowed my program enough to have to use full CPU. So I thought of using OpenGL with SDL to delegate the drawing on the graphic card and free my CPU. \$\endgroup\$
    – GigaBass
    Jan 2 '13 at 20:50
  • \$\begingroup\$ Woops, pressed enter ~ So basically, you're saying SFML does what I was aiming at with SDL + OpenGL? \$\endgroup\$
    – GigaBass
    Jan 2 '13 at 20:51
  • \$\begingroup\$ It does slightly more; SDL really leaves you with only the GL context, whereas SFML provides utility functions for loading images into textures, shader creation, postprocess effects, pushing/popping GL states… It’s not a replacement for a full rendering engine, but it does make your life easier if you’re rolling your own simple GL code. \$\endgroup\$ Jan 2 '13 at 20:52
  • \$\begingroup\$ So, if I "port" my SDL, software rendered game, to SFML, I'll be using graphic card and be very light on the CPU? Just to be sure. But I'll accept it asap, you've done enough \$\endgroup\$
    – GigaBass
    Jan 2 '13 at 20:55
  • \$\begingroup\$ Oh and as a final question, is SFML 2.0 stable enough to use? I'm reading some very good things about it! \$\endgroup\$
    – GigaBass
    Jan 2 '13 at 21:00

You must log in to answer this question.

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