Jump to content

Vulkan tutorials for C

Okay, so .. before I begin - c++ is NOT AN OPTION!!!! Do not recommend it

Does anyone know where I can find some tutorials for C and Vulkan?
OpenGL is slower than Vulkan.

And every.fucking.tutorial.seems.to.be.for.C++. WHY??!?!
I heard that Vulkan is written in C..

What are my options?! Follow tutorials for C++ and somehow find C alternatives for libraries and code? I am not sure if I can even do that.

Why would I even use an API? - For speed, compatibility and for the sake of not inventing the wheel and spending months on something that would only cause chaos..
I need speed and compatibility if possible.

Can anyone help me out?
Tutorials I have found say that "If you are using C or rust - it is doable".. like the fuck?

I cannot quote people with the built-in function because I almost never enable JavaScript on websites. You won't get notified if I reply to you, sadly :/

Link to comment
Share on other sites

Link to post
Share on other sites

You can easily follow C++ tutorials and just adapt them to C. The glfw library is written in C so there are no compatibility barriers; the only thing you may need to change is the linear algebra library, which is not specific to Vulkan.

54 minutes ago, ZFSinmylungs said:

Why would I even use an API? - For speed, compatibility and for the sake of not inventing the wheel and spending months on something that would only cause chaos..

Then why are you using C?

54 minutes ago, ZFSinmylungs said:

OpenGL is slower than Vulkan.

What could you possibly be trying to make - on your own and with limited programming experience - that would require better performance than OpenGL?

57 minutes ago, ZFSinmylungs said:

Tutorials I have found say that "If you are using C or rust - it is doable".. like the fuck?

Also you should calm down. If you don't understand something or can't find a tutorial that's not a good reason to vent on a forum while asking for help.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

https://vulkan-tutorial.com/ Their C++ tutorial uses the Vulkan C bindings (Vulkan-H) instead of the C++ Vulkan bindings (Vulkan-Hpp) so you're don't have to worry about different API calls. All you have to do is essentially get rid of the C++ features and idioms such as classes and RAII. It doesn't really get too deep into C++ so it's pretty straight forward to strip out and become a pure C implementation. 

 

This is probably the best you're going to find because C++ is the standard when it comes to game development which is what drives 3D graphics forward the most. Typically you're some weird unicorn when you're using something other than C++ for 3D rendering APIs/Specifications (less so with C but still). So thats why every tutorial and book that you will find on the subject won't cover anything in any other language. You're not expected to use anything else and if you do thats on you as the developer to adapt.

 

Even the tutorials themselves are never written for beginner programmers because its supposed to be the concepts not the code that you're grasping. Even then most tutorials are very limited since they're supposed to get you off the ground with the API and then you're supposed to go read the docs for everything else.

 

As far as the Vulkan API being written in C its true because almost every language/platform out there can use C bindings. This is what helps Vulkan shine since its a unified API across all platforms (including mobile) so its less workload for developers to port their project to other platforms.

 

TL;DR When you get into 3D rendering you're in a C++ world. You're going to have to bite the bullet and learn from the C++ tutorials.

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

@Sauron

"You can easily follow C++ tutorials and just adapt them to C. The glfw library is written in C so there are no compatibility barriers; the only thing you may need to change is the linear algebra library, which is not specific to Vulkan."
Hmm yeah I have the glfw package installed.
About the linear algebra.. does the math library have that or any one you recommend?

"Then why are you using C?"
What do you mean? I just told you

"What could you possibly be trying to make - on your own and with limited programming experience - that would require better performance than OpenGL?"
Something amazing. Limited programming experience? It's not like I wasn't a newbie once at something and now better - it's more than once. A beginner? - that only means I can excel.
What do you mean? You sound like you're against someone wanting best performance at a reasonable sacrifice(yes, Vulkan counts as one)?

"Also you should calm down. If you don't understand something or can't find a tutorial that's not a good reason to vent on a forum while asking for help."
Don't tell me how to feel. I was not venting out, that's me just being normal. For something that's apparently written in C - for it to not have tutorials in C is just confusing.. but like you said ... I do know that C++ is basically supposed to be an successor to C and is similar to C - I don't know what the differences are other than that C++ has strings and .cpp .chh and stuff alike, again - I am a beginner in C, yes.

P.S. Why did you guess that I'm a beginner? Is it because I do not know some of differences between C and C++?

####################################3
@trag1c

"https://vulkan-tutorial.com/ Their C++ tutorial uses the Vulkan C bindings (Vulkan-H) instead of the C++ Vulkan bindings (Vulkan-Hpp) so you're don't have to worry about different API calls. All you have to do is essentially get rid of the C++ features and idioms such as classes and RAII. It doesn't really get too deep into C++ so it's pretty straight forward to strip out and become a pure C implementation. "
That is amazing! I am curious about that "#include " - what's that? I do not seem to have that nor that there's a package named like so.

"This is probably the best you're going to find because C++ is the standard when it comes to game development which is what drives 3D graphics forward the most. Typically you're some weird unicorn when you're using something other than C++ for 3D rendering APIs/Specifications (less so with C but still). So thats why every tutorial and book that you will find on the subject won't cover anything in any other language. You're not expected to use anything else and if you do thats on you as the developer to adapt. "
Yeah, I know that C++ is the standard for GD.. I do not want to go that way; multiple options are always the best.
I'm a weird unicorn? I do not know why, but that sounds like a compliment :/.

"Even the tutorials themselves are never written for beginner programmers because its supposed to be the concepts not the code that you're grasping. Even then most tutorials are very limited since they're supposed to get you off the ground with the API and then you're supposed to go read the docs for everything else."
Yeah right, that's what I wanted anyways - get the most basic window and a triangle, then everything with docs, because that's the best way to learn stuff, and there might be some stackoverflow guys having same problems, who knows :/ (to save time as opposed to "wasting time").

"As far as the Vulkan API being written in C its true because almost every language/platform out there can use C bindings. This is what helps Vulkan shine since its a unified API across all platforms (including mobile) so its less workload for developers to port their project to other platforms."
That's great... if I only knew what you mean by programming language bindings.. oh well - I'll find out soon enough :D. Yeah man I did read that the compatibility is quite large indeed.. I actually wanted something good for GNU+Linux, but compatibility is just a plus. I also heard that Doom Eternal added a patch for vulkan support.. which is weird.. a weird name "patch" for something that is most probably a shit-ton of code and work.. and yeah I did hear that Doom Eternal is veeery well optimized which is cool.. I want to create something that is efficient, too, in a few years :)

Yes, @Sauron, I'm planning for years because I got tired of "searching for the best language to learn", "searching for the best game engine to learn" and just want to learn the good old C, which will help me understand how computers and programming works much better than writing Python code or otherwise. Also learning a graphics API is so much better than learning an game engine - so much freedom for tweaking stuff. I heard that a simple window with a triangle takes ~1000 lines of code, written in C++, for example.. compared to OpenGL, which takes ~100 lines of code for the same function. That level of nerdness is just ... URGH scary. I am scared to learn, but I believe this is the path I want to invest my time and effort in.. I believe it would definitely mean something.


"TL;DR When you get into 3D rendering you're in a C++ world. You're going to have to bite the bullet and learn from the C++ tutorials."
I forgot to answer this lol; at least I'll learn some differences between the two :/
Any channel you can recommend? I found a few, of course - C++, and they seem okay, but I am uncertain if they are/were doing memory management.. as it's something I am interested in - pointers and shit.. I got a grasp what they are and how to access .. or.. better said CYCLE arrays by using pointers and increments.. I know I am a no one, I know that my knowledge is very very small, and I expect to learn something for the next 5 years in C.. I believe it's that "complicated", big. No, I don't want any courses get out of here!!! I'll forget what I "learned" a few days afterwards.. hahaha

I cannot quote people with the built-in function because I almost never enable JavaScript on websites. You won't get notified if I reply to you, sadly :/

Link to comment
Share on other sites

Link to post
Share on other sites

First. Please learn to use quotes. What your doing is hard to follow and doesn't notify the people you are responding to.

 

50 minutes ago, ZFSinmylungs said:

"Then why are you using C?"
What do you mean? I just told you

Actually you didn't. There is nothing in your post as to why you explicitly need "C" and why "C++" isn't a option.

 

3 hours ago, ZFSinmylungs said:

And every.fucking.tutorial.seems.to.be.for.C++. WHY??!?!

Because what I can do in 10 lines of C++ might take 50 in C.

There is very little to gain in going with a lower language than C++ for Game Development and a lot more room for error.

 

50 minutes ago, ZFSinmylungs said:

That is amazing! I am curious about that "#include " - what's that? I do not seem to have that nor that there's a package named like so.

Which include? or do you mean the pre-processor itself '#include'?

 

50 minutes ago, ZFSinmylungs said:

That's great... if I only knew what you mean by programming language bindings.. oh well - I'll find out soon enough :D.

They are basically wrappers that convert data structures from one programming language to another.

 

Link to comment
Share on other sites

Link to post
Share on other sites

@Nayr438
" First. Please learn to use quotes. What your doing is hard to follow and doesn't notify the people you are responding to. "
First. Please learn how to read people's signature section.

" Actually you didn't. There is nothing in your post as to why you explicitly need "C" and why "C++" isn't a option. "
I did - for speed and compatibility reasons. :/

" Because what I can do in 10 lines of C++ might take 50 in C. "
Exactly. I like that.

" There is very little to gain in going with a lower language than C++ for Game Development and a lot more room for error. "
I know. Weeell.. "very little gain" - depends - are you making a 2D game? Are you making a simple application? Then yes - it would be worthless gain. I do not want to do those.

" Which include? or do you mean the pre-processor itself '#include'? "
Weeeeird I swear I wrote it... it either deleted it (when I go to edit my messages sometimes shit disappears from them, like whole pharagraphs and a refresh usually does the trick) or actually schizophrenically forgot to add it..
I meant "#include " line.. I read somewhere afterwards it's something for error handling/logging?

" They are basically wrappers that convert data structures from one programming language to another. "
I see... like google translator? xD

Thank you for your comment.

I cannot quote people with the built-in function because I almost never enable JavaScript on websites. You won't get notified if I reply to you, sadly :/

Link to comment
Share on other sites

Link to post
Share on other sites

13 minutes ago, ZFSinmylungs said:

First. Please learn how to read people's signature section.

I have signatures disabled and there is no reason you can't use the quote feature on the forum.

 

13 minutes ago, ZFSinmylungs said:

I did - for speed and compatibility reasons. 😕

That's not really a valid reason. The speed difference is negligible in most cases and you could actually end up producing slower code. C++ is also just as portable as C, just don't use non standard C++ libraries unless they are compatible with all your targets.

 

13 minutes ago, ZFSinmylungs said:

I know. Weeell.. "very little gain" - depends - are you making a 2D game? Are you making a simple application? Then yes - it would be worthless gain. I do not want to do those.

As a Programmer who uses C and C++, and is currently porting a game engine to Vulkan on Linux, I can strongly disagree with this statement. And in places where C can be beneficial, you can drop down to C code in C++.

 

13 minutes ago, ZFSinmylungs said:

I meant "#include " line.. I read somewhere afterwards it's something for error handling/logging?

I still don't see a file reference so I assume you just mean "#include" which just includes header files to be used within your current source/header file.

Link to comment
Share on other sites

Link to post
Share on other sites

On 8/14/2021 at 8:07 PM, ZFSinmylungs said:

P.S. Why did you guess that I'm a beginner? Is it because I do not know some of differences between C and C++?

You're looking for tutorials, you find translating C++ code to C difficult, you only want to use one specific language as though it were the only one you ever used - this all screams "beginner".

 

Not that there's anything wrong with that but you should have some perspective when trying to learn new things. They don't teach you how to drive with a Ferrari.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

@Sauron
Yeah makes sense now.
I started reading some book about graphics programming, for beginners, and will aside also slowly learn C and some little of C++ so I CAN translate it xD..
I know there's a long way.. but I have always wondered "what can I do with programming using this language? Meh, I give up" or something like that.. or well "give up" more like not learn enough.. but now I know what I want , which is a step closer to getting there - at relief..
This is something I wanted to make for years now - I never rested because of this.. is this regret? It must be.

I cannot quote people with the built-in function because I almost never enable JavaScript on websites. You won't get notified if I reply to you, sadly :/

Link to comment
Share on other sites

Link to post
Share on other sites

Being a reasonably experienced C developer, I opted for diving into C++ with this Vulkan Tutorial (vulkan-tutorial.com).

You will not learn how to code clean C++ code - as basically everything "Object Oriented" is left out. The whole tutorial is C-Style C++ coding with helper functions of modern C++. Yes, you can use a (void*) instead of std::any, but in my opinion it's not worth the hassle. The focus of this tutorial is mainly Vulkan, but with the Swap Chain and everything it's complicated enough 🙂

 

 

On 8/14/2021 at 8:07 PM, ZFSinmylungs said:

About the linear algebra.. does the math library have that or any one you recommend?

I use the linmath.h library (developed by Khronos, LunarG and Valve, Apache license) - works like a charm and is fully compatible with CUDA (in case you need it).

I heavily recommend the cplusplus.com reference - it's well documented and has tons of examples for its different functions.

Link to comment
Share on other sites

Link to post
Share on other sites

That's cool, man.
Yeah - I do feel like I first need to learn more C.
That library is in the AUR.. soo not official, I am biased with trusting AUR packages..
But certainly - thank you for sharing your experience :)
Don't worry, I'll look into that linmath.h library :)

I cannot quote people with the built-in function because I almost never enable JavaScript on websites. You won't get notified if I reply to you, sadly :/

Link to comment
Share on other sites

Link to post
Share on other sites

On 8/14/2021 at 9:02 PM, ZFSinmylungs said:

Okay, so .. before I begin - c++ is NOT AN OPTION!!!! Do not recommend it

Does anyone know where I can find some tutorials for C and Vulkan?
OpenGL is slower than Vulkan.

And every.fucking.tutorial.seems.to.be.for.C++. WHY??!?!
I heard that Vulkan is written in C..

What are my options?! Follow tutorials for C++ and somehow find C alternatives for libraries and code? I am not sure if I can even do that.

Why would I even use an API? - For speed, compatibility and for the sake of not inventing the wheel and spending months on something that would only cause chaos..
I need speed and compatibility if possible.

Can anyone help me out?
Tutorials I have found say that "If you are using C or rust - it is doable".. like the fuck?

you want pain?

 

Vulkan WAS built for C++. Why? Well because directx and OpenGL was using C++. You can very easily adapt to C++, if you have a good background with C. The only major differences between the two is the STL and OOP. 

 

Use the best tool for the job. You wouldn't write a website in CGI, would you?

 

 C is no longer in use, apart from in systems programming because everyone has been using C++ for this stuff since the start of time. C has a lot of stuff missing that is needed to work with a complex graphics API.

 

As for rust, vulkan would have issues with it because the language is too new..

On 8/14/2021 at 9:02 PM, ZFSinmylungs said:

OpenGL is slower than Vulkan.

Really depends. For some things, it may be faster. Much more of the reason why people are switching to Vulkan is because of the missing features. Iiirc, opengl 4.6 is still stuck with phong reflection model. 

 

On 8/15/2021 at 12:41 AM, ZFSinmylungs said:

Exactly. I like that.

Common mistake of beginners. They think that C is actually for real men. Real men know 3-4 languages at the minimum and like to get work done.

 

There are a lot of reasons to avoid C++ like the plague, but if you want to do 3D, you need C++. As much as I would love directx being ported to run with golang, I know it won't happen. You can look for some niche alternatives, but you will probably have to do C++.

Link to comment
Share on other sites

Link to post
Share on other sites

@WolframaticAlpha
" Common mistake of beginners. They think that C is actually for real men. Real men know 3-4 languages at the minimum and like to get work done. "
I know. I know a bit of Python.
If one doesn't start as a boy/girl, they will never become man/woman.

"There are a lot of reasons to avoid C++ like the plague, but if you want to do 3D, you need C++. As much as I would love directx being ported to run with golang, I know it won't happen. You can look for some niche alternatives, but you will probably have to do C++. "

No! >,< yes I know I am being ignorant.. I want to find out about it myself, though. It's not that I do not believe you.. It's just that I'm more curious I guess.
And some consider it an medal or something, like the Rover thing written in C (recent news).

I cannot quote people with the built-in function because I almost never enable JavaScript on websites. You won't get notified if I reply to you, sadly :/

Link to comment
Share on other sites

Link to post
Share on other sites

On 8/19/2021 at 6:01 AM, WolframaticAlpha said:

Vulkan WAS built for C++.

No it wasn't. The Vulkan was built in C for for low level access and adaptability. C++ is more commonly referenced as it's more commonly used by it's target audience.

 

On 8/19/2021 at 6:01 AM, WolframaticAlpha said:

C is no longer in use, apart from in systems programming because everyone has been using C++ for this stuff since the start of time. C has a lot of stuff missing that is needed to work with a complex graphics API.

This is false. C is still widely used everywhere, including Game Development. There is nothing preventing you from writing a game entirely in C, I mean you could even drop down to Assembly if you really wanted.

Just from a development standpoint it doesn't make sense most of the time.

 

On 8/19/2021 at 6:01 AM, WolframaticAlpha said:

As for rust, vulkan would have issues with it because the language is too new..

Once again this is false. Vulkan can be adapted to pretty much any language and Rust is no exception. In fact we have a few Vulkan Rust Wrappers.

 

On 8/19/2021 at 6:01 AM, WolframaticAlpha said:

There are a lot of reasons to avoid C++ like the plague

I would be interested to hear this as my list of reasons to not use C is far longer than my list of reasons to not use C++.

 

On 8/19/2021 at 6:01 AM, WolframaticAlpha said:

As much as I would love directx being ported to run with golang, I know it won't happen. You can look for some niche alternatives, but you will probably have to do C++.

It doesn't need ported to golang... golang just needs to be able to communicate with the DirectX API. So it's not up to Microsoft to make it available, it's up to anyone who is willing to put forth effort to make it happen.

Link to comment
Share on other sites

Link to post
Share on other sites

@Nayr438
Thanks mate.. I do not know how you got notified about the above comment you replied to, but I am glad you did xD I usually like people's comments and at least that notifies them :/

I cannot quote people with the built-in function because I almost never enable JavaScript on websites. You won't get notified if I reply to you, sadly :/

Link to comment
Share on other sites

Link to post
Share on other sites

9 hours ago, Nayr438 said:

Once again this is false. Vulkan can be adapted to pretty much any language and Rust is no exception. In fact we have a few Vulkan Rust Wrappers.

Tell me about the number of vulkan rust wrappers that are in use professionally?

9 hours ago, Nayr438 said:

No it wasn't. The Vulkan was built in C for for low level access and adaptability. C++ is more commonly referenced as it's more commonly used by it's target audience.

There is a huge difference between being built IN one language and using with one language.

9 hours ago, Nayr438 said:

This is false. C is still widely used everywhere, including Game Development.

Sure, you can write a game in C. You can also write a game in java. One in Javascript. One in brainfuck too. But C++ is the premier language for game developement and 3D. If you want max. compatibility with someone else's library, then you would want to use C++. 

9 hours ago, Nayr438 said:

I would be interested to hear this as my list of reasons to not use C is far longer than my list of reasons to not use C++.

I said that C++ is hated by some. Just because I hate C++, doesn't mean I can hate C too. :)

9 hours ago, Nayr438 said:

golang just needs to be able to communicate with the DirectX API. So it's not up to Microsoft to make it available, it's up to anyone who is willing to put forth effort to make it happen.

DX translation layers are notorious for being hard to write. Using a wrapper seems like the only good way to go with it. But you know what the problem with wrappers is. You are now maintaining two codebases, or are dependent on an under-developement project. It becomes significantly more difficult to debug and catch errors if you are using an under-developement wrapper. To my knowledge, there are no fully developed wrappers for golang and dx.

 

Everything that you stated was correct, but I assumed that OP wanted to use these languages to create a real project w/ vulkan, so it becomes difficult to just use C. C++ is a massive productivity enhancer for these APIs

9 hours ago, ZFSinmylungs said:

No! >,< yes I know I am being ignorant.. I want to find out about it myself, though. It's not that I do not believe you.. It's just that I'm more curious I guess.
And some consider it an medal or something, like the Rover thing written in C (recent news).

Ah OK. Now I get it. I thought that you wanted to do really large and serious 3D projects w/ vulkan. If you want a challenge in C, then I suggest that you try writing a simple UNIX-like OS for a microcontroller board. It will be extremely fun!

Link to comment
Share on other sites

Link to post
Share on other sites

@WolframaticAlpha
"Ah OK. Now I get it. I thought that you wanted to do really large and serious 3D projects w/ vulkan. If you want a challenge in C, then I suggest that you try writing a simple UNIX-like OS for a microcontroller board. It will be extremely fun! "
Fuck
Yes I know it'd be fun.. but that earlier sentence is quite provoking :d

I cannot quote people with the built-in function because I almost never enable JavaScript on websites. You won't get notified if I reply to you, sadly :/

Link to comment
Share on other sites

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

×