Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
    
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. –  GigaBass Jan 2 '13 at 20:50
    
Woops, pressed enter ~ So basically, you're saying SFML does what I was aiming at with SDL + OpenGL? –  GigaBass Jan 2 '13 at 20:51
    
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. –  Sam Hocevar Jan 2 '13 at 20:52
    
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 –  GigaBass Jan 2 '13 at 20:55
    
Oh and as a final question, is SFML 2.0 stable enough to use? I'm reading some very good things about it! –  GigaBass Jan 2 '13 at 21:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.