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

Nach der Transformation ist es nur noch ein kleiner Schritt zur Rotation. Hierbei wird die ganze Matrix um einen Wert um eine (oder mehrere) Achsen gedreht.

Stellt euch jetzt einmal das 3 Dimensionale Koordinatensystem vor. Da haben wie die X Achse, welche horizontal verläuft. Die Y Achse verläuft vertikal und die Z Achse in den Bildschirm hinein und heraus. Nun rotieren wir einmal um die X Achse. Wir nehmen unser Gebilde oben an der Y Achse und rotieren um die X Asche herum, bis die Y Achse auf uns zeigt. Und schon läuft die Y Achse in den Bildschirm und die Z Achse läuft vertikal.

Hm, da man das ganze besser visuall versteht, hier ein kleines Beispiel, bei dem wir die Matrix um die Y Achse drehen.

  glClear( GL_COLOR_BUFFER_BIT );
  glLoadIdentity();

  glRotatef( rotation, 0.0, 1.0, 0.0 );                         

  glBegin( GL_TRIANGLES );
    glColor3f(1.0, 0.0, 0.0);  
    glVertex3f(0.0, 1.0, 0.0);
    glColor3f(0.0, 1.0, 0.0); 
    glVertex3f(-1.0, -1.0, 0.0);
    glColor3f(0.0, 0.0, 1.0); 
    glVertex3f(1.0, -1.0, 0.0);
  glEnd();  

Das komplette Beispiel gibt es hier.

Wir wir sehen wird glRotatef() mit 4 Parametern aufgerufen. Der erste ist die Anzahl der Rotation in Grad. Die nachfolgenden 3 stehen für den Vektor, vom dem aus sich die Rotation vollzieht.

Wir nutzen für die fortlaufende Rotation eine Variable, die sich in jeder Runde erhöht und so auch den Wert der Drehung. Man könnte auch einen festen Wert wie 0.1 wählen und den Reset der Matrix (glLoadIdentity) weglassen. Kommt auf das gleiuche heraus.

Schaut es euch am besten einmal an und gebt ein paar Werte in glRotatef() ein, dann bekommt ihr recht schnell den Durchblick.

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

Back to previous page

Useful Links









Link to us