You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
1.7 KiB
Plaintext
90 lines
1.7 KiB
Plaintext
unit UMainForm;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, OpenGLContext, gl,
|
|
UView, UDraw;
|
|
|
|
type
|
|
|
|
{ TMainForm }
|
|
|
|
TMainForm = class(TForm)
|
|
OpenGLControl: TOpenGLControl;
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure FormDestroy(Sender: TObject);
|
|
procedure OpenGLControlClick(Sender: TObject);
|
|
procedure OpenGLControlPaint(Sender: TObject);
|
|
procedure OpenGLControlResize(Sender: TObject);
|
|
private
|
|
FView: TView;
|
|
public
|
|
|
|
end;
|
|
|
|
const
|
|
CCenterX = 250;
|
|
CCenterY = 200;
|
|
CWidth = 200;
|
|
CHeight = 300;
|
|
CCornerSize = 30;
|
|
|
|
var
|
|
MainForm: TMainForm;
|
|
|
|
implementation
|
|
|
|
{$R *.lfm}
|
|
|
|
{ TMainForm }
|
|
|
|
procedure TMainForm.FormCreate(Sender: TObject);
|
|
begin
|
|
FView := TView.Create(OpenGLControl);
|
|
end;
|
|
|
|
procedure TMainForm.FormDestroy(Sender: TObject);
|
|
begin
|
|
FView.Free;
|
|
end;
|
|
|
|
procedure TMainForm.OpenGLControlClick(Sender: TObject);
|
|
begin
|
|
// TODO: This is just a workaround until we find a better place for the init.
|
|
FView.OpenGLInit(True);
|
|
OpenGLControl.Repaint;
|
|
end;
|
|
|
|
procedure TMainForm.OpenGLControlPaint(Sender: TObject);
|
|
begin
|
|
// Prepares drawing.
|
|
FView.Clear;
|
|
glLoadIdentity;
|
|
|
|
// Draws everything.
|
|
TDraw.AddRoundBox(CCenterX, CCenterY, CWidth, CHeight, CCornerSize);
|
|
|
|
// Finishes drawing.
|
|
OpenGLControl.SwapBuffers;
|
|
end;
|
|
|
|
procedure TMainForm.OpenGLControlResize(Sender: TObject);
|
|
begin
|
|
//scaling := FDrawing.Scaling;
|
|
FView.OpenGLInit(True);
|
|
// TODO: It seems that a call to Reset should not be necessary, which then should also make the scaling changes irrelevant.
|
|
//FView.Reset;
|
|
// TODO: Restore previous zoom.
|
|
// ScaleView(scaling);
|
|
|
|
// Redraws control, but only if form is shown.
|
|
if (fsShowing in FormState) then
|
|
OpenGLControl.Repaint;
|
|
end;
|
|
|
|
end.
|
|
|