Table of Contents
Since SGL stands for Simple Graphics Library, its design philosophy is simple—in most situations where a trade-off had to be made between simplicity and increased flexibility with an associated increase in complexity, simplicity was chosen.
The SGL is a thin wrapper around GLUT. It insulates the programmer from the GLUT API and provides its own simplified object-oriented API. The programmer can access the lower-level GLUT and OpenGL routines if necessary, but the aim of the SGL is to completely protect the novice developer from the more arcane and technically complicated GLUT and OpenGL functions.
The SGL's object model is similar to Java's graphical component model. Java's model is, of course, fairly sophisicated. Because it is simple, the SGL is much more restricted. For example, in Java programmers may register any number of graphical and non-graphical objects as listeners for mouse events such as button clicks or mouse pointer movement. In the SGL, the graphical window responsible for the mouse event is the only listener. Since most programs developed by beginning programmers will need to register only one mouse listener, this limitation is generally not an issue. In situations where multiple objects must be notified when a mouse event occurs, the programmer can write custom code to forward the event on to the appropriate objects. Since the window is the mouse listener in the SGL, no registration is required. The trade-off here is clear:
The SGL adopts a simple approach that makes it relatively easy to program the large majority of mouse event scenarios encountered by beginning programmers.
Modern GUI development libraries such as Java's eases the management of more complex mouse event scenarios at the expense of complicating the code required to process even the most trivial mouse events.
Beginning programmers typically do not tackle problems with the industrial-strength requirements that modern GUI development libraries were created to handle, so the SGL approach avoids the cognitive overhead and strives to make simple things easy to do.
Copyright ©2019 Richard L. Halterman | Version 0.9.5 | February 17, 2019 |