DEV Community

Beau
Beau

Posted on • Updated on

Nyx: A Graphics Library for C++

Ugh, how many of these do we need?

I'm tired of using the same old graphics libraries in C++. I want something simple, something as easy to use as LÖVE or Pyglet. I could use these in their respective languages but I quite honestly just like the speed of C++. Also, modern C++ isn't nearly as painful to use as I think some of us may have learned in school (aka doing C with classes).

A lot of the existing libraries that are out there aren't really C++ at all, but simply C. These are fine if you're coding in C, but they tend to be unnatural and clunky when it comes to C++. A good example would be SDL2: totally functional, but dated naming conventions and a less than stellar build process (I just want CMake support!).

Some of those libraries are also pretty feature incomplete, in my opinion. Ragging on SDL2 again, why are basic primitives not really a thing it supports? To be fair, primitives are mostly used in the early stages of the development process, not in a final product, but why not have them available anyway? It doesn't make much sense to me. Yes, you can use SDL2_gfx, but I feel like it should be something the base library has included.

That's why I've decided to start my own graphics library instead, taking advantage of everything I can to make it a one-stop-shop for your graphics (and some game development) needs.

Okay but like have you considered X?

Probably! I've tried out many different things over the years, none of them come even close to the simplicity of libraries you find in higher level languages. I don't see why they can't, and I'm tired of waiting for someone to make it for me. Plus, this is just a great project to put on my resume given that I do have an actual interest in engine development as a career.

That said, I haven't tried everything, if you really would like me to check out some other library, I'll probably at least take a cursory glance at its git repo.

Introducing: Nyx

Nyx is the name of a graphics library that I'm currently developing. There isn't any particular inspiration behind the name, it's just really short, which makes it nice for a namespace, and mythology is cool.

For now, it's in a private repo until I think it's at least useable for something. As of now, it's quite literally useless as it basically just opens a screen and can draw an FPS counter and memory usage indicator on the top. This isn't nothing, and there's actually quite a bit of code to handle some events and everything as well, but I'll make another post for those.

This is actually a rewrite of a project I had been working on for a while--that's why there's that seemingly random functionality in there already, it's just copied over. I have a scrapped project called Aurora that had the exact same goal, but I hit a wall when I realized I had structured it pretty poorly. The way the library was set up, certain things were hard to access, or all had to go through a central object I called "Engine". This was all well and good but added a lot of unnecessary noise to the code. Then, I remembered how LÖVE does it. I'll discuss what happened there in the next article.

Anyway, this was just a quick intro post. I'm hoping to document the process as I go along, don't expect 100% consistency with me writing these, but it shouldn't be terribly slow either. I tend to try and get a little something done on it every day, though I likely won't write an article every day, that feels a bit excessive. If somehow this gets popular, I'll consider doing live coding streams, that's always seemed like a fun idea to me, though I'm not sure how exciting it would be to watch me do it. :)

Top comments (1)

Collapse
 
dynamicsquid profile image
DynamicSquid

:(

"nyx" was the name I was going to chose for my package manager!

But I haven't made it yet so I guess I'll have to chose another name :)