19

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.

4
  • 3
    Questions asking for off-site resources (such as tutorials) are off-topic for StackOverflow.
    – JAL
    Jul 24, 2015 at 16:04
  • 1
    possible duplicate of Learning SDL in C
    – MC10
    Jul 24, 2015 at 16:05
  • 1
    @MC10 that one is for SDL 1.
    – Quentin
    Jul 24, 2015 at 16:09
  • @JAL Yes I know. I asked anyway because I ran out of options. Now I don't ask anybody to look for this matter in my stead. I was simply hoping someone might have had the same issue and might remember where they found an answer for this. But I figured that worst case scenario, my post would get no answer / get deleted, but that if things were to turn well, I might get some help anyway. It's worth trying.
    – MrChwepsy
    Jul 24, 2015 at 16:11

1 Answer 1

26

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!

1
  • 8
    You probably helped me a lot (even though I have not read all those links' content yet) despite of Stackoverflow's policy concerning "asking for tutorial", and for this I am truly greatful. Thank you a lot. Most of the tutorials I've seen so far started would start creating a class (which I try to picture as some kind of structures), and I was afraid to "translate them" in C. But you're right, I should have asked for help on that matter instead. Anyway, again, thank you (a lot).
    – MrChwepsy
    Jul 24, 2015 at 17:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.