The Ocasional Tech Blog

Bifrost - An Event Driven Asset Database

Building a game engine can be an hard endeavour but many tools and libraries exist out there to aid your engine's development.

Despite asset management being a core functionality in any engine and more broadly, any tool, I have had an hard time finding a library that could handle this domain in my tools.

So I built one.

Bifrost

Bifrost is an open source, MIT Licensed, Event Driven Asset Database for games, engines and tools.

Throughout this post I'll be exploring the reasoning behind the design decisions made during the development of the library.

What is an Asset Database?

An asset database's primary job is, given some handle, returning information about the asset that handle points to.

Additionally bifrost provides an Event Driven API allowing client applications to register Event Handlers for common file system events. This way a client application can respond to events as they happen, refreshing UIs, Reimporting assets or running custom queries on the database.

Language and Dependencies

Bifrost is built in C99 using only a couple libraries:

Raylib is also used to build a small example application.

C99 was chosen due to the ubiquity of C ABI in most languages which will be extremely useful in the future when developing bindings for other languages such as Odin, Zig, Rust and Beef.

Conclusion

The File System

It turns out, developing a library or application to be cross platform can be an uphill battle when dealing with the file system.

Every operating system has its nuonces when dealing with the file system and it can lead to some headaches.

I attempted to skirt around these particularities by using libuv and, even then, I had to deal with a couple issues mainly revolving around libuv's lack of recursive filesystem watching support on linux.

Single responsability

Bifrost was originally planned to include an entire asset import and packing module but I made the decision to cut it from the final version as it added a lot of complexity and assumptions about the client application's design. I might end up building another library for this purpose later on.

Improvements and next steps

I am always striving towards being better, while bifrost does currently work as I envisioned it, there are aspects of it I can improve such as:

Additionally I'm looking towards the next steps after v1.0.0 release these include:

Closing Words

This project has been a fun one to work on

It started as just me extracting my asset database and pipeline from my C++ engine so I could reuse them. Then I figured others might be interested in using it as well.

I made the decision to rewrite from C++ to C99 for broader language support through bindings.

And now I've released it as my first real open source project. I look forward to receive feedback and make improvements to the library as I move towards a v1.0.0 release.