Topenglpanel Page

ViewMat := TMatrix.CreateLookAt( Point3D(0, 2, 5), // Eye position Point3D(0, 0, 0), // Look-at center Point3D(0, 1, 0) // Up vector );

// Setup matrices ModelMat := TMatrix.Identity; ModelMat := ModelMat * TMatrix.CreateRotationY(DegToRad(FAngle)); ModelMat := ModelMat * TMatrix.CreateRotationX(DegToRad(FAngle * 0.7)); TOpenGlPanel

procedure TOpenGLContextHelper.DrawCubeFace(FaceIndex: Integer; Size: Single); const // Vertex data for each face (order: bottom-left, bottom-right, top-right, top-left) FaceVertices: array[0..5, 0..3] of TPoint3D = ( (( -1, -1, 1), ( 1, -1, 1), ( 1, 1, 1), (-1, 1, 1)), // front (( 1, -1, -1), (-1, -1, -1), (-1, 1, -1), ( 1, 1, -1)), // back (( -1, 1, -1), ( 1, 1, -1), ( 1, 1, 1), (-1, 1, 1)), // top (( -1, -1, 1), ( 1, -1, 1), ( 1, -1, -1), (-1, -1, -1)), // bottom (( -1, -1, -1), (-1, -1, 1), (-1, 1, 1), (-1, 1, -1)), // left (( 1, -1, 1), ( 1, -1, -1), ( 1, 1, -1), ( 1, 1, 1)) // right ); var V: array[0..3] of TPoint3D; j: Integer; begin for j := 0 to 3 do V[j] := FaceVertices[FaceIndex, j] * Size; ViewMat := TMatrix

type TMyOpenGLPanel = class(TOpenGLPanel) private FAngle: Single; FTimer: TTimer; procedure OnTimer(Sender: TObject); protected procedure Paint; override; procedure Resize; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure StartAnimation; procedure StopAnimation; end; ViewMat := TMatrix.CreateLookAt( Point3D(0

type TOpenGLContextHelper = class helper for TContext3D public procedure DrawCubeFace(FaceIndex: Integer; Size: Single); end; implementation

Context.SetModelViewMatrix(ModelMat * ViewMat); Context.SetProjectionMatrix(ProjMat);

feedback