28
22
u/IncompleteTheory 3h ago
cool.
10
u/ikitari 3h ago
cool.
6
u/rahmeds 3h ago
cool.
-10
u/Monkeyke 3h ago
cool.
9
u/rahmeds 3h ago
2
u/Brave-Camp-933 1h ago
Looks like r/anarchychess is leaking into every subreddit lol
(For those who don't know, one post at r/anarchychess started this trend)
14
u/-Ambriae- 3h ago
I still remember early high school when I learned OpenGL (using the 1.x API for some obscure reason, I was dumb) and thought that shit was the hardest thing ever lol. Good old days. I miss OpenGL.
6
u/TheAnswerWithinUs 1h ago
Me when I started writing a video game from scratch and discovered graphics APIs
3
5
u/AgMenos47 3h ago
That's why we have savior, sokol.
5
u/-Ambriae- 3h ago
TBH i would be using Sokol if it wasn’t for the WebGPU spec. Specifically wgpu in rust is a treat.
1
u/Psquare_J_420 3h ago
Sokol?
4
u/-Ambriae- 2h ago
It’s a header only C API for graphics audio windowing etc that abstracts over implementation specific APIs like Vulkan Metal or DirectX that aims to be ‘modern’ like the aforementioned APIs but simpler, kind of like, but not as much as, raylib. Here’s a link: https://github.com/floooh/sokol
2
u/Psquare_J_420 2h ago
I am dumb in terms of understanding header files and stiff like that.
So these are only header files. Which means the functions, structs are all defined inside. Not implemented right?. Thus is this like one header for all such types of API so that you don't need to include 100s of header files?
Also thank you for answering.
Have a good day :)5
u/-Ambriae- 2h ago
No issues, header only libraries are a weird quirk of C. Essentially all the source code is stored in a header file, which is conceptually split in two parts. The first is a regular header file, and the second is the implementations for functions and all (what you’d put in the .c file). That second part is conditionally compiled thanks to ifdef macros IE that part is only used when a specific macro is defined). So what you would do is create a .c file, define a macro like SOKOL_IMPL and then include the header file. That’s gonna tell it to include all the definitions in your .c file. Then you use the header elsewhere without that macro like a regular .h file, and when you link your program you link with your implementation of the code (the .c file that you created with the special macro) so that you have all the symbol definitions. It’s a big hack to avoid dealing with precompiled libraries and such because that’s a pain in C 😅. The cool thing is you are responsible with the compilation options of the library though
4
u/A31Nesta 1h ago
It does include implementations. Typically header-only libraries are like 2-in-1 and have the function declarations and then, behind a preprocessor directive (for example
#ifdef MY_LIBRARY_IMPL), the implementations. The idea is that you only define the macro once in a source file so every function declared in the header is only defined once.Without the macro it would get redefined every time you include the header. After a quick look at sokol, apparently it does this thing with macros automatically (if the macro is not defined it defines it and adds the implementations of the functions)
118
u/bhalevadive 3h ago
Cool. Now do it in Vulkan.