Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there good tutorials for SDL2.0 for C programming? (not C++) [closed]

Tags:

c

sdl-2

I'm a student learning C programming (at the moment).

In the subject I was given, I have to create some kind of Wolfenstein3d clone (hence the name of the project, "wolf3d"). To do this project, I'm allowed to use either the graphic library created by my school, or the SDL. I chose the SDL, because it is more complex to use and therefore more interesting.

Unfortunately, I was not able to find any tutorial for SDL2 in C. Even the SDL wiki links were all oriented C++.

I'd be grateful if you could help me finding good tutorials for the SDL2 in C (even though I know the policy of the website is "use a search engine, which I did, but as I said, I did not find any so far).

I think I might need to explain a few things about my school, in order to not give you the impression I'm asking you for help in order to cheat:

Why don't you look in your class notes?

Because I'm not given any. I'm given projects to do and sometimes few hints as how I should do them. I'm supposed to use Google or any means as long as I understand what I did.

And that's pretty much it. I'm also not looking for a tutorial on "how to create a wolfenstein3d clone using SDL2.0", but only a tutorial on how to use the SDL2 itself, from creating a window to drawing points.

like image 855
MrChwepsy Avatar asked Jul 24 '15 16:07

MrChwepsy


1 Answers

If I were you I would use the tutorials available on SDL's page here:

http://wiki.libsdl.org/Tutorials

In conjunction with the API documentation here:

http://wiki.libsdl.org/APIByCategory

The API is written in C so despite the fact that the tutorials may be in C++ you should be able to follow the tutorial by referencing the API docs and understanding the functional structure of the example programs.

As an aspiring developer you should be able to understand enough of the C++ syntax to understand the conceptual way you need to develop an analogous application in C. The API calls will be need to made in the same way.

Consider this page from one of the linked tutorials (which is stated as being for C++):

http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index2.php

Are any of those code blocks really foreign to you? They shouldn't be, they're written in C. If you come across some expressions you are unfamiliar with as you go through the tutorial, reference the API. If you're still stumped, then maybe it would be time to post on StackOverflow. That particular tutorial may be written completely in C, I'm not sure I only went through the first few pages.

Also note that the function documentation in the SDL API docs gives C and C++ example code:

http://wiki.libsdl.org/SDL_Init

Here you can cross reference two identical programs in C and C++ and begin to learn how the same operations are performed in the two languages. From there you can start to interpret C++ tutorials for high level functional operations and translate that to C as opposed to just copying code samples. You will learn much more going through this process.

To your own admission you decided to go the complex route. You should be prepared to invest some effort in the process!

like image 54
Kin3TiX Avatar answered Sep 21 '22 02:09

Kin3TiX