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 9 - by Delax

Now that we know the Depth Functions, we can start to build our own 3D objects. Actually this is very simple as an object is composed of primitives. So we use triangles, quads etc to build more complex 3D objects.

Let's take a pyramid for example. A pyramid is composed out of 4 triangles and one quad. 4 triangles as front, left, back and right and the quad as bottom.

     glBegin( GL_TRIANGLES );

	glColor3f(1.0,0.0,0.0);
	 glVertex3f( 0.0, 1.0, 0.0);
	 glVertex3f(-1.0,-1.0, 1.0);
	 glVertex3f( 1.0,-1.0, 1.0);

	glColor3f(0.0,1.0,0.0);
	 glVertex3f( 0.0, 1.0, 0.0);
	 glVertex3f( 1.0,-1.0, 1.0);
	 glVertex3f( 1.0,-1.0, -1.0);

	glColor3f(0.0,0.0,1.0);
	 glVertex3f( 0.0, 1.0, 0.0);
	 glVertex3f( 1.0,-1.0, -1.0);
	 glVertex3f(-1.0,-1.0, -1.0);

	glColor3f(1.0,1.0,0.0);
	 glVertex3f( 0.0, 1.0, 0.0);
	 glVertex3f(-1.0,-1.0,-1.0);
	 glVertex3f(-1.0,-1.0, 1.0);

     glEnd();

     glBegin( GL_QUADS );

	glColor3f(1.0,0.0,1.0);
	 glVertex3f( 1.0,-1.0,-1.0);
	 glVertex3f( 1.0,-1.0, 1.0);
	 glVertex3f(-1.0,-1.0, 1.0);
	 glVertex3f(-1.0,-1.0,-1.0);

     glEnd();

Get the source code here.

Not that complicated, is it? About every object can be composed out of these simple primitives. But as I mentioned before: you have to look out in what direction your surfaces are pointing (clockwise or counter clockwise).

Try to build a cube for yourself. Or how about a simple house? Fool around a bit and get comfortable with building something in a 3D space.

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

Back to previous page

Useful Links









Link to us