donderdag 28 februari 2013

Pencil.Gaming - Because everything else is shit

That is a horrible title for a first blog post, so let me introduce myself properly first.

My name's Antonie (internet name: antonijn or antonijnb), and I'm a dutch programmer/game developer. I started my programming life with a language you might have heard of; it's called HTML. I stayed in the world of web-development for a couple of years, but decided I wanted to switch to application development, so I learned a language, you might have heard of it, it's called C++. After that I thought it might be cool to learn another language, so I learned C#, because that was also provided by MSVS. After that I learned Java, C, Assembly and Lua, but currently I do most of my programming in C# and C++ (mostly C#).

I wanted (and still want) to make games, just for the sake of making 'em, but I soon ran into a problem. Every gaming library for C# is shit. Let's examine the options:
  • Microsoft XNA
  • OpenTK
  • SharpDX
There might be some others, but these are the largest ones that I'm aware of.

Microsoft XNA is the framework I learned first, and I've used it quite a bit. At first glance it's a great framework; it provides solid support for graphics (both for easy 2D applications and the more advanced 3D stuff), audio and input, and is very extensive.

So why is it shit? First of all it requires the user to install a very large redistributable package, which is something I want to avoid (this was the main reason I switched to OpenTK). Secondly, it's designed as a framework relying on DirectX, and is therefore not designed to be cross-platform. Of course you have MonoGame, but that just doesn't "feel" as solid as the Microsoft implementation, and using "Microsoft.Xna.Framwork" classes for Linux and Mac, seems cheat-y to me.

Then there's the second library I tried (you can't really call it a framework): OpenTK. OpenTK is great in many different aspects, but is, just like XNA, flawed in two vital places. OpenTK fixes the cross-platform problem with XNA, meaning it allows you to write applications for Linux (my current OS, so this is a must) and Mac OS. It does require you to install the OpenAL redistributable package, but you can work around this fairly easily, although you do have to give up 64-bit support for it.

However, it doesn't feel as solid a library as XNA, mainly because it isn't. Some of the implementations just don't work for Linux and OS X. I had an issue with my ludum dare entry, where someone on OS X couldn't play the game because OpenTK didn't register keyboard input properly.

A more recent downside of OpenTK, is it's update frequency. OpenTK used to be very frequently updated, but the main developer (the_fiddler) mysteriously vanished somewhere last year, and as a result, OpenTK hasn't been updated in almost a year.

Then there's SharpDX. This one's easy. Not cross platform; bye bye SharpDX. I've worked with Direct3D in C++ a little, but never really looked into it seriously. OpenGL is the future.


So everything is shit at the moment. There are two possible solutions:
  • Choose a different programming language (Java, wink, wink)
  • Write something yourself (what Linus would do)
Well, I didn't choose the first one, since I just love C# too much, I don't care whether free-software fundamentalists will shout at me for it. I chose to write something myself, and I finally started it last weekend.

I have the ideas of what I want it to be. I want it to be:
  • Rock solid
  • Cross-platform
  • Small
  • Familiar to C++/C developers
So I just want to wrap a couple of C libraries, maximizing cross-platform capabilities.

This is also an aspect of OpenTK that makes it so shit: it tries to implement it's own windowing system. It's shit. It works great for windows, but if you try to do anything with your window other than opening it, you're guaranteed to blow your program up, or blow yourself up out of frustration.

The library will be called Pencil.Gaming (long story, I'll explain later), and will wrap the following libraries:
  • OpenGL
  • OpenAL
  • Glfw
And it will have some utilities that I'll implement myself. Not a lot of them, but enough to make your life bearable.

It will work, and in fact already works, for x86 and x86-64 versions of both Windows and Linux (I don't think it will work flawlessly on Max OS X, I haven't had the opportunity to test it yet), and will feature strongly types enums, like OpenTK does.

I've simply copy-pasted the GL class from OpenTK, and changed it around a bit to match my way of OpenGL function loading (I'm using glfwGetProcAddress instead of OS-specific functions), but have implemented GLFW and OpenAL support myself.

There's no need to install any redistributable packages as far as I'm aware, and you should currently be able to create some pretty advanced games with it, although sound will only work on Linux as far as I know.


So if you're interested, here is the source. The binaries can be found there too. It's way too early for testing yet, and you can't even call it alpha at this stage in development, but it's there, and it kind of works.

The github repo also has a wiki page, where you can find some more info about GLFW. The standard README.md also provides some sample applications.

Expect more updates on it soon!