Topenglpanel 90%
// Draw a cube (6 faces) for i := 0 to 5 do begin case i of 0: Context.SetColor($FFFF0000); // Red - front 1: Context.SetColor($FF00FF00); // Green - back 2: Context.SetColor($FF0000FF); // Blue - top 3: Context.SetColor($FFFFFF00); // Yellow - bottom 4: Context.SetColor($FFFF00FF); // Magenta - left 5: Context.SetColor($FF00FFFF); // Cyan - right end;
ViewMat := TMatrix.CreateLookAt( Point3D(0, 2, 5), // Eye position Point3D(0, 0, 0), // Look-at center Point3D(0, 1, 0) // Up vector );
// Clear buffers Context.SetClearColor($FF1A1A2E); // dark blue-gray Context.Clear([TClearTarget.Color, TClearTarget.Depth]); TOpenGlPanel
procedure TMyOpenGLPanel.OnTimer(Sender: TObject); begin FAngle := FAngle + 2; if FAngle >= 360 then FAngle := FAngle - 360; Repaint; // triggers Paint method end;
procedure TMyOpenGLPanel.Resize; begin inherited; if Assigned(Context) then Context.SetViewport(RectF(0, 0, Width, Height)); end; // Draw a cube (6 faces) for i
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;
unit uOpenGLPanelDemo; interface
// Each face: two triangles (4 vertices) Context.DrawCubeFace(i, 1.0); // Custom helper (see below) end; end;
ProjMat := TMatrix.CreatePerspectiveFovRH( DegToRad(60), // Field of view Width / Max(Height, 1), // Aspect ratio 0.1, 100.0 // Near/far planes ); // Red - front 1: Context.SetColor($FF00FF00)
uses System.SysUtils, System.Classes, System.Math.Vectors, FMX.Types, FMX.Controls3D, FMX.Objects3D, FMX.MaterialSources, FMX.Controls.Presentation, FMX.Controls, FMX.Forms, FMX.Types3D, FMX.Context.GLES, FMX.Layers3D;
Recent Comments