- unit Gpspath;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ExtCtrls, OpenGl, Glut, StdCtrls;
- type
- TForm1 = class(TForm)
- Image1: TImage;
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure FormPaint(Sender: TObject);
- private
- { Private-Deklarationen }
- GLContext : HGLRC;
- public
- { Public-Deklarationen }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.FormCreate(Sender: TObject);
- var pfd : TPixelformatdescriptor;
- formatindex : integer;
- begin
- fillchar(pfd, Sizeof(pfd),0);
- with pfd do begin
- nSize := SizeOf(pfd);
- nVersion := 1;
- dwFlags := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL;
- iPixelType := PFD_TYPE_RGBA;
- cColorBits := 24;
- CDepthBits := 32;
- iLayertype := PFD_MAIN_PLANE;
- end;
- formatindex := Choosepixelformat(image1.canvas.handle,@pfd);
- Setpixelformat(image1.canvas.Handle,Formatindex,@pfd);
- GLContext := wglCreateContext(image1.canvas.handle);
- wglMakeCurrent(image1.canvas.Handle,GLContext);
- end;
- procedure TForm1.FormDestroy(Sender: TObject);
- begin
- wglMakeCurrent(image1.canvas.handle,0);
- wglDeleteContext(GLContext);
- end;
- procedure TForm1.FormPaint(Sender: TObject);
- var error : GLint;
- begin
- glClearColor(1.0,1.0,0.0,0.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- error := glgeterror;
- if error<>GL_NO_ERROR then
- raise Exception.Create('Error in Paint'#13+gluErrorString(error));
- end;
- end.