1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85:
| unit WEST3;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, OPenGL, GLU, GL, ExtCtrls, StdCtrls;
type TForm3 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormPaint(Sender: TObject); private { Private-Deklarationen } hrc: HGLRC; procedure setdcpixelformat(Handle: HDC); public { Public-Deklarationen } end;
var Form3: TForm3; DC : HDC;
implementation
{$R *.DFM}
uses west1;
procedure TForm3.setdcpixelformat(Handle:HDC); var pfd : TPixelFormatDescriptor; npixelformat : 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; nPixelFormat:=choosePixelFormat(Handle,@pfd); setpixelformat(Handle,npixelformat,@pfd); end;
procedure DrawScene; begin glclear(GL_color_buffer_bit or gl_depth_buffer_bit); glbegin(gl_triangles); glcolor3f(1.0,0,0); glvertex2f(-0.5,-0.5); glcolor3f(0,1.0,0); glvertex2f(0.5,-0.5); glcolor3f(0,0,1.0); glvertex2f(0.0,0.5); glend; glflush(); //swapbuffers(DC) end;
procedure TForm3.FormCreate(Sender: TObject); begin // dc:=getdc(panel.handle); setdcpixelformat(canvas.handle); hrc:=wglcreatecontext(canvas.handle); end;
procedure TForm3.FormDestroy(Sender: TObject); begin wgldeletecontext(hrc);
end;
procedure TForm3.FormPaint(Sender: TObject); begin wglmakecurrent(canvas.handle,hrc); drawscene; wglmakecurrent(0,0);
end; |