How do you learn an API such as SDL?

Started by
5 comments, last by DragonBooster 9 years, 9 months ago

After re-learning most of my programming with some console programs i would like to move on to using libraries which i can make a 2D game with such as SDL but the problem i have is... How do i learn an API? Because when i was trying to learn SDL from LazyFoo's tutorial i didn't get it because to me it kind of wasn't explained properly on what function is or what it does. How did you guys start learning SDL and other libraries?

Advertisement

Tutorials are supposed to get you started, to give you an idea of how to do common things with that API's approach. Maybe the LazyFoo's tutorials are not clear enough for you, but good tutorials at least tell you what a piece of code (not necesarilly each function) is doing and that's fine. If you're reading a tutorial an you want to be sure what every line is doing you can open the documentation on another tab and search every function that looks like magic.

Once you have some idea of how an API must be used a good source to learn the API is the documentation itself. Even if you're not looking at a tutorial, if you know what's the purpose of a class you can read the documentation for that class and you'll learn new things just by reading what methods are available.

Another great way to learn something is to just search how to do something with it. Say you have an image with white background and you want it to be transparent. You can edit the image and save it as PNG with a transparent background or you can search "SDL change white background to transparent" in google, and reading some answers you'll probably learn something new.

Also, some people buy books about certain API's.

I don't think there's a way to learn everything from an API from the same source, API's tend to be really big and giving examples and details of everything is a lot of work, and trying to teach everything in a progresive and clear way is a lot harder. At the end, you'll learn an API while using it and finding obstacles, wondering if something can be done and how can you do it.

After re-learning most of my programming with some console programs i would like to move on to using libraries which i can make a 2D game with such as SDL but the problem i have is... How do i learn an API? Because when i was trying to learn SDL from LazyFoo's tutorial i didn't get it because to me it kind of wasn't explained properly on what function is or what it does. How did you guys start learning SDL and other libraries?

I used the documentation: http://wiki.libsdl.org/APIByCategory. Once you know what to expect from a library it becomes quite easy to look in the documentation to find the information you need.

[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

Greatly appreciated. So in a nutshell you just have to know what each function/class does by looking at how it is used by looking at examples and experimenting with it.

How do you learn an API such as SDL?


Make something with it. Come up with some simple game/app. Try to make it. When you need some feature that you don't know how to use, look it up. By the end you'll know the gist of everything you need to and you'll have working sample code that you intimately understand since you wrote it.

The only way to learn anything for real is to _do it_. Practice, practice, practice.

Sean Middleditch – Game Systems Engineer – Join my team!

Greatly appreciated. So in a nutshell you just have to know what each function/class does by looking at how it is used by looking at examples and experimenting with it.


No, that is a bad way to go on about it. You might use a tutorial or example code to get an approximate idea where to start and then you use, as SimonForsman says, the documentation to understand the details. Just experimenting will not tell you about all those important details what an API promises under which condition and about where it explicitly makes no guarantees.

I see. Thank you for the warning Bitmaster. So you use tutorials to start of to get an idea on how to use the API and the documentation to understand the intricate the details of the code i want to use.

This topic is closed to new replies.

Advertisement