I few years back, I began developing a new framework called XPG. It stood for “cross-platform gaming” (meant to target Windows, OSX, and Linux). It was spurred on by several events.
First, I really wanted to begin using OpenGL 3. SDL 1.2 only supported OpenGL 2.1, and I still do not trust SDL 1.3. I tinkered with other frameworks out there (such as GLFW), but it was really about this time that I became genuinely interested in the low level details. I wanted to learn how to make an OpenGL context myself.
Second, I was tired of C frameworks. I appreciate that people just want to maximize the reach of their APIs, and it matches the fact that OpenGL is in C. Heck, I’ve even built a library in C for the same reasons, but I reached a point where I was tired of wrapping all that behavior in C++ over and over. I always do game development in C++, so I wanted to make a framework custom built for my needs, not someone else’s.
I made a lot of progress on XPG. I managed to create OpenGL windows in Windows, OSX, and Linux. I learned how to catch keyboard/mouse events. It was a very satisfying experience, but I eventually ran into walls. One day, my Windows build stopped working (just displayed a blank window). Not long after, my OSX build stopped working (same blank window). I really had no idea how to debug any of these things. I finally put the project on indefinite hold out of frustration.
Looking back, I see that I should not have jumped straight to building OpenGL windows. I missed a lot of important details. So, this past weekend, I had some quality time with the Win32 API. I put OSX and Linux out of my mind and just played with Windows itself. I banned myself from OpenGL for much of the exercise. I focused strictly on working the event loop and altering window behavior. I separated in my mind what a window class is, what a window instance is, what a device context is, etc. I learned to really control these aspects. I created a recurring timer. I posted a message to the message queue from another thread (‘message’ == Win32 event).
Ironically, adding the OpenGL from there was the easiest thing I’ve ever done. I was able to create a GL 2.1 context and a GL 3.3 context. My code was much more organized this time around too. I plan on revisiting XPG and deploying these improvements soon. Shortly thereafter, I plan on having these zen sessions with X11 and Cocoa. No XPG. No OpenGL. I will make an OS-specific window and mess with it. (Frankly, I’m surprised I ever got a window working my first time hacking it together those years ago.)
I have also learned OpenAL since my first attempt at coding XPG. I always knew I’d be adding OpenAL support eventually, but I struggled to learn OpenAL for a long time. Now, OpenAL and I are buds. I manage my own context, load my own audio files, and play the sounds.
I’ll post more about XPG soon.