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.

60 lines
1.1 KiB
Plaintext

unit UView;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, OpenGLContext, gl, glu, UGLTypes;
type
{ TView }
TView = class
public
constructor Create(AOpenGLControl: TOpenGLControl);
procedure OpenGLInit(AResetModelView: Boolean);
procedure Clear;
private
FOpenGLControl: TOpenGLControl;
end;
const
CBackgroundColor: TColor3f = (R: 0.27; G: 0.53; B: 0.71);
implementation
{ TView }
constructor TView.Create(AOpenGLControl: TOpenGLControl);
begin
FOpenGLControl := AOpenGLControl;
FScale := 1;
end;
// TODO: Do we need 'AResetModelView'?
procedure TView.OpenGLInit(AResetModelView: Boolean);
begin
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
glViewport(0, 0, FOpenGLControl.Width, FOpenGLControl.Height);
gluOrtho2D(0, FOpenGLControl.Width, 0, FOpenGLControl.Height);
glMatrixMode(GL_MODELVIEW);
if AResetModelView then
glLoadIdentity;
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
end;
procedure TView.Clear;
begin
glClearColor(CBackgroundColor.R, CBackgroundColor.G, CBackgroundColor.B, 0);
glClear(GL_COLOR_BUFFER_BIT);
end;
end.