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.

Einführung in OpenGL - Teil 9 - by Delax

Jetzt, wo wir die Depth Functions kennen gelernt haben, können wir anfangen richtige 3D Objekte zu bauen. Dies geht eigentlich ganz einfach. Ein Objekt besteht seinerseits aus einer Anzahl von Primitives. Wir nutzen also Drei-, Vier- und Vielecke, um ein 3D Objekt zusammen zu setzen.

Nehmen wir einmal eine Pyramide. Sie hat 4 Dreiecke als Seitenwände und ein Viereck als Unterseite. Und das setzen wir einfach nur um.

     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();

Hier der komplette Source zum Beispiel.

Wirklich nicht besonders schwer, oder? Die allermeißten Objekte lassen sich aus mehr oder weniger vielen Primitives zusammenbauen. Wichtig ist wie gesagt darauf zu achten wohin die Fläche zeigt und sie dann in entsprechender Reiehnfolge (im oder gegen den Uhrzeigersinn) zu zeichnen. Beispielsweise zeichnen wir die Rückseite der Pyramide im Uhrzeigersinn, was daran liegt, das wir sie ja von hinten sehen.

Versucht einfach mal selbst einen Würfel oder ähnliche Objekte zu bauen. Vielleicht sogar eine Art Strichmännchen aus Quads? Denkt euch was aus und baut es. So bekommt ihr ein Gefühl für den 3D Raum und wie man Objekte zusammensetzt.

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

Back to previous page

Useful Links









Link to us