- function TfemProjectCanvas.ObjToScr(X, Y, Z: Double): TfemPoint3D;
- // Objektkoordinaten in Bildschirmkoordinaten wandeln
- var
- ViewPort: TGLVectori4;
- oX, oY, oZ: TGLDouble;
- begin
- if FOpenGLValid then
- begin
- // aktuellen Viewport lesen
- glGetIntegerv(GL_VIEWPORT, @ViewPort);
- // Punkt berechnen
- if gluProject(X, Y, Z, FOpenGLMatrixModelView, FOpenGLMatrixProjection, ViewPort, @oX, @oY, @oZ) <> GL_TRUE then
- raise Exception.CreateFmt('Error calling gluProject'#13'%s', [gluErrorString(glGetError)]);
- // Ergebnisse eintragen
- Result.X := oX;
- Result.Y := ViewPort[3] - oY;
- Result.Z := oZ;
- end
- else
- Result := TfemPoint3D.Create(0, 0, 0);
- end;