SDL/OpenGl or just OpenGL

Started by
10 comments, last by Ezbez 18 years, 6 months ago
I have been using c++ with SDL to make games for almost a year now and have a fairly good understanding of how to make a game. I will want to learn OpenGl sometime soon-ish(aka:within a couple months). Since I already have a good idea of how to use SDL, should I go with OpenGL that is used through SDL(whatever the term is...), or should I learn OpenGL with no SDL? Thanks!
Advertisement
That is dependent on if you want to use another API to get your input and sound. If it's not broken, don't fix it.
SDBradley
CGP
"A person who won't read has no advantage over one who can't read." ~Mark Twain
If you're on Windows, you'll have to learn some simple Windows programming before you can get an OpenGL app to run. You can't just use OpenGL, as it doesn't have a windowing system.

You can use Nehe's OpenGL code that's ported to Linux/SDL. It compiles and runs under Windows.
I don't know how comfortable you are with the Win32 API, but I'd recommend sticking with SDL for now, since you're already very familiar with it. In my experience, there's not much difference between using the Win32 API compared to SDL as far as OpenGL is concerned, but you lack all of the convenient input and event interfaces that SDL provides.

All in all, if you're more comfortable using SDL as opposed to the Win32 API (especially with input polling) then learning OpenGL through SDL will make it that much easier for you.

:stylin: "Make games, not war.""...if you're doing this to learn then just study a modern C++ compiler's implementation." -snk_kid
SDL is pure awesomness. I use it whether I'm rendering with SDL/OGL/D3D/whatever.

That said, I have 0 win32 experience because of it... >_>
Will OpenGL with SDL have any noticble difference in speed compared to with the Win32 API? And if at any point I wanted to switch to Win32 API after learning it with SDL, would that be fairly easy?
Essentially SDL just makes all of the win32 calls for you (and just acquires a render context) so using it to do just that won't have any effect on performance. There are some drawbacks to it though, like not having full control over how the window is created (because SDL does that for you), but most of the stuff you'd want is accessible through SDL functionality.

I'm not aware of any significant overhead when using the event part of SDL, however I'd imagine that (since its a level of abstraction that actually gets used during runtime, as opposed to launchtime) there is a minimal overhead. I don't think that its enough to actively worry about though.

As per switching out to win32 code at a later date - I mean, its all based on how you set your code up to begin with. Sure, if you abstract all of your event processing and window generation, it'll be pie. But if you're using abstraction and polymorphism and pie, you'll have the overhead of looking up virtual functions from the tables. Which again, isn't too much to worry about.

In the end, it all comes down to preferance. I've used both win32 and SDL, and I prefer having SDL do all the stuff for me, simply because I don't like the feel of win32.
If your interest is in graphics programming and not win32, I suggest sticking to SDL. That way you'll spend less time figuring out win32 and more time working with OpenGL.
-------------------------------See my tutorial site: Click here
I would also recommend staying with SDL to do your windowing/input and OpenGL for 3d. This way your app will remain cross-platform and you can share stuff with your Linux and Mac buddies......

Performance-wise there is practically no difference. SDL is basically a very-thin wrapper around Win32 calls.

Win32 is not exactly fun either - it is boilerplate code, basically the same everytime.
Don't forget now it all comes down to what you want to do in your game. If you continue to use SDL, you already have a lot of functionality built it as well as provided in easy to download and install libaries. These include cd-rom support, audio, joystick/game pad controls, and networking. If you decide to use Win32, you will have to put together other libraries into your game to get that same functionality. While not all of those componets are 'the best', they are decent enough to get you started with a basic game without too much headaches of finding alternatives.

Quote:And if at any point I wanted to switch to Win32 API after learning it with SDL, would that be fairly easy?


Not at all, learning Win32 is seperate from SDL. SDL wraps a lot of the Win32 functionality, so it does not make it any easier to use after you use SDL. If you didn't use SDL with OpenGL, you could just use Win32 api and learn it that way if you wanted to. Although there are other options to use for OpenGL besides Win32, such as GLFW.

So it all comes down to this. If you are comfortable with SDL, then continue to use OpenGL though it. SDL is just an application framework for SDL when used in that context. You will have additional functionality at your disposal to make your game. All of the OpenGL coding will be the same, excluding the setup/cleanup portions. If you do want to learn the Win32 API though, go ahead and start with it, using SDL won't help you there any.

This topic is closed to new replies.

Advertisement