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.

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?

share|improve this question
2  
It's not accelerated. And yes, GPU may be very useful for 2D. –  krzat Feb 8 '13 at 22:14
    
Is there an easy option to accelerate it? –  akled Feb 8 '13 at 22:22
1  
Not sure what are your options with SDL (probably, only direct OpenGL). I prefer SFML library, cause it uses GPU without any additional effort. –  krzat Feb 8 '13 at 22:37
add comment

1 Answer

up vote 6 down vote accepted

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.

share|improve this answer
    
Thank you. I'm not really able to research now, but does SMFL support things like event handling, sound, etc? –  akled Feb 9 '13 at 7:37
1  
Yes - "SFML is a free multimedia C++ API that provides you low and high level access to graphics, input, audio, etc." –  andrew Feb 9 '13 at 16:45
    
@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. –  Sean Middleditch Feb 10 '13 at 18:51
add comment

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.