interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OpenGL12;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
****procedure*InitGL;*
****procedure*DrawScene;
****procedure*ApplicationEvents1Idle(Sender:*TObject;*var*Done:*Boolean);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
procedure*SetDCPixelFormat(
Handle:*HDC);
var
Form1: TForm1;
aDC:hDC;
**hRC:HGLRC;
implementation
{$R *.dfm}
procedure*SetDCPixelFormat(
Handle:*HDC);
**var
****nPixelFormat:*GLUint;
**const
****pfd:*PIXELFORMATDESCRIPTOR*=*(
********nSize:*sizeof(*PIXELFORMATDESCRIPTOR*);
********nVersion:*1;
********dwFlags:*PFD_DRAW_TO_WINDOW
********or*PFD_SUPPORT_OPENGL
********or*PFD_DOUBLEBUFFER;
********iPixelType:*PFD_TYPE_RGBA;
********cColorBits:*16;
********cRedBits:*0;
********cRedShift:*0;
********cGreenBits:*0;
********cBlueBits:*0;
********cBlueShift:*0;
********cAlphaBits:*0;
********cAlphaShift:*0;
********cAccumBits:*0;
********cAccumRedBits:*0;
********cAccumGreenBits:*0;
********cAccumBlueBits:*0;
********cAccumAlphaBits:*0;
********cDepthBits:*16;
********cStencilBits:*0;
********cAuxBuffers:*0;
********iLayerType:*PFD_MAIN_PLANE;
********bReserved:*0;
********dwLayerMask:*0;
********dwVisibleMask:*0;
********dwDamageMask:*0
****);
**begin
****nPixelFormat:=ChoosePixelFormat(aDC,*@pfd);
****SetPixelFormat(aDC,nPixelFormat,@pfd);
**end;
procedure*TForm1.InitGL;
begin
**glClearColor(0,0,0,0);
**glClearDepth(1);
**glDepthFunc(GL_LESS);
**glShadeModel(GL_SMOOTH);
**glEnable(GL_DEPTH_TEST);
**glViewport(0,0,Width,Height);
**glMatrixMode(GL_PROJECTION);
**glLoadIdentity;
**gluPerspective(45,Width/Height,1,100);
**glMatrixMode(GL_MODELVIEW);
end;
procedure*TForm1.DrawScene;
begin
**glClear(GL_COLOR_BUFFER_BIT*or*GL_DEPTH_BUFFER_BIT);
**glLoadIdentity;
**//Hier wird später die Scene gezeichnet.
**SwapBuffers(aDC);
end;
procedure*TForm1.ApplicationEvents1Idle(Sender:*TObject;
**var*Done:*Boolean);
begin
**DrawScene;
**Done:=False;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
InitOpenGL;
**aDC:=GetDC(
Handle);
**SetDCPixelFormat(aDC);
**hRC:=wglCreateContext(aDC);
**wglMakeCurrent(aDC,hRC);
end;
end.