Live data from Hacker News

Olive.c: a simple graphics library that does not have any dependencies

tsoding.org

71–80 of 96 posts

Re: Olive.c: a simple graphics library that does not have any dependencies

#72

The combination of mapping pixels to memory and rendering individually and then that appearing on webgl and looking great on a not too expensive phone, where I am pinch zooming while it flawlessly animates, sort of blows my mind in how much technology has come in 25 years. Connects the old with the new in a way I haven’t seen for a while (and yeah seen loads of C64 emulators and such)

those are canvas with 2d context, not webgl

Re: Olive.c: a simple graphics library that does not have any dependencies

#73
post #70

It's cool that you can get away with software rendering these days, but it's a shame to not make use of the power of the GPU.

That's the point. Also, not all devices have dedicated graphics hardware

Only embedded systems and servers lack it these days. Server-side rendering is an interesting use-case, I guess.

Re: Olive.c: a simple graphics library that does not have any dependencies

#75
post #21

Nice to see tsoding on the top of HN, this guy does amazing streams and youtube video

Dude is insanely talented and patient enough to learn new stuff, it's always a pleasure to watch the videos even though they're usually really long.

Re: Olive.c: a simple graphics library that does not have any dependencies

#76

Earlier quoted context omitted.

Sorry, why does it make the project feel like a toy? I'm not trying to argue, I just don't understand. Is it because you're including a source file instead of a header file?

single-file libraries almost always feel like toys because most serious projects i'd want them integrated into a real build system. vcpkg is a good one these days for c/cpp. nothing wrong with a toy library ofc.

sqlite has amalgamated source too. It's used EVERYWHERE. This opinion doesn't seem like it's based on anything valid or real.

Note you get some opportunities for better compiler optimizations when the entire compilation unit is the entire project. In fact, sqlite claims the code runs 5-10% faster when built as an amalgamation (https://www.sqlite.org/amalgamation.html)

Re: Olive.c: a simple graphics library that does not have any dependencies

#77
post #70

It's cool that you can get away with software rendering these days, but it's a shame to not make use of the power of the GPU.

That's the point. Also, not all devices have dedicated graphics hardware

And even if they do, if they're portable please think of my battery :)

Re: Olive.c: a simple graphics library that does not have any dependencies

#78
post #9
post #7

Earlier quoted context omitted.

The function declarations and definitions are all commingled in a single file. So if you want to use this library in a project that contains multiple source files, you have to include a duplicate copy of the implementation (including e.g. the static font data) in every single compilation unit. It's possible that your linker would be smart enough to identify and remove the duplicates, but it's still inelegant, unidiom…

gcc or clang would crash on the linking step complaining about duplicate symbols. This library is only good for a project that is built in a single .c file.

False.

Re: Olive.c: a simple graphics library that does not have any dependencies

#79
post #42
post #40

Earlier quoted context omitted.

Sure, but only if the text file looks like a C string literal, i.e. starts and ends with double quotes (which would make it into a weird text file). Doing const char *s = " #inclued "test.txt" "; won't work, since the preprocessor won't interpret directives inside string literals of course. In many assemblers, there is a directive called "incbin" which pastes in unstructured binary data at the point of usage. I just…

Note that C23 will include a variant of incbin spelled #embed : Semantically, the preprocessor will insert a list of integers which you can use to initialize an array.

Also, for clarity, it is fully expected that the compiler will use the as-if rule to optimize it. Most likely by having a dedicated token/ast node that only decomposes to comma separated values if if actually needs to, with common usage in initalizers being handled by simply copying the data directly into a static data segment without ever creating an integer list at all.
Post reply on HN