Home Index Search Links About Us
[LinuxFocus Image]
[Navegation Bar]
  News   Archives   Companies   Tips  

OpenGL Programming: More About Lines

by Miguel Angel Sepúlveda


example2.c

Makefile

Drawing Lines

Last time we discussed the basic elements of polygon construction under OpenGL. OpenGL only supports a few basic primitive geometrical objects: points, lines, polygons, and surfaces described by arrays of small quadrilaterals or triangles.

The main idea behind OpenGL's simplicity is that it is up to the developer to implement from this simple objects more complex geometrical models. OpenGL contains a number of commands to control the details of points, lines and polygons.

For example the size of points can be specified in pixels using glPointSize:


void glPointSize(GLfloat size)

By the default the size of points is 1.0 and size must always be greater than zero. Notice that the size of a point is specified by a float number; fractional point and line sizes are allowed. OpenGL interprets fractional pixel sizes according to the rendering context. If the anti-aliasing mode is enable then OpenGL modifies the neighboring pixels to the line in question in order to give the appearance of a fractional width. Anti-aliasing is a technique also used to eliminate the ugly stars the straight lines show on computer screens at low monitor resolution. If anti-aliasing is not enable then glPointSize will round off size to the closets integer.

The physical size of a pixel actually is device dependent. So for example at low monitor resolution a pixel appears wider. Similarly on very high resolution devices, like a plotter, the default 1 pixel line can appear almost invisible. To estimate the real width of your lines you must know the actual physical dimensions of pixels on the output device.

The width of lines is specified by the glLineWidth function, that must be invoked before the glBegin() - glEnd() pair that draws the line(s). Here is the full syntax of the command:


void glLineWidth(GLfloat width)

OpenGL implementations may limit the width of nonantialiased lines to its maximum antialiased line width, rounded to the nearest integer value. Also keep in mind that line widths are measured not perpendicularly to the line but in the y-direction if the absolute value of the slope is less than 1; if greater in the x-direction.

This month we have prepared another simple but hopefully useful 2D animation that shows you how to use various kinds of line widths in your OpenGL applications (example2.c, Makefile). I chose an example from Quantum Physics, a quantum particle trapped in a double well potential. Why? Umm actually I forget. Anyway I figurnd writing experience in many ways. Not only have I learnt a lot doing it, but I've met thousands of people that I really like while developing Linux - some of them in person, most of them through the internet.

LF : Please allow me to make an easy and superficial comparison. You, like Bill Gates have developed an operating system of great success while still being a student. Well actually Gates did not really developed an OS himself, but allow me the comparison ;). You have gained tremendous popularity and won several prices like "The UniForum Award" or the recent "Nokia Foundation" in 1997 which mentions your "inspiring example for young researchers". Now Mr. Gates, years past and far away from that youngster who together with Paul Allen founded Microsoft, is disgustingly rich and lives in a mansion near Lake Washington, Seattle, which cost him around 63 million US$. Can you see yourself, your wife Toe and your daughter Patricia in a house like that?

Linus: I have no idea where I'd get that kind of money, but I can certainly imagine living in a house like that. I'd probably enjoy it immensely ;)

But I don't really think that the comparison is all that valid. Bill Gates really seems to be much more of a business man than a technologist, while I prefer to think of Linux in technical terms rather than as a means to money. As such, I'm not very likely to make the same kind of money that Bill made..

LF: The 25th of August 1991, you launched the following message to the USENET: "Hello everybody out there using minix. I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones." Since the birth of Linux in 1991 (Destiny wished you didn't called it Benedictux, thankfully), the evolution of this operating system has gone through various stages since that primitive 0.01 of September 1991. By the 5th of October you already had 0.02 an shortly after 0.03, finally arriving to a 0.10, 0.11 and a very decent 0.12. From here it jumped to the 0.95 and 0.96, already foreseeing the first "non-beta" version. After the first version, in June 9th 1996 you announced version 2.0 which had little to do with its predecessors: multi-architecture support, symmetrical multi-processor support, read-write shared memory mappings of file support, just to mention a few of its innovations. Do you have any idea when we will see version 3.0 and what can kind of innovations will merit a jump to a new version?

Linus: Right now it looks like the next "jump" is going to be real-time and cluster features. Linux is actually already used for both of these things, but being used for something and being designed to do it are two different things.

But I really don't want to limit Linux to any special "five year plan": the clustering and real-time stuff is just something that people are already working on, and that is fairly well understood and has traditional uses.

I think the really _interesting_ new things are going to be things that are only beginning to show up today, but that will be commonplace in a year or two. High-bandwidth networking, live video etc. I don't know how that will change how we use computers, but it will certainly have a rather fundamental impact on operating systems.

LF: In August of last year, 1997, in Monterey California, a long standing dispute over the ownership of the Linux operating system trademark was resolved and you were assigned the ownership for the registered mark. Despite this, the GPL license allows other companies to do business selling Linux without you taking direct part (at least in just proportion) in the share of profits that must result, instead you devote actively and personally in the development of new versions and patch updates....

Linus: Yes. It should be noted that a trademark on the name "Linux" and the copyright on the code that consitutes Linux really are very separate. Right now I own both the trademark and a large portion of the copyrights, but there is nothing to say that it has to be so. In fact, I tried to get the trademark transferred to the Linux International not-for-profit organization, but it made more legal sense to transfer it to me personally, and also there were more people who apparently trusted me personally rather than a organization.

LF: ...When you are asked if this bothers you, you not only respond negatively but express your satisfaction and happiness that companies like Red Hat are introducing Linux in commercial ventures, thus contributing to develop a more polished product. What does your ego feels when it becomes known for example that Linux is selected (over Windows/NT and DEC UNIX) as the ideal OS by Digital Domain, the company that created the high-tech visual effects for the movie Titanic, or when Debian Systems develops the software for the Ham Radio satellite's communication systems?

Linus: Obviously one of the reasons that I really don't mind that people are selling Linux commercially is exactly because it _does_ make me feel good that people use the product.

So while I may not get any money from Linux, I get a huge personal satisfaction from having written something that people really enjoy using, and that people find to be the best alternative for their needs.

And at the same time, the GPL forces all future contributions to Linux to be available to everybody, which means that when a commercial company like RedHat makes a more polished Linux release, I really _do_ get something out of it. So there is quite a lot of compensation, even when that compensation isn't in the form of money.

LF: How do you feel about the GUI war going on for the Linux environment? What do you think about alternative GUIs such as the Berlin project? Do you see any problems with X?

Linus: I'm in the strange position of having concentrated very actively on the base operating system, and I really haven't even followed the projects around Linux very much. I let the user-level chips fall as they may, in the secure knowledge that whatever strange things some user level program may do, the kernel will be able to handle it.

When it comes to a GUI, one of the most important parts is that it is widely accepted, and that it is technically sound. The X Window system meets both of those requirements as far as I'm concerned, and while it obviously has a few problems they are by no means debilitating.

I think the most interesting work is going into making X look and feel nicer, rather than replacing it with something else. There are a few really nice desktop systems: fvwm95, KDE etc, and I think X is stronger for them. I don't think we have much of a problem with the GUI, but I'll wait and see what people will come up with.

LF: At this point in time, merely 6 years since the birth of Linux things are moving very rapidly. RedHat was named by Infoworld the operating system of the year; Linux is the fastest growing non-Microsoft Operating System in the world according to the IDC; and it is estimated that in 1997 somewhere between 2 million to 6 million copies of Linux were installed worldwide. Amist this cyclone of events you do not appear to remain passive watching Linux grow. Instead you seem to break physical space/time laws, showing up in multiple conferences (like your schedule appearence in North Carolina this May), your work at Transmeta (incidentally can you unveil anything to us?), the continuing development of the Linux Kernel (keeping up with email, newsgroups), taking care of the attention that from time to time the media pays you and your private life. Looking back in the past, Do you feel Linux has satisfied your initial expectations?

Linus: Linux has more than satisfied any small initial expectations I had. It's simply incredible how successful Linux has been, and how good a time I've had developing it and leading the project. It _does_ take a lot of my time, but it's time I really enjoy spending, and Linux has continued to be challenging both technically and from a managing standpoint.

I don't go to conferences quite as much as I used to: having a child and movin away from the university leaves me with less time than I had a few years ago, but I've tried to balance things out - not just spending time with Linux all the time, but having a real job and a real life at the same time. It has worked reasonably well, and while I'm fairly busy I can honestly say that I'm not at least bored ;)


© 1998 Manuel Martinez
This website is mantained by Miguel A Sepulveda.
usr/doc/lfocus-en-1998.03/html/article3.html100644 0 0 41720 6563376632 16643 0ustar rootroot LinuxFocus March 1998 -- OpenGL Programming: More About Lines Home Index Search Links