3
\$\begingroup\$

I'm going over some SDL tutorials aimed at creating 2D games.

However, when I create a basic SDL program - is it hardware accelerated?

Or is hardware acceleration only relevant when it comes to 3D animations? Can a GPU help when it comes to pure 2D graphics?

\$\endgroup\$
3
  • 2
    \$\begingroup\$ It's not accelerated. And yes, GPU may be very useful for 2D. \$\endgroup\$
    – szotp
    Commented Feb 8, 2013 at 22:14
  • \$\begingroup\$ Is there an easy option to accelerate it? \$\endgroup\$
    – jcora
    Commented Feb 8, 2013 at 22:22
  • 1
    \$\begingroup\$ Not sure what are your options with SDL (probably, only direct OpenGL). I prefer SFML library, cause it uses GPU without any additional effort. \$\endgroup\$
    – szotp
    Commented Feb 8, 2013 at 22:37

1 Answer 1

7
\$\begingroup\$

No. SDL's drawing primitives do not match modern hardware well. I've been told that projects like SDL_gfx seek to offer an accelerated but simple 2D drawing API, though the docs indicate otherwise (it looks likw SDL extensiona). I believe the prerelease SDL 2.0 code has hardware accelerated 2D.

Building your own over OpenGL or Direct3D is another option, easier than you might think, and is what most native-codec"real" 2D games do these days. If you understand the hadware, making a fast 2D renderer is not terribly hard or time consuming.

SFML HAS A hardware accelerated graphics module, and in my non-objective opinion is a far better, more modern, easier to use API than SDL anyway. It also allows shaders and such in its 2D API, unlike SDL. I'd recommend the prerelease 2.0 version, as I ran into some WONTFIX bugs in SFML 1 a few years ago that are fixed for 2.

Doing 2D well, like doing 3D well, requires understanding how modern hardware works and batching together objects with the same render state and layer. SDL 1.x dates back to the days of old Windows DIB/GDI interfaces and X.org drawing, which no longer work well on modern hardware, as the old 2D rendering parts of graphics chips are long gone. Everything today is triangles and shaders. Even line rendering is typically done by drawing a thin triangle or quad (pair of tris), and blitting or clearing a rectangle is done by drawing a quad (the APIs hide that, but the hardware often has no dedicated line rendering hardware).

APIs like SDL's are faster in software these days. It's still way faster to properly use the hardware, but doing so is very different than using SDL 1.x.

\$\endgroup\$
3
  • \$\begingroup\$ Thank you. I'm not really able to research now, but does SMFL support things like event handling, sound, etc? \$\endgroup\$
    – jcora
    Commented Feb 9, 2013 at 7:37
  • 1
    \$\begingroup\$ Yes - "SFML is a free multimedia C++ API that provides you low and high level access to graphics, input, audio, etc." \$\endgroup\$
    – user14992
    Commented Feb 9, 2013 at 16:45
  • 1
    \$\begingroup\$ @Yannbane: SFML can be thought of as a modern C++ replacement for SDL. I've found that less experienced programmers can pick up SFML way faster than SDL, usually. If you plan on writing your own renderer, though, it really doesn't matter which you use; they both work just fine. \$\endgroup\$ Commented Feb 10, 2013 at 18:51

You must log in to answer this question.

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