Feedback Search Top Backward Forward

The Codesmith's Library

Written by Carsten Whimster



My web page is finally coming of age, despite a minor accident. The OS/2 section has grown dramatically, and now has a large number of useful links to other OS/2 sites. Check it out at

My machine has been upgraded to an AMD DX4-100 with 20 Mb RAM and an ATI Mach64 with 2 Mb DRAM. Due to the increased speed and responsiveness, my interest in developing is growing once again. I am working on an update to my POV-Panel/2, and also on a couple of other projects, including a POV-Ray editor, and a PM version of an old video game called Qix. We'll see how far I get with all of it though <grin>.

Programming the OS/2 Warp GPI

For a while now, the OS/2 world has been without an in-depth, up-to-date book on the GPI. Now things are about to change, both because of this book, and also because Graham Winn's book has been updated as well. Here are the chapter headings for this, the newest of Stephen Knight's and Jeffrey Ryan's OS/2 books:

  • Overview
  • OS/2 Architecture
  • Graphic Primitives
  • Fonts
  • Building Blocks of the GPI
  • Transformations
  • Paths, Regions, Clipping, Boundary Accumulation, and Correlation
  • Printing Graphics
  • OS/2 Metafiles
    Appendix A: GPI Functions
    Appendix B: Working with the Diskette

This is a book by the author of Learning to Program OS/2 2.0 Presentation Manager by Example, and it shows. I criticized that particular book for only including a single, monolithic program as the example the whole book was built around. This book has the same basic structure, but I won't reiterate my criticism unless I feel that this book also suffers from the same faults that I described in the first one.

Reading this book quickly showed that the authors' ability to explain difficult material has not decreased with time. The writing is lucid, and more in-depth than the first book. This book is quite unusual in that it presents a complete, well-featured program in good detail throughout the chapters. The Overview presents the graphics application from the user's perspective, and really is a user manual, albeit a little short.

The next chapter, inexplicably called OS/2 Architecture, spends most of its time explaining the architecture of the GPI, and the OS/2 graphics viewing pipeline. The GPI architecture is quite complicated, and not really intuitive at all, but when you spend some time reading up on it, a lot of it come together. I still wonder if there isn't a better way to do things, though. It really does seem needlessly complicated to me. Hopefully DIVE will give those of us who prefer building things more manually a much-needed reprieve from the GPI. Anyway, enough complaining about the GPI!

The third chapter discusses graphic primitives like lines, circles, ovals, rectangles, as well as graphic attributes like line width, line colour, character colour, character shear, image colour, marker mix, and so on ad infinitum. There really are an absolutely astounding number of attributes to worry about, but they can be grouped into logical subsets, of course. These subsets are then explained briefly, followed by explanations of the line and arc primitives, including line join options. Some of the specific line options are outlined, but the main philosophy of the book is to explain only the most common functions in detail. Others may or may not get mentioned, but you can rest assured that 90-95% of what you will use is here. Some of the fills are also explained here, including the functions that use them. Also in this chapter is an introduction to text primitives, or in other words, using fonts in graphics. Finally, we are treated to an introduction to bitmap usage.

Chapter four is the first non-introductory chapter on any subject so far, and it attacks fonts. By the way, if you look at the chapter headings of this book, and compare them to the chapter headings of Winn's book, you will see a remarkable similarity there. I suppose it is unavoidable to a certain extent, but it doesn't look like a complete coincidence. Indeed, Graham Winn is given credit in the Acknowledgements section, so it looks like there is a fairly close relationship between the various graphics-book authors working at IBM. It should be interesting to see what Winn's new book will look like. In any case, back to the Fonts chapter. This chapter, like the rest, has an introductory paragraph giving a little background to the subject. I prefer to see a little more, and to have it also give a quick preview of what the chapter contains so that you know where you are headed, but that could be just personal preference. After the introductory paragraph, we are told a bit about codepages. This is interesting material, but at the same time, I really wish it didn't have to be there, ie. IBM should take some initiative with OS/2, and move towards double-byte characters, so that we won't have to deal with codepages any more. Yes, this would slow down our systems a bit, but I think that in the long run, it is worth it. But, back to our book. Outline fonts, image (bitmapped) fonts, kerning, font metrics, font attributes, and width tables are all introduced, and explained, and some larger code snippets out of the sample application are given.

The fifth chapter launches into an explanation of the building blocks that the GPI is constructed from, such as graphics orders and elements. Segments are covered in good depth, and then the graphics viewer is introduced into our subject matter. Quite a bit of code is given along the way, in large-ish chunks. Sometimes it is a little hard to grasp everything, with so much listed at a time.

The next chapter deals with the various transformations that the GPI allows you to perform on objects, including revisiting the coordinate spaces. You generally draw your objects first, and then put them through the transformations on the way to their final form. A fair amount of matrix math is needed to do this, so be sure that you are up on this subject before attempting to read this chapter. Of course, the GPI does supply the tools to do this, but comprehension is important.

Paths, regions, and so on is chapter seven's subject. It deals with the possibility of creating paths and regions, and then using these to either clip, fill, or otherwise modify various (other) objects. This is a fairly powerful technique, which you will most likely find a need for if you get into GPI in any depth at all. There are various ways to define paths and regions, and ways of combining them. Redrawing using regions is also explained. Model space clipping, page space clipping, device space clipping, and other clipping related options are all sub-sections of this chapter. In addition to these, there is a section called correlation, which is a bit of a god-send to anyone trying to design something like a Doom editor. This subject deals with the GPI's ability to select objects based on mouse- clicks and keystrokes. To this end, tags are explained here. They are used with objects to yield the desired granularity for the selection operation. A medium-sized code snippet goes along with this, but my feeling is that some more depth would have been nice here.

Printing graphics is the next chapter, and it explains the device independence of OS/2's printing sub-system, as well as a basic outline of the graphics-printing relationship in OS/2. Chapter 9 delves into OS/2's metafiles, and the raison-d'etre for this otherwise fairly unused format. Basically, it is meant as a go-along to the GPI, and is supposed to be used for picture interchange between applications of different nature. It saves more information than the other non-native format of the drawing editor, TIFF, in that drawing commands themselves can be stored in a metafile. It is in some ways more similar to a printer or the screen, than to other graphics formats, in that it is handled as a device under OS/2. Again, a large- ish chunk of code is regurgitated at the end of the chapter, making the reading a little heavier than usual. With these large code-snippets, it is harder to dissect what is necessary, and what is frills. Still, a good deal more can potentially be taught as opposed to small programs that do little.

The appendices have information on the GPI functions (basically a quick-reference listing of the GPI functions of Warp), and a small section on how to use the accompanying diskette.


I like this book a fair amount, and it is a definite improvement on the feel of Stephen Knight's Learning to Program OS/2 2.0 Presentation Manager by Example. At the same time, having only a single sample program has to have its limitations, and I can't help but feel that certain areas could have been covered more in depth. This does not in any way mean that this book is not a good book, and in fact, one might equally well complain that most books, by having a large number of small programs miss out on the chance to treat certain other subjects in depth. It is more of a new angle than a bad angle. I personally prefer more small programs, but I won't let this affect my judgement of the book, because not everyone feels the same way. I feel that sometimes the reader is left for a long time without concrete code to browse, and other times the code snippets get a little large to digest. For this reason only, I give this book an A-, rather than an A.

This book should be extremely attractive to anyone writing a graphics editor, since it includes a capable, if not full-featured graphics editor program and full source. It may appeal less to games writers and other graphics programmers due to the limited nature of using only one sample application. Very readable, and well-explained, however.

Programming the OS/2 Warp GPI, Knight and Ryan.

  • Wiley and Sons. ISBN 0-471-10718-2. US$39.95, CAN$55.95.
  • Intended Audience: OS/2 Graphics Programmers
  • Mark: A-

Reviewed Books

Our Bookstore has reviews and links to Amazon for all books we have reviewed in the past, as well as several books waiting to be reviewed, and others which we recommend.