glLoadMatrix: Unterschied zwischen den Versionen
K (Kategorisierung) |
(→Beispiel-Quelltext) |
||
| Zeile 41: | Zeile 41: | ||
===Beispiel-Quelltext=== | ===Beispiel-Quelltext=== | ||
| − | Als Ersatz für [[glPushMatrix]] | + | Als Ersatz für [[glPushMatrix]] und [[glPopMatrix]]: |
| + | |||
<source lang="pascal">type | <source lang="pascal">type | ||
| − | + | TMatrix = array[0..3, 0..3] of glFloat; | |
| − | |||
| − | |||
| − | TMatrix = array[ | ||
| − | |||
var | var | ||
| − | TempMatrix:TMatrix; | + | TempMatrix: TMatrix; |
begin | begin | ||
| − | glClearColor(0,0,0,0); | + | glClearColor(0.0, 0.0, 0.0, 0.0); |
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); | ||
glMatrixMode(GL_MODELVIEW); | glMatrixMode(GL_MODELVIEW); | ||
glLoadIdentity; | glLoadIdentity; | ||
| − | glTranslatef(-0.8,-0.5,0); //Vorgebene Startposition | + | glTranslatef(-0.8, -0.5, 0.0); // Vorgebene Startposition |
| − | glGetFloatv(GL_MODELVIEW_MATRIX,@TempMatrix); //Matrix wird gespeichert | + | glGetFloatv(GL_MODELVIEW_MATRIX, @TempMatrix); // Matrix wird gespeichert |
| − | + | // Rotes Dreieck | |
| − | glColor3f(1,0,0); | + | glColor3f(1.0, 0.0, 0.0); |
| − | glTranslatef(1,0,0); | + | glTranslatef(1.0, 0.0, 0.0); |
glBegin(GL_TRIANGLES); | glBegin(GL_TRIANGLES); | ||
| − | glVertex3f(1,0 | + | glVertex3f(1.0, 0.0, -2.0); |
| − | glVertex3f(0,1 | + | glVertex3f(0.0, 1.0, -2.0); |
| − | glVertex3f(0,0 | + | glVertex3f(0.0, 0.0, -2.0); |
glEnd; | glEnd; | ||
| − | glLoadMatrixf(@TempMatrix); //Gespeicherte Matrix wird wieder geladen | + | glLoadMatrixf(@TempMatrix); // Gespeicherte Matrix wird wieder geladen |
| − | + | // Grünes Dreieck | |
| − | glColor3f(0,1,0); | + | glColor3f(0.0, 1.0, 0.0); |
glBegin(GL_TRIANGLES); | glBegin(GL_TRIANGLES); | ||
| − | glVertex3f(1,0 | + | glVertex3f(1.0, 0.0, -2.0); |
| − | glVertex3f(0,1 | + | glVertex3f(0.0, 1.0, -2.0); |
| − | glVertex3f(0,0 | + | glVertex3f(0.0, 0.0, -2.0); |
glEnd; | glEnd; | ||
end;</source> | end;</source> | ||
| − | |||
| − | |||
== Fehlermeldungen == | == Fehlermeldungen == | ||
Version vom 22. Juni 2018, 17:36 Uhr
Inhaltsverzeichnis
glLoadMatrix
Name
glLoadMatrix - ersetzt die aktuelle Matrix durch eine beliebige Matrix.
Delphi-Spezifikation
procedure glLoadMatrixd(const m: PGLdouble); procedure glLoadMatrixf(const m: PGLfloat);
Parameter
| m | Ein Zeiger auf eine 4x4-Matrix, welche die aktuelle Matrix ersetzen soll. |
|---|
Beschreibung
glLoadMatrix ersetzt die aktuelle Matrix durch die 4x4-Matrix, auf die m zeigt. Abhängig vom aktuellen Matrix-Modus (glMatrixMode) wird dadurch die Projektions-Matrix, die Modelview-Matrix oder die Texture-Matrix ersetzt (siehe dazu "Die drei OpenGL-Matrizen").
Der Parameter m zeigt auf eine 4x4-Matrix, welche spaltenweise Fließkommazahlen mit einfacher oder doppelter Genauigkeit (Single oder Double) enthält.
Die Matrix muß also in der folgenden Reihenfolge gespeichert sein:
+- -+ | 0 4 8 12 | | 1 5 9 13 | | 2 6 10 14 | | 3 7 11 15 | +- -+
Beispiel-Quelltext
Als Ersatz für glPushMatrix und glPopMatrix:
type
TMatrix = array[0..3, 0..3] of glFloat;
var
TempMatrix: TMatrix;
begin
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
glTranslatef(-0.8, -0.5, 0.0); // Vorgebene Startposition
glGetFloatv(GL_MODELVIEW_MATRIX, @TempMatrix); // Matrix wird gespeichert
// Rotes Dreieck
glColor3f(1.0, 0.0, 0.0);
glTranslatef(1.0, 0.0, 0.0);
glBegin(GL_TRIANGLES);
glVertex3f(1.0, 0.0, -2.0);
glVertex3f(0.0, 1.0, -2.0);
glVertex3f(0.0, 0.0, -2.0);
glEnd;
glLoadMatrixf(@TempMatrix); // Gespeicherte Matrix wird wieder geladen
// Grünes Dreieck
glColor3f(0.0, 1.0, 0.0);
glBegin(GL_TRIANGLES);
glVertex3f(1.0, 0.0, -2.0);
glVertex3f(0.0, 1.0, -2.0);
glVertex3f(0.0, 0.0, -2.0);
glEnd;
end;
Fehlermeldungen
GL_INVALID_OPERATION wird generiert, wenn glLoadMatrix innerhalb eines glBegin-glEnd-Blocks aufgerufen wird.
Zugehörige Wertrückgaben
glGet mit Token GL_MATRIX_MODE
glGet mit Token GL_MODELVIEW_MATRIX
glGet mit Token GL_PROJECTION_MATRIX
glGet mit Token GL_TEXTURE_MATRIX