- procedure TForm1.FormCreate(Sender: TObject);
- function GetAAPixelformat(var pf: Integer): Boolean;
- procedure PostError();
- var e: Integer;
- begin
- e := glGetError;
- if e<>GL_NO_ERROR then
- Memo1.Lines.Add(gluErrorString(e));
- end;
- const MAX_PFS = 20;
- var
- tmpForm: TForm;
- multiARB, multiEXT: Boolean;
- IAttribs: Array[0..18] of Integer;
- FAttribs: Array[0..0] of Single;
- PossiblePFs: Array[0..MAX_PFS] of Integer;
- PFcount, QueryAttrib: Integer;
- tmpDC, oldDC: HGLRC;
- tmpRC, oldRC: HGLRC;
- i: Integer;
- PFSampleCount: Array[0..MAX_PFS] of Integer;
- begin
- Result := False;
- oldDC := wglGetCurrentDC;
- oldRC := wglGetCurrentContext;
- tmpForm := TForm.Create(nil);
- tmpDC := GetDC(tmpForm.Handle);
- tmpRC := CreateRenderingContext(tmpDC, [opDoubleBuffered], 32, 24, 0,0,0, 0);
- if (tmpRC=0) then
- begin
- PostError;
- tmpForm.Free;
- Exit;
- end;
- ActivateRenderingContext(tmpDC, tmpRC);
- multiARB := WGL_ARB_extensions_string and
- WGL_ARB_pixel_format and
- (WGL_ARB_MULTISAMPLE or GL_ARB_MULTISAMPLE);
- multiEXT := WGL_EXT_extensions_string and
- WGL_EXT_pixel_format and
- (WGL_EXT_MULTISAMPLE or GL_EXT_MULTISAMPLE);
- if not (multiARB or multiEXT) then
- begin
- tmpForm.Free;
- DestroyRenderingContext(tmpRC);
- Exit;
- end;
- if multiARB then
- begin
- Read_WGL_ARB_pixel_format;
- multiEXT := False;
- end
- else
- Read_WGL_EXT_pixel_format;
- PostError;
- IAttribs[0] := WGL_DRAW_TO_WINDOW_EXT;
- IAttribs[1] := 1;
- IAttribs[2] := WGL_SUPPORT_GDI_ARB;
- IAttribs[3] := 1;
- IAttribs[4] := WGL_DOUBLE_BUFFER_ARB;
- IAttribs[5] := 1;
- IAttribs[6] := WGL_PIXEL_TYPE_ARB;
- IAttribs[7] := WGL_TYPE_RGBA_ARB;
- IAttribs[8] := WGL_COLOR_BITS_ARB;
- IAttribs[9] := 32;
- IAttribs[10] := WGL_ALPHA_BITS_ARB;
- IAttribs[11] := 0;
- IAttribs[12] := WGL_DEPTH_BITS_ARB;
- IAttribs[13] := 24;
- IAttribs[14] := WGL_STENCIL_BITS_ARB;
- IAttribs[15] := 0;
- IAttribs[16] := WGL_SAMPLE_BUFFERS_ARB;
- IAttribs[17] := 1;
- IAttribs[18] := 0;
- FAttribs[0] := 0;
- if multiARB then
- wglChoosePixelFormatARB(tmpDC, @IAttribs[0], @FAttribs[0], MAX_PFS, @PossiblePFs[0], @PFcount)
- else
- wglChoosePixelFormatEXT(tmpDC, @IAttribs[0], @FAttribs[0], MAX_PFS, @PossiblePFs[0], @PFcount);
- PostError;
- if PFcount>MAX_PFS then
- PFcount := MAX_PFS;
- QueryAttrib := WGL_SAMPLES_ARB;
- if multiARB then
- begin
- for i := 0 to PFcount-1 do
- wglGetPixelFormatAttribivARB(tmpDC, PossiblePFs[i], 0, 1, @QueryAttrib, @PFSampleCount[i]);
- end
- else
- for i := 0 to PFcount-1 do
- wglGetPixelFormatAttribivEXT(tmpDC, PossiblePFs[i], 0, 1, @QueryAttrib, @PFSampleCount[i]);
- PostError;
- tmpForm.Free;
- DestroyRenderingContext(tmpRC);
- ReleaseDC(tmpForm.Handle, tmpDC);
- Result := True;
- Memo1.Clear;
- for i := 0 to PFcount-1 do
- Memo1.Lines.Add(IntToStr(possiblepfs[i])+'->'+IntToStr(pfsamplecount[i]));
- end;
- var pf: Integer;
- begin
- if not InitOpenGL() then
- Application.Terminate;
- GetAAPixelFormat(pf);
- end;