- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //ermittelt alle Pixelformate, die MultiSampling unterstützen
- //@aFormatSettings: Settings des Pixelformats;
- //@PFList: Liste in die die Pixelformate geschieben werden;
- //@SampleList: Liste in die die SampleRate passend zum Pixelformat geschrieben wird;
- //@MaxCount: Maximale Länge der übergebenen Listen;
- //@Count: Anzahl der gefundenen Pixelformate in der Liste;
- //@result: TRUE wenn erfolgreich, sonst FALSE;
- function gluGetAntiAliasingPixelFormats(const aFormatSettings: TgluPixelFormatSettings; PFList, SampleList: PglInt; const MaxCount: Integer; var Count: Integer): Boolean;
- var
- //temporäres Fenster zum erzeugen des RC
- Form: TForm;
- //ARB_Erweiterung vorhanden
- //| EXT_Erweiterung vorhanden
- MultiARBSup, MultiEXTSup: Boolean;
- //Liste der Integer Attribute
- IAttrib: array[0..22] of Integer;
- //Liste der Float Attribute (nur 0, da kein Wert)
- FAttrib: GLFloat;
- //temp. PixelFormat
- //| Schleifenvariable
- //| | AttributName
- PF, i, QueryAtrib: Integer;
- //Zeiger auf zum hochzählen ni der Liste
- PPosiblePF, PSample: PglInt;
- //temp. RenderKontext
- //| RenderContext, der zurvor aktiviert war
- RC, OldRC: TgluRenderContext;
- begin
- result := false;
- OldRC.DC := wglGetCurrentDC;
- OldRC.RC := wglGetCurrentContext;
- Form := TForm.Create(nil);
- PF := gluGetPixelFormat(Form.Handle, aFormatSettings);
- RC := gluCreateRenderContext(Form.Handle, PF);
- if RC.RC = 0 then begin
- Form.Free;
- if (OldRC.DC <> 0) and (OldRC.RC <> 0) then
- gluActivateRenderContext(OldRC);
- gluLastError := GLU_ERROR_INVALID_RC;
- exit;
- end;
- if not gluActivateRenderContext(RC) then begin
- Form.Free;
- gluDestroyRenderContext(RC);
- if (OldRC.DC <> 0) and (OldRC.RC <> 0) then
- gluActivateRenderContext(OldRC);
- gluLastError := GLU_ERROR_ACTIVATE_RC;
- exit;
- end;
- //Pixelformate mit AA auslesen
- MultiARBSup := false;
- MultiEXTSup := false;
- if WGL_ARB_extensions_string and
- WGL_ARB_pixel_format and
- (WGL_ARB_MULTISAMPLE or GL_ARB_MULTISAMPLE) then
- multiARBSup := true;
- if WGL_EXT_extensions_string and
- WGL_EXT_pixel_format and
- (WGL_EXT_MULTISAMPLE or GL_EXT_MULTISAMPLE) then
- multiEXTSup := true;
- if multiARBSup then
- Read_WGL_ARB_pixel_format
- else if multiEXTSup then
- Read_WGL_EXT_pixel_format;
- if not (MultiARBSup or MultiEXTSup) then begin
- Form.Free;
- gluDestroyRenderContext(RC);
- if (OldRC.DC <> 0) and (OldRC.RC <> 0) then
- gluActivateRenderContext(OldRC);
- gluLastError := GLU_ERROR_AA_NOT_SUPPORTED;
- end;
- IAttrib[00] := WGL_DRAW_TO_WINDOW_ARB;
- IAttrib[01] := 1;
- IAttrib[02] := WGL_SUPPORT_OPENGL_ARB;
- IAttrib[03] := 1;
- IAttrib[04] := WGL_DOUBLE_BUFFER_ARB;
- if (opDoubleBuffered in aFormatSettings.Options) then
- IAttrib[05] := 1
- else
- IAttrib[05] := 0;
- IAttrib[06] := WGL_PIXEL_TYPE_ARB;
- IAttrib[07] := WGL_TYPE_RGBA_ARB;
- IAttrib[08] := WGL_COLOR_BITS_ARB;
- IAttrib[09] := aFormatSettings.ColorBits;
- IAttrib[10] := WGL_ALPHA_BITS_ARB;
- IAttrib[11] := aFormatSettings.AlphaBits;
- IAttrib[12] := WGL_DEPTH_BITS_ARB;
- IAttrib[13] := aFormatSettings.DepthBits;
- IAttrib[14] := WGL_STENCIL_BITS_ARB;
- IAttrib[15] := aFormatSettings.StencilBits;
- IAttrib[16] := WGL_ACCUM_BITS_ARB;
- IAttrib[17] := aFormatSettings.AccumBits;
- IAttrib[18] := WGL_AUX_BUFFERS_ARB;
- IAttrib[19] := aFormatSettings.AuxBuffers;
- IAttrib[20] := WGL_SAMPLE_BUFFERS_ARB;
- IAttrib[21] := 1;
- IAttrib[22] := 0;
- FAttrib := 0;
- if multiARBSup then
- wglChoosePixelFormatARB(RC.DC, @IAttrib, @FAttrib, MaxCount, PFList, @Count)
- else if multiEXTSup then
- wglChoosePixelFormatEXT(RC.DC, @IAttrib, @FAttrib, MaxCount, PFList, @Count);
- if Count > MaxCount then
- Count := MaxCount;
- QueryAtrib := WGL_SAMPLES_ARB;
- PSample := SampleList;
- PPosiblePF := PFList;
- for i := 0 to Count-1 do begin
- if multiARBSup then
- wglGetPixelFormatAttribivARB(RC.DC, PPosiblePF^, 0, 1, @QueryAtrib, PSample)
- else if multiEXTSup then
- wglGetPixelFormatAttribivEXT(RC.DC, PPosiblePF^, 0, 1, @QueryAtrib, PSample);
- inc(PSample);
- inc(PPosiblePF);
- end;
- if not gluDestroyRenderContext(RC) then begin
- Form.Free;
- exit;
- end;
- Form.Free;
- if (OldRC.DC <> 0) and (OldRC.RC <> 0) then
- if not gluActivateRenderContext(OldRC) then
- exit;
- result := True;
- end;