home

Tutorial index

Win32Api/GDI: Why this?

            Use of the Windows GDI is discouraged by Microsoft as other libraries and tools appear and are supported as easier and more agile, but in the same way we learn assembly in computer engineering departments all over the world, I believe that knowledge of the GDI provides an insight into the foundations of Windows graphics. Furthermore, I ended up studying the GDI due to the fact that setting up most of the other graphics mechanisms turned out to be confusing, too complicated for what I needed, or not professionally used.

For example, DirectX needs several pages of setup and twenty times those pages in tutorials before one can render a single triangle, and getting any leads to Direct2D is rather hard. Thus for rendering basic 2D graphics I consider DirectX a bit too in-direct (pun intended) and the code that is actually describing graphics would be less than a tenth of the entire DirectX code we would use for these tutorials.

OpenGL is slightly confusing to set up, actually I wasted multiple hours trying to find the graphics libraries, and though I found it’s code more to the point, this confusion is discouraging. One may argue that OpenGL does have professional uses, i.e. there are many applications and games using it that are commercially available, but if I expand into more commercially applicable libraries, it will be either into the XNA framework (which I am currently studying) or DirectX, as it seems to have an uppe hand in the industry as well as the support of Microsoft.

Allegro is another graphics library which one will clearly come across more than the others while browsing books on gaming graphics. The problem with Allegro is that it supports little 3D rendering while it has an all-too-easy set of 2D functions that will clearly not help introduce you to more serious developing tools. Furthermore, there are no commercially available games created with it, and no other libraries linked to it in the way that Direct2D is the successor of GDI.

Finally, one goal of learning the GDI is to learn a bit about how Windows work with device contexts and other such concepts, another is preserving the legacy, and a last one is building your own graphics library based on the GDI. I only have a single warning for all this, when projects get a bit too big, chances are it might become slow, but I am confident that by that time I will have started a tutorial on the XNA framework (which uses the same code both for PC and XBOX applications), and you will have enough experience to start using more modern libraries. Now we can jump to the point and start programming with the GDI!

Before you start though, I should warn you that though you will be learning useful things at a good rate and you will gain some knowledge very few people have any more, it will be a while before you can see that your code can bring results. But be patient, what you can create with the Win32Api and GDI, it is fair to say it's the real world stuff.