Monday, 20 April 2015

Native Cross-platform Drawing Window


Many times I find myself duplicating the same low-level window creation code snippets at the start of creating a standalone desktop graphical application, and too often have I had to look up platform specific API calls to do simple drawing operations. There has to be a better way!

So I gave in, and put together a light-weight graphical API that handles essential drawing operations (ie, draw lines, bitmaps, texts),  as well as encapsulates mouse and keyboard events in a simple cross-platform package.

On Windows, the drawing operations are piped to GDI calls, while on Unix, Linux, and Mac, they are directed to X11 calls. Bitmap transparencies are handled with bit-masking and bit-blitting operations to ensure everything runs quick and snappy. Double buffering is also handled internally so that a user can draw with flicker free goodness out of the box.

Full source code and demo (Breakout!) can be found on GitHub: