Earlier quoted context omitted.
It looks like olive.c is a "single header" library. They chose a .c suffix rather than .h. If OLIVE_IMPLEMENTATION is defined before including "olive.c", then the full implementation is produced. Otherwise, just declarations, so that it behaves like a header file. It's a valid technique. If you have a library all in one source file, the requirement to have a separate .h doubles your file count. One small reason to ha…
This feels far messier to me than just having a .h file.
Olive.c: a simple graphics library that does not have any dependencies
31–40 of 96 posts
Re: Olive.c: a simple graphics library that does not have any dependencies
#32It pains me to see #include at the top of the file. It makes the project feel like a toy.
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?
Re: Olive.c: a simple graphics library that does not have any dependencies
#33Nice to see tsoding on the top of HN, this guy does amazing streams and youtube video
Re: Olive.c: a simple graphics library that does not have any dependencies
#34Any plans for text rendering?
Re: Olive.c: a simple graphics library that does not have any dependencies
#35Earlier 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.
Re: Olive.c: a simple graphics library that does not have any dependencies
#36Does this use WebGL2? It doesn't run on my phone (which does support WebGL 1). Edit: According to the JS source file it appears to be a plain 2D canvas. Now I am even more confused, those should definitely load! https://github.com/tsoding/olive.c/blob/master/js/vc.js
Re: Olive.c: a simple graphics library that does not have any dependencies
#37Re: Olive.c: a simple graphics library that does not have any dependencies
#38Earlier quoted context omitted.
This feels far messier to me than just having a .h file.
Sure, but let's look at the larger picture. If you have one file, then that's your deliverable. You can host that file somewhere, send it as an e-mail body, drop it into a paste-bin or whatever. It is one self-contained unit. If you have two files: .h and .c, the use scenario may be simpler. Not a lot though. And now youu have two files which have to stay together somehow, yet remain distinct. If you combine them in…
Re: Olive.c: a simple graphics library that does not have any dependencies
#39Cool project! What’s the motivation? Since it eschews any graphics API, is it safe to assume this only does CPU-based rendering?
From demos/triangle.c ( https://github.com/tsoding/olive.c/blob/master/demos/triangl... ) // This idea is that you can take this code and compile it to different platforms with different rendering machanisms: // native with SDL, WebAssembly with HTML5 canvas, etc. The goal seems to be to maximize portability.
Re: Olive.c: a simple graphics library that does not have any dependencies
#40It pains me to see #include at the top of the file. It makes the project feel like a toy.
Just wait till you find out that you can do: const char *s = #include "test.txt" ;
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 found a very clever C and C++ wrapper [1] for that, which gives you an INCBIN() macro. Nice!