Kolejny problem
Chciałbym uruchomić w Delphi przykład opisany na stronie nehe
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=46
Przykład wykorzystania WGL_ARB_multisample
Testowałem na Delphi 2006 i 2010 ale wyniki są podobne i aliasingu nie ma po kompilacji programu
Jeżeli uruchomię EXE kompilowane w Visual C++ to aliasing widać :)
Szukając przyczyn znalazłem miejsce w kodzie funkcję wglChoosePixelFormatARB
która powinna zwrócić numFormats w postaci liczby większej od ZERO a zwraca zero :(
Gdzie mozna znaleźć opis do funkcji wglChoosePixelFormatARB ,
i co moze byc przyczyna takiego stanu ?
Kod C i Delphi wydaja sie bardzo podobne
Jak ewentualnie można inaczej poprawić krawędzie obrazu ?
Modyfikacja I)
komilowałem projekt w wersji Visual C++ i tam
wglChoosePixelFormatARB zwraca
pixelFormat = 32
numFormats = 12
w delphi jest
pixelFormat = 0
numFormats = 0
Parametry wejsciowe funkcji identyczne oprócz hDC ;)
// These Attributes Are The Bits We Want To Test For In Our Sample
// Everything Is Pretty Standard, The Only One We Want To
// Really Focus On Is The SAMPLE BUFFERS ARB And WGL SAMPLES
// These Two Are Going To Do The Main Testing For Whether Or Not
// We Support Multisampling On This Hardware
int iAttributes[] = { WGL_DRAW_TO_WINDOW_ARB,GL_TRUE,
WGL_SUPPORT_OPENGL_ARB,GL_TRUE,
WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
WGL_COLOR_BITS_ARB,24,
WGL_ALPHA_BITS_ARB,8,
WGL_DEPTH_BITS_ARB,16,
WGL_STENCIL_BITS_ARB,0,
WGL_DOUBLE_BUFFER_ARB,GL_TRUE,
WGL_SAMPLE_BUFFERS_ARB,GL_TRUE,
WGL_SAMPLES_ARB, 4 , // Check For 4x Multisampling
0,0};
// First We Check To See If We Can Get A Pixel Format For 4 Samples
valid = wglChoosePixelFormatARB(hDC,iAttributes,fAttributes,1,&pixelFormat,&numFormats);
// if We Returned True, And Our Format Count Is Greater Than 1
if (valid && numFormats >= 1)
{
arbMultisampleSupported = true;
arbMultisampleFormat = pixelFormat;
return arbMultisampleSupported;
}
SetLength(iAttributes,22);
iAttributes[0] := WGL_DRAW_TO_WINDOW_ARB;
iAttributes[1] := 1;
iAttributes[2] := WGL_SUPPORT_OPENGL_ARB;
iAttributes[3] := 1;
iAttributes[4] := WGL_ACCELERATION_ARB;
iAttributes[5] := WGL_FULL_ACCELERATION_ARB;
iAttributes[6] := WGL_COLOR_BITS_ARB;
iAttributes[7] := 24;
iAttributes[8] := WGL_ALPHA_BITS_ARB;
iAttributes[9] := 8;
iAttributes[10] := WGL_DEPTH_BITS_ARB;
iAttributes[11] := 16;
iAttributes[12] := WGL_STENCIL_BITS_ARB;
iAttributes[13] := 0;
iAttributes[14] := WGL_DOUBLE_BUFFER_ARB;
iAttributes[15] := 1;
iAttributes[16] := WGL_SAMPLE_BUFFERS_ARB;
iAttributes[17] := 1;
iAttributes[18] := WGL_SAMPLES_ARB;
iAttributes[19] := 4;
iAttributes[20] := 0;
iAttributes[21] := 0;
valid := wglChoosePixelFormatARB(h_dc,@iattributes,@fattributes,1,@pixelFormat,@numFormats);
if valid and (numFormats >= 1) then // Vráceno true a počet formátů je větší než jedna
begin
arbMultisampleSupported := true;
arbMultisampleFormat := pixelFormat;
Result := arbMultisampleSupported;
SetLength(fAttributes,0);
SetLength(iAttributes,0);
exit;
end;