Welcome to the new Friends-of-FPC!

Here you can find all kinds of information about the FreePascal Compiler. We have many tutorials and howtos as well as a selection of tools to help you with your programming. We also have some example codes for you. And if you want to contribute some information/ sources/ tools yourself you can do so.
Also we have finally relaunched the FoFPC forum. It's your chance for some Q&A about everything FreePascal.

Friends-of-FPC

Tutorials: Learn how to code with FreePascal.

Source Codes: A collection of examples, miscellaneous source codes and open source stuff.

Tools and Help Files: Intro- duction of some tools that might help you with FPC.

Community

Forum: Ask or answer questions about the FreePascal Compiler, programming or just babble about coding.

Contribute! Contribute your own Tutorial, Source Codes or Tools and send them to us!

Website

About: Information about Friends-of-FPC.org.

OpenGL/ FPC - Chapter 5 - by Delax

In the third chapter, we learned how to draw triangles in OpenGL. Those triangles are part of the OpenGL primitives. Primitives are simple surfaces like triangles, quads, lines etc. With these primitives one can compose more complex objects.

A line is described by two vertices: start and end. A triangle has 3 vertices, a quad has 4 and a polygon can be composed out of an infinite number of vertices. But more on polygons later, let's focus on the simple primitives for now.

A line is drawn with glBegin( GL_LINES ). Until the glEnd() is given, every pair of Vertices will be drawn as line. If you want the ending vertex of one line to be the start vertex of the next line, use glBegin( GL_LINE_STRIP ).

As you can see to the right, you need 3 vertices with glBegin( GL_LINE_STRIP ). Triangles also have a stripped variant. The last two vertices are the starting vertices for the new triangle.

Triangles also have another mode called TRIANGLE_FAN. Fan is using the first vertex as center and all the following vertices are set around this center.

Next up are quads. Quads do have a stripped mode, but they don't behave like normal quads then. The even vertices are drawn on one side and the odd ones on the other. So the quad strip vertices have to be given like this: v1, v2, v4, v3, v6, v5,.. It's confusing at first, but one gets used to it.

So where is the advantage of stripped primitives? Well, obviously you don't need as much vertices. That means that you don't need as much space and the graphics card can process your objects faster. So composing objects our of stripped primitives is the preferred method.

Take a look at the sample program here. All primitive modes mentioned here are drawn. But not as filled surfaces, but outlined with glPolygonMode(GL_BACK, GL_LINE);. No magic, just outlining a surface instead of filling it with the set color.

Delax/ Sundancer Inc.
[delax@sundancerinc.de]

Back to previous page

Useful Links









Link to us