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!

8 opmerkingen:

  1. Sounds interesting. I currently use OpenTK for my (basic) game engine but oddly enough it's game runner has been annoying me too... shall keep an eye out on this!

    Incidently, the URL in the post goes to a 404, I guess you renamed the repo to Pencil.Gaming-GLFW2?

    Regards;
    Richard Moss

    BeantwoordenVerwijderen
    Reacties
    1. Yes, I'm sorry about that, I fixed the link. I'm very glad you're interested!

      Verwijderen
  2. Just trying and all runing smoothly.
    Nice work!

    BeantwoordenVerwijderen
  3. Awesome work man. I really like the simplicity and clean interface. Would a glfw3-wip wrapper be on the roadmap as well? I'm currently checking out glfw3 and making a toggle for borders/fullscreen windows. I'll be stalking your project...

    BeantwoordenVerwijderen
    Reacties
    1. Guess why the project is called Pencil.Gaming-GLFW2? You can expect Pencil.Gaming-GLFW3 as soon as I figure out how cmake works...

      Thank you for your feedback, I'm glad you like the project!

      Verwijderen
  4. antonijn,


    I've tested GLFW2(32/64 bits WORKS) and GLFW3(only 32bit WORKS).
    It seems like the WINDOWS DLLs included in both 32/64bit folders are all 32bits...thus the 64bit run does not work (complains of BAD IMAGE FORMAT for the loaded binary dll). Great work btw, I can't wait for the 64bit to become stable and working) :)

    Peter

    BeantwoordenVerwijderen
    Reacties
    1. As I said, I'm not very good with CMake, and I'm kind of having trouble building GLFW 3. Also, I presume you are on Windows, as on Linux, GLFW3x64 definitely does work.

      I'm sorry, I will try to reinstall MinGW and try CMake again, hopefully it will be more successful than my previous attempt.

      Verwijderen
    2. I just implemented GLFW 3.0.1 for windows, which came out a couple of days ago. I haven't checked if it works, but it should.

      Verwijderen