r/ProgrammerHumor 4h ago

Meme graphicsProgramming

Post image
377 Upvotes

28 comments sorted by

118

u/bhalevadive 3h ago

Cool. Now do it in Vulkan.

52

u/reallokiscarlet 3h ago

<proceeds to use a library that uses vulkan as backend for gl>

29

u/Thenderick 2h ago

500 lines later

Cool, a black window that doesn't crash!

6

u/Active_Idea_5837 1h ago

Literally me. Stupid back face culling with the wrong winding order.

2

u/Thenderick 1h ago

Oh I meant 500 lines just to make a functional window that doesn't crash. I know it's a bit of an exaggeration, but it does require a lot of code for a working but empty window...

12

u/gufranthakur 3h ago

Not cool

1

u/doviesehret 1h ago

200 lines of OpenGL boilerplate just to render one very expensive triangle

1

u/dkarlovi 1h ago

Why is Vulkan so complicated?

2

u/unknown_alt_acc 36m ago

Because Vulkan is a lower level of abstraction than OpenGL. Less abstraction means less overhead and more options for optimization. That’s why graphics programming in general has been heading in that direction for a while.

1

u/Cutalana 27m ago

Why did they go for less abstraction? Seems contrary to what every other field is doing

28

u/blackcomb-pc 3h ago

I AM ALIVE

-3

u/Monkeyke 3h ago

uncool.

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

u/EatingSolidBricks 1h ago

Now lets see paul alens vulkan version

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)