Sign in to follow this  
Ezbez

SDL/OpenGl or just OpenGL

Recommended Posts

Ezbez    1164
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!

Share this post


Link to post
Share on other sites
CodeTitan    258
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.

Share this post


Link to post
Share on other sites
stylin    758
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.

Share this post


Link to post
Share on other sites
Mushu    1396
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... >_>

Share this post


Link to post
Share on other sites
Ezbez    1164
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?

Share this post


Link to post
Share on other sites
Mushu    1396
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.

Share this post


Link to post
Share on other sites
aaroncox1234    298
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.

Share this post


Link to post
Share on other sites
AzCoder    150
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.

Share this post


Link to post
Share on other sites
Drew_Benton    1861
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.

Share this post


Link to post
Share on other sites
markr    1692
SDL concentrates on software rendering, which you aren't going to be using with opengl. So some of its (SDL's) ability goes to waste.

Consider an alternative scheme for OpenGL context creation, such as GLFW, rather than using SDL. SDL is great as a primitive but somewhat confusing.

GLFW will give you a simpler, more pure OpenGL app. It won't worry you with software rendering rubbish.

Mark

Share this post


Link to post
Share on other sites
Ezbez    1164
Okay, thanks guys. It seems like I'll probably stick with SDL for now. And since I do have Mac/Linux freinds, using win32 might get them angry.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this