PDA

View Full Version : OpenGL and Multisample



M109uk
27-04-2007, 09:55 PM
Hi all,

Yet more problems (as such)...

Originally i was using SDL, however due to several non-ending problems with SDL, OpenGL and multisampling (using dglOpenGL and GL.pas, GLU.pas, etc) i decided to not use it and use win32 instead, however the appearence is very different, in SDL the view was nice & smooth, how ever now it is big and chunky.. does anyone know how SDL creates the contexts etc?

Secondly, im having problems setting up multisampling... my card does support it (i have checked via GLView, its a fairly new card and i have used programs that had multisampling), it passes all the checks to see if it is supported, but when i go to create the PixelFormat, i get the result true, but i get the number of formats and the pixelformat back as 0.

The code is:

function InitializeMultiSample: Boolean;
var
pFormat: Integer;
valid: Boolean;
nFormats: UInt;
fAttrib: Array Of Single;
iAttrib: Array Of Integer;
begin
Result := False;
If Not GL_ARB_MULTISAMPLE Then Exit;
If Not Assigned(wglChoosePixelFormatARB) Then Exit;

SetLength(fAttrib, 2);
fAttrib[0] := 0;
fAttrib[1] := 0;

SetLength(iAttrib, 22);
iAttrib[0] := WGL_DRAW_TO_WINDOW_ARB;
iAttrib[1] := 1;
iAttrib[2] := WGL_SUUPORT_OPENGL_ARB;
iAttrib[3] := 1;
iAttrib[4] := WGL_ACCELERATION_ARB;
iAttrib[5] := WGL_FULL_ACCELERATION_ARB;
iAttrib[6] := WGL_COLOR_BITS_ARB;
iAttrib[7] := 24;
iAttrib[8] := WGL_ALPHA_BITS_ARB;
iAttrib[9] := 8;
iAttrib[10] := WGL_DEPTH_BITS_ARB;
iAttrib[11] := 16;
iAttrib[12] := WGL_STENCIL_BITS_ARB;
iAttrib[13] := 0;
iAttrib[14] := WGL_DOUBLE_BUFFER_ARB;
iAttrib[15] := 1;
iAttrib[16] := WGL_SAMPLE_BUFFERS_ARB;
iAttrib[17] := 1;
iAttrib[18] := WGL_SAMPLES_ARB;
iAttrib[19] := 4;
iAttrib[20] := 0;
iAttrib[21] := 0;

valid := wglChoosePixelFormatARB(_hDC, @iAttrib, @fAttrib, 1, @pFormat, @nFormats);
If (valid) And (nFormats > 0) Then
Begin
Result := True;
Exit;
End;

iAttrib[19] := 2;
valid := wglChoosePixelFormatARB(_hDC, @iAttrib, @fAttrib, 1, @pFormat, @nFormats);
If (valid) And (nFormats > 0) Then
Begin
Result := True;
Exit;
End;
end;


I cant figure out why is would result in true but not return anything else, im using dglOpenGL.pas.

Thanks

JernejL
27-04-2007, 10:38 PM
Check out this article on NeHe about how to do multisampling (without SDL):
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=46

M109uk
27-04-2007, 10:43 PM
Yeah thats the original i tried, the C++ worked fine, except when i compiled the delphi version that didnt work either :s..

JernejL
27-04-2007, 10:45 PM
Yeah thats the original i tried, the C++ worked fine, except when i compiled the delphi version that didnt work either :s..

it's possible that the delphi translation is broken somehow. i think that www.sulaco.co.za has another multisampling example, i'll check it out since i'm not sure.

edit: just checked, it doesn't have any multisampling example.

M109uk
27-04-2007, 10:49 PM
Sulaco has a multisample example, but if i remember its not fullscreen... dont quote me though..

I thought it might be the translations, but if i try to use the GL units that come with Jedi-SDLv1 i get nothing at all, it wont load the extensions or anything (with and without SDL),

I have downloaded dglOpenGL.pas from their site 2 weeks ago, and i dont think they have any updates.

Are there any other better units around?

JernejL
28-04-2007, 11:54 AM
if the nehe delphi tutorial doesn't work, but C one does, you could check out why delphi one doesn't and so fix it.

M109uk
28-04-2007, 12:36 PM
In the end i tried again with SDL and after huge amounts of problems, i have managed to get it working now, i found that the reason it would'nt use multisampling in the end was because i was using a TPanels handle, when i took it out so that SDL created a window it worked.

Thanks for all your help :)