Live data from Hacker News

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

tsoding.org

41–50 of 96 posts

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

#42
post #40
post #30

Earlier quoted context omitted.

Just wait till you find out that you can do: const char *s = #include "test.txt" ;

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.

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

#43
post #40
post #30

Earlier quoted context omitted.

Just wait till you find out that you can do: const char *s = #include "test.txt" ;

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…

An incbin-like facility is coming to the standard: https://thephd.dev/finally-embed-in-c23

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

#44
post #5

Earlier quoted context omitted.

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.

Unfortunately only portable to systems with fast CPUs though. Although I guess rendering simple 3d shapes probably runs just fine on low end hardware.

Uh, right? The demo page renders fine on this decade old core i5-3337u, with all the vulnerabilities patched.

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

#45
post #43
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…

An incbin-like facility is coming to the standard: https://thephd.dev/finally-embed-in-c23

Yeah, I actually had heard about that but it didn't show up in my first search. Thanks!

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

#46
post #40
post #30

Earlier quoted context omitted.

Just wait till you find out that you can do: const char *s = #include "test.txt" ;

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…

Yeah, ignoring incbin hackery, a better example than strings might be

  float vertices[] = {
  #include "stuff.txt"
  };

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

#50

Earlier quoted context omitted.

How can I find them?

Using the search field on youtube is probably easiest.

Gee thanks. I tried typing olive.c there. That didn't help. The string "tsoding" is the magic I needed.
Post reply on HN