openglmain.pas

来自「一款RPG游戏的引擎可以自己制作一款RPG游戏的引擎可以自己制作」· PAS 代码 · 共 71 行

PAS
71
字号
unit OpenGLMain;

interface

{ The Fuchsia borders around some of the trees, are a fault in the map,
  not a fault in the OpenGLIsoEngine (I don't know why DirectX doesn't
  displays them different) }

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  {CgWindows is part of CgLib which can be obtained from www.gamedeveloper.org}
  CgWindow,
  OpenGLIsoEngine;

type
  TForm1 = class(TCGForm)
    procedure FormResize(Sender: TObject);
  private
    { Private declarations }
    FIsoMap: TOpenGLIsoMap;

    procedure Flip(Sender: TObject);
    procedure AppIdle(Sender: TObject; var Done: Boolean);
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;

    property IsoMap: TOpenGLIsoMap read FIsoMap;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

{ TForm1 }

procedure TForm1.AppIdle(Sender: TObject; var Done: Boolean);
begin
  IsoMap.DrawIsoMap;
  Done := True;
end;

constructor TForm1.Create(AOwner: TComponent);
begin
  inherited;
  InitGL;
  FIsoMap := TOpenGLIsoMap.Create(Self);
  IsoMap.OnFlip := Flip;
  IsoMap.Width := ClientWidth;
  IsoMap.Height := ClientHeight;
  Application.OnIdle := AppIdle;

  IsoMap.LoadFromFile('campground.dxm');
end;

procedure TForm1.Flip(Sender: TObject);
begin
  SwapBuffers(DC);
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  IsoMap.Height := ClientHeight;
  IsoMap.Width := ClientWidth;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?