Projects
BPR RendererIt's a 3D renderer I built to dive deeper into graphics programming, using as reference the great LearnOpenGL tutorial and Google's Filament. The renderer implements Physically Based Rendering (PBR), a technique that simulates light and shadows to closely mimic real-world behavior. It supports shadow mapping, Image-Based Lighting (IBL), and can load meshes from external files. |
MicroTCP
MicroTCP is a user-space network stack I developed to better understand TCP and lower-level protocols like IP, ICMP, and ARP. It provides two interfaces: a blocking, BSD socket-like interface and a non-blocking, epoll-like interface for handling multiple connections efficiently. I tested it by porting xHTTP to it, an HTTP/1.1 implementation I wrote previously. You can also check out a discussion about it on Hacker News.
Noja
This is the first "serious" project I worked on. It's an interpreter for a high level language I designed from scratch. It taught me how to manage non-trivial codebases and how important it is to keep complexity low. The language supports features like multiple return values, default argument values, and closures. It was a great learning experience and helped me understand interpreters deeply. You can find various examples in the examples/ folder of the GitHub repository, including an HTTP server I ported to the language.
1 | fun loadFile(path: String) { |
2 | |
3 | # Log the path |
4 | print("path=", path, "\n"); |
5 | |
6 | # Open the file |
7 | stream, error = files.openFile(path, files.READ); |
8 | if error != none: |
9 | return none, error; |
10 | |
11 | # Copy its contents to a dinamically growing buffer |
12 | text = ""; |
13 | size = 512; |
14 | do { |
15 | size = 2 * size; |
16 | data = buffer.new(size); |
17 | |
18 | num_bytes, error = files.read(stream, data); |
19 | if error != none: |
20 | return none, error; |
21 | |
22 | text = string.cat(text, buffer.toString(data)); |
23 | |
24 | } while num_bytes == size; |
25 | |
26 | # Close the file handle |
27 | files.close(stream); |
28 | |
29 | # Return the file contents to the caller |
30 | return text; |
31 | } |
xHTTP
This was my first attempt at writing an HTTP server, and pretty much got me into network programming. It's an HTTP/1.1 server for Linux designed to be extremely lightweight and fast. It leverages all of the cool Linux-specific system calls like sendfile and epoll. These days I'm more interested in cross-platform code and non-blocking interfaces, so I would change the interface a bit.
Here's how an application using xHTTP looks like:
1 | #include <string.h> |
2 | #include "xhttp.h" |
3 | |
4 | static void callback(xh_request *req, xh_response *res, void *userp) |
5 | { |
6 | res->status = 200; |
7 | if(!strcmp(req->URL.str, "/file")) |
8 | res->file = "index.html"; // Send a static file |
9 | else |
10 | res->body.str = "Hello, world!"; // Send a string |
11 | xh_header_add(res, "Content-Type", "text/plain"); |
12 | } |
13 | |
14 | int main() |
15 | { |
16 | xhttp(NULL, 8080, callback, NULL, NULL, NULL); |
17 | return 0; |
18 | } |
Minor stuff
c2html |
Tool to add HTML syntax highlighting to C code snippets |
TinyTemplate |
Templating engine in C |
Buddy Allocator |
General-purpose allocator for memory constrained environments |
TinyIO |
Cross-platform interface for the various OS-specific event loop APIs (I/O completion ports on Windows and io_uring on Linux) |
gap_buffer.c |
Gap buffer implementation, a data structure used in text editors |