最近开发一个工作上需要的地图引擎。想使用opengl离线渲染。网上查找资料,实现如下。
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
windows,Classes, SysUtils, Forms, Controls,Graphics, Dialogs, Buttons,
GDIPAPI,GDIPOBJ,GDIPUTIL,StdCtrls, ExtCtrls ,gl,glu;
type
{ TForm1 }
TForm1 = class(TForm)
//MyglTextures:TglTexture;
procedure FormClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
// glbox:tOpenGLControl;
public
glmap:Tbitmap;
Bmp,BmpOld : HBITMAP;
procedure Draw;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
procedure TForm1.FormCreate(Sender: TObject);
const
pfd:TPIXELFORMATDESCRIPTOR = (
nSize:sizeof(TPIXELFORMATDESCRIPTOR); // size
nVersion:1; // version
dwFlags:PFD_DRAW_TO_BITMAP or PFD_SUPPORT_OPENGL; // support double-buffering
iPixelType:PFD_TYPE_RGBA; // color type
cColorBits:32; // preferred color depth
c