Why do people use SDL with OpenGL?

Started by
3 comments, last by rip-off 13 years ago
I've played with OpenGL before but not for very long. I've noticed that the id tech engine uses SDL alongside OpenGL but I don't really understand why? DirectX 10 uses on screen quads with textures to render 2d sprites so I'm wondering why not just do that with OpenGL? I'm pretty sure playing 3d audio would still require OpenAL so why even use SDL for audio? On top of that I'm pretty sure anything else SDL does would be covered by [font="Arial"]wxWidgets or even [/font][font="Arial"]GLFW. Why is SDL the standard?[/font]
Advertisement
SDL or SFML are just cross platform wrappers. Assuming it works on all your platforms, it means less code you have to port. Simple stuff like creating an OpenGl window and context is different depending on the platform, but SDL wraps it into a common call on all platforms. I'd still choose to use something like FMOD directly over SDL_Audio, but again, it's just another wrapper over the basic functionality provided by the OS.

Sure, all the functionality is provided by underlying code you could also be writing. But why rewrite it? There is usually no need, so most people just grab a wrapper.

I've played with OpenGL before but not for very long. I've noticed that the id tech engine uses SDL alongside OpenGL but I don't really understand why? DirectX 10 uses on screen quads with textures to render 2d sprites so I'm wondering why not just do that with OpenGL? I'm pretty sure playing 3d audio would still require OpenAL so why even use SDL for audio? On top of that I'm pretty sure anything else SDL does would be covered by [font="Arial"]wxWidgets or even [/font][font="Arial"]GLFW. Why is SDL the standard?[/font]

SDL tries to be the proverbial Jack of all trades, and naturally is master of none. The best thing is to use different libraries optimized for each specific thing you need. In some cases, you can even beat the native Windows API for things such as mutexes: http://locklessinc.com/articles/keyed_events/ (also check other articles on this site for more, it's a goldmine or extreme optimization)
"But who prays for Satan? Who, in eighteen centuries, has had the common humanity to pray for the one sinner that needed it most?" --Mark Twain

~~~~~~~~~~~~~~~Looking for a high-performance, easy to use, and lightweight math library? http://www.cmldev.net/ (note: I'm not associated with that project; just a user)

DirectX 10 uses on screen quads with textures to render 2d sprites so I'm wondering why not just do that with OpenGL?


They are. When you use OpenGL with SDL, you can't use any of the SDL drawing functions because those are only designed to work in software rendering mode. When you use SDL with OpenGL, you're using it as a cross-platform input and window-management wrapper.
Because setting up basic window and input in SDL is a handful of easy to read lines of code, as opposed to massive boilerplate with most other systems. It is a simple, solid API. SDL is also pretty lightweight compared to wxWidgets. I've never used GLFW so I can't comment on that.

This topic is closed to new replies.

Advertisement