Can someone explain why this isn't working. I just get a black screen, I want to see a sphere. Any help appreciated.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, GLScene, GLViewer,
GLVectorGeometry, GLVectorTypes, GLObjects;
type
{ TForm1 }
TForm1 = class(TForm)
private
Scene: TGLScene;
Viewer: TGLSceneViewer;
Camera: TGLCamera;
Sphere: TGLSphere;
Light: TGLLightSource;
public
constructor Create(AOwner: TComponent); override;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
constructor TForm1.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
// Create the scene
Scene := TGLScene.Create(Self);
// Create the camera and set its position
Camera := TGLCamera.Create(Scene);
Camera.Position.SetPoint(0, 0, 10); // Set the camera 10 units away from the scene
// Camera.PointTo(TVector(0,0,0),TVector(0,1,0));
// Add a light source to the scene
Light := TGLLightSource.Create(Scene);
Light.Position.SetPoint(5, 5, 5); // Place the light source at (5, 5, 5)
// Create a sphere and place it at the center of the scene
Sphere := TGLSphere.Create(Scene);
Sphere.Radius := 10.0; // Set the radius of the sphere to 1 unit
Sphere.Position.SetPoint(0, 0, 0); // Set the position of the sphere
// Set up the GLSceneViewer
Viewer := TGLSceneViewer.Create(Scene);
Viewer.Parent := Form1; // Attach the viewer to the form
Viewer.Align := alClient; // Set it to fill the form
Viewer.Camera := Camera; // Assign the camera to the viewer
// Start rendering the scene
Viewer.Invalidate;
end;
end.