Jump to content

  • Log In with Google      Sign In   
  • Create Account


Why do people use SDL with OpenGL?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 SteveDeFacto   Banned   -  Reputation: 109

Like
0Likes
Like

Posted 13 April 2011 - 10:47 AM

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 wxWidgets or even GLFW. Why is SDL the standard?

Sponsor:

#2 KulSeran   Members   -  Reputation: 2287

Like
0Likes
Like

Posted 13 April 2011 - 11:15 AM

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.

#3 Prune   Members   -  Reputation: 216

Like
-1Likes
Like

Posted 13 April 2011 - 11:16 AM

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 wxWidgets or even GLFW. Why is SDL the standard?

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)

#4 Dementia   Members   -  Reputation: 123

Like
0Likes
Like

Posted 13 April 2011 - 12:21 PM

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.

#5 rip-off   Moderators   -  Reputation: 8049

Like
0Likes
Like

Posted 13 April 2011 - 12:37 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS