r/C_Programming • • 26d ago • Mindblown 1 Heartwarming 1

Video Lets build a JRPG Game in SDL3 (C programming)

https://www.youtube.com/watch?v=dV30oggjPYs&ref=reddit

In this video we will be creating a window in SDL3 and further draw map using tilemap technique which will stand as our foundation for render Tiled Maps. I will be using a 16px tileset to render our map today.

[Handmade code, you can as well see in this video. NO AI USED.]

Code: https://github.com/steelx/sdl3-tutorial

170 Upvotes

23 comments sorted by

•

u/AutoModerator 26d ago

Hi /u/laggySteel,

Your submission in r/C_Programming was filtered because it links to a git project.

You must edit the submission or respond to this comment with an explanation about how AI was involved in the creation of your project.

While AI-generated code is not disallowed, low-effort "slop" projects may be removed and it's likely that other users push back strongly on substantially AI-generated projects.

You can read more at How do I post my Project?


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

19

u/siendo64 26d ago

This is great! Thanks for sharing. Love seeing more low level C tutorials that don't use AI. We need more like this.

4

u/laggySteel 26d ago

Thanks for watching . There is so much AI on internet, but few video inspired me. I'm definitely going to take this series to Exploration, Combat stages of JRPG.

6

u/mikeblas 26d ago

Thank you for your disclosure. I've approved your post.

1

u/laggySteel 26d ago

🎈 yey 

2

u/justachemist 24d ago

I know this is a question that's difficult to answer, but will you finish it? I ask because there are so many unfinished SDL tutorials out there, and I remember back in the day being infuriated when I got to the newest tutorial, only to realise the creator had dropped off the face of the earth :')

1

u/laggySteel 23d ago edited 23d ago

Great question and the answer comes down to my history. I'm person who left his huge software engineering salary for doing just what I love. And my plan is set, I will definitely not leave this unfinished. May take more time as I'm recording this only over weekends. 

2

u/idontthinkofanamelol 26d ago

SDL3 isn't the best choice for every game project but it's more than good enough for a passionate RPG.

2

u/lordoflight03 26d ago edited 26d ago

Generally new to this topic. How would one go about deciding something like this?

edit: typo and grammar

-6

u/idontthinkofanamelol 26d ago • Bravo

SDL3 is almost entirely singlethreaded. It doesn't let you handle many things asynchronously. So, that's a limitation. For something with high performance requirements, a single thread might not be enough. Secondly, it's just way too general. You don't need to use SDL3 for something that will run on a single platform. It's meant for apps that need to run on multiple OSes and CPU/GPU architectures. It's also wasteful and it uses OpenGL for many platforms and acts as a layer over that. If you are just learning graphics, SDL3 as a versatile multimedia platform or OpenGL as the minimal graphics API are fine. But if you are looking for a really serious and challenging project, it's more than worth it to learn Vulkan. Some people might hate that i say this but Vulkan isn't impossible to learn for beginners. It shouldn't be your first experience with graphics but it's very rewarding to learn. Also very easy to mess up. That's just my experience, though.

9

u/lordoflight03 26d ago

I am trying to understand this single threaded comment, where does SDL_thread fit into this?

Is it just a lib that SDL provide to do multi threading and the "other" computation happen singled threaded.

12

u/syntactic_stevia 26d ago

He's just making broad generalizations, and lots of nonsense regarding performance. SDL3 is basically a platform abstraction layer, and is as thread safe as the underlying systems. If it's not thread safe in SDL3, it's not thread safe in general.

You can also just pick and choose which SDL systems to use, and roll your own if you need to. It's just not worth losing sleep over the core utilization of resizing a window.

2

u/idontthinkofanamelol 26d ago

You're right. Maybe i generalized too much when thinking about performance and utilization. I personally lost sleep over the core utilozation of resizing a window though so maybe i am biased (and not normal). SDL3 is thread safe, i got that confused. My concerns about performance were too insignificant for this case, so you're right.

4

u/tulpyvow 25d ago

SDL can be multithreaded, it is your responsibility to set that up and to figure what elements can/can't be multithreaded (the doc comments in the headers usually indicate if it is or not).

Also, SDL3 has vulkan and the GPU module now. You can make highly efficient software using it that still supports multiple platforms.

3

u/idontthinkofanamelol 25d ago

Thank you. I didn't know it had newer features. I might have been too narrow sighted because I didn't have a personal multiplatform project so i used plain Vulkan with win32.

1

u/CreaTbJ 25d ago

redemption arc

1

u/idontthinkofanamelol 25d ago

That started when i decided to build my project.

1

u/TheBuzzSaw 24d ago

I'm curious as to why you think this. SDL3 has one of the better rendering engines, and even when you graduate to OpenGL/Vulkan/SDLGPU, you continue using SDL3 for windowing, event-handling, etc. It's a core product in Steam too.

1

u/idontthinkofanamelol 24d ago

SDL3 is amazing for many things. But honestly, for most cases, it shouldn't be used for a single platform and platform-specific API should be used for window handling instead. That's what i saw and learned on a Windows project. First i wanted to use SDL3, but i decided to start over with Vulkan for rendering + winapi for syscalls, events and window handling and it's a nice separation of concerns. Since it's platform specific it works more explicitly which i enjoy.

1

u/TheBuzzSaw 23d ago

SDL is relatively thin in terms of mapping to underlying OS specifics. Outta curiosity, what did you need from win32 that SDL doesn't offer?

1

u/idontthinkofanamelol 23d ago

SDL3 has many things on win32 on a thin layer as you said, it was just that i did not want the whole SDL package for things i didn't need to do. There was kind of an unnecessary dependence chain in my eyes because SDL3 is also quite OOP oriented in some ways. Winapi has clearer ways of window management, especially with window messages and how you handle them, it feels closer to the core so it just feels like i am using what i'm actually supposed to yk, because my aim isn't any more platforms than Windows.

3

u/wtom7 23d ago

Even then there are still advantages to using SDL. You get a clean, simple, and readable library that has been developed over decades to handle all of the weird quirks of Windows and MacOS and the very very fragmented Linux ecosystem, plus modern consoles too if you ever go down that route. Not to mention the very cohesive gamepad support in particular.

And I'd disagree with critiquing SDL on the basis of being object-oriented; when you're creating a cross-platform library that deals with modern OS concepts like windows, file handles, threads, and devices, you're kind of inevitably going to have an API that deals with nouns and verbs you can do with those nouns, unless you're writing it in some obscure way to deliberately avoid that sort of thing. It's not an OOP rat's nest of inheritance and polymorphism and AbstractFactoryManagerStrategy classes; it's simple and straightforward C code that can even be useful to refer to if you're building a platform layer yourself.

Nothing wrong with using WinAPI directly if you only want to target Windows, need to do specific things SDL doesn't have, want to shave off a couple megabytes, or just want to have more control or learn to do it yourself. But SDL is a very popular choice for a reason!

1

u/TheBuzzSaw 22d ago

I fully respect both wanting to learn the lowest possible layer and avoiding unnecessary dependencies. It's not my intent to discourage you from doing that, but I just don't quite follow your reasoning for doing so.

SDL and Win32 are quite similar. They both support blocking and non-blocking event pumping. Most (relevant) enums in Win32 map 1:1 with an SDL enum. SDL just lets me write significantly less code because most games want the same basic window setup, and I get more operating systems for free.

I don't understand the OOP angle either. SDL and Win32 follow the same pattern: create a resource, capture it to a handle/pointer, and interact with that resource using functions. What does SDL do that makes it feel different in that regard?

Regardless, good luck. I do think Win32 knowledge is useful.