218 results for "":
Next power of two
While looking to write a pure ooc version of ftgl, I was reading the source of ftgl-gl3 and I stumbled upon this piece of code:
static inline GLuint NextPowerOf2(GLuint in)
{
in -= 1;
in |= in >> 16;
in |= in >> 8;
in |= in >> 4;
in |= in >> 2;
in |= in >> 1;
return in + 1;
}
This is needed because dealing with power-of-two textures (32x32, 64x64, 128x128, etc.) is more efficient with OpenGL (some implementations don’t even support non-power-of-two textures!).
Having fun with ooc
Unfortunately, the ooc language could have better documentation. In the meantime, I’d like to blog about about some features that might not be very well-known.
Nested functions
Here’s a program that prints 1, 3, 5, 7, 9:
import structs/ArrayList
main: func {
list := ArrayList<Int> new()
addIfOdd := func (i: Int) {
if (i % 2 != 0) list add(i)
}
for (i in 0..10) {
addIfOdd(i)
}
list map(|i| i toString()) join(", ") println()
}
Cut for time
This series has to end somewhere, so let’s end it here!
However, here is a list of some things I’d like to come back to:
Bundling & TypeScript
Using a bundler like Parcel so I can write some of the client-side logic in TypeScript, have it take care of building the SCSS, etc.
I do that to great effect in another project of mine and I’d like to show you how I did it!
Happy stay with us day
I didn’t really know what to do for “World Suicide Prevention Day 2014”.
First off, I didn’t know it existed at all. Like, c’mon, know your audience, if you have a party like that, I want in!
Second, it’s a terrible name: I hereby propose “stay with us day” in place. Nevermind the “world” part because, hey, we’re on the internet, the “suicide” part because, well, avoiding that is just the very start of a long uphill battle, and let’s keep the “day” part because, honest, if we can attract people’s attention for even a single day per year, it’ll be nothing short of a miracle.
Working with strings in Rust
There’s a question that always comes up when people pick up the
Rust programming language: why are there two
string types? Why is there String, and &str?
My Declarative Memory Management article answers the question partially, but there is a lot more to say about it, so let’s run a few experiments and see if we can conjure up a thorough defense of Rust’s approach over, say, C’s.
Async fn in trait... not
Async fn in trait… not
I was planning on showing the in-progress async_fn_in_trait feature in the
context of my website, but it turns out, I can’t!
My website uses two databases: one local SQLite database for content, and a shared Postgres database for user credentials, preferences etc. Migrations are run on startup, and each migration implements one of the following traits:
Fast font packing for fun and profit
Being creative is hard work, let’s go optimizing instead! My graphics engine dye was pretty naive about displaying text, and it was wasteful. Let’s see how I made it all better with this one weird tip.
Disclaimer: Even after a few years I’m still very much an OpenGL newbie. Please don’t hit me with crowbars.
Once upon a time, OpenGL was easy to use - and also falling out of relevancy as far as high-performance 3D graphics were concerned. But it wasn’t all bad! You could basically pick up any library out there and integrate it with your existing GL project. Not that it’s a good idea, but it usually just worked.
Building a Rust service with Nix
That health is mental
Disclaimer:
Trigger warning: depression, talk of suicide.
It’s been a while since I wrote a mental health piece — but I think it’s important to occasionally stop, take a breather, and think about how we feel.
So.
deep breath
I’m okay, I think? Just a little restless.
A bit of personal context
For those keeping score, I went through major life events in 2023 — a divorce, a move, and the news that I might need a second round of jaw surgery.
Introducing facet: Reflection for Rust
I have long been at war against Rust compile times.
Part of the solution for me was to buy my way into Apple Silicon dreamland, where builds are, like… faster. I remember every time I SSH into an x86_64 server, even the nice 64-core ones.
And another part was, of course, to get dirty with Rust itself.
I wrote Why is my Rust build so slow?, which goes in-depth into rust build performance, down to rustc self-profiling even!