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

Nun kommen wir zu Transformationen. Mit Transformationen kann man das Zentrum unserer Matrix verschieben.

Also, nehmen wir einmal an, wir zeichnen ein Dreieck um den Mittelpunkt unserer Matrix herum ( 0, 0, 0). Die Koordinaten der Vertices würden etwa so aussehen: ( 0,-1, 0); (-1,-1, 0); ( 1,-1, 0);

Wenn man dieses Dreieck nun nach rechts verschieben möchte, hat man zwei Möglichkeiten. Die eine ist es das Dreieck selbst zu verschieben: ( 1,-1, 0); ( 0,-1, 0); ( 2,-1, 0); Oder aber man verschiebt die ganze Matrix nach rechts und zeichnet das Dreieck um den neuen Nullpunkt. Und letzteres ist eine Transformation.

Transformationen führt man durch, in dem man glTranslate() aufruft. Als Parameter werden x/y/z Koordinaten angegeben, in welche Richtung man verschieben will. Hier nun der Code für unser nach rechts verschobenes Dreieck.

  glClear( GL_COLOR_BUFFER_BIT );
  glLoadIdentity();

  glTranslatef(0.9,0.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. Die ganze Matrix wird um 0.9 Einheiten nach rechts verschoben.

Mit glLoadIdentity(); bringen wir die Matrix in den Urzustand. Löscht einmal die Zeile glLoadIdentity() und schon verschiebt ihr jede Runde die Matrix weiter nach rechts (bis das Dreieck aus dem Bild ist). So weit zu Transformation.

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

Back to previous page

Useful Links









Link to us