How to enable AntiAlias mode

I need to enable AntiAlias such as
Supersample or Multisample mode
What i need to do, please give me an exmples.
Thank alots.

You need to use WGL_ARB_Pixel_Format extension with WGL_ARB_Multisample.

You have it documented in this paper:

and explained in this presentation:

In lastest nVidia drivers (40.71 & 40.72) WGL_ARB_Pixel_Format is not working properly to me. I don’t know if anyone else has noticed it or it is something of my system. In previous drivers it was working ok.

Hope this helps.

Thanks man.

I thought that it was my fault… but i have experienced the same!

(even nVidias PisxelFomat demo fails… but i thought that i had some other error amongst all the dll:s)

Originally posted by Mazy:
(even nVidias PisxelFomat demo fails… but i thought that i had some other error amongst all the dll:s)

Yes, I noticed it. I sent it to nVidia more than one week ago. Again, I have sent it today to one of its developer relations.

[This message has been edited by Cab (edited 10-05-2002).]

Please tell mi what i have to do to antialiase polygons!!!

About recent 40.7X drivers and WGL_ARB_pixel_format: I was able to reproduce the problem with the NVIDIA pixel format demo last night. The problem appears to be due to an initial call to determine the number of pixel formats supported, which returns zero.

That call passes in a pixel format index of zero, which is never a valid pixel format (indices start at one). The 40.7X drivers reject the index.

The spec itself is self-contradictory. First,

    The number of pixel formats for the device context. The
    <iLayerPlane> and [b] <iPixelFormat> parameters are ignored [/b] if this
    attribute is specified.

[[ The language here isn’t quite right – <iPixelFormat> should be ignored only for the purposes of querying this single attribute value. It obviously can’t be ignored if you query just about anything else at the same time. ]]


[b] An error is generated [/b] if &lt;piAttributes&gt; contains an invalid
attribute, [b] if &lt;iPixelFormat&gt; is not a positive integer [/b] or is larger
than the number of pixel formats, if &lt;iLayerPlane&gt; doesn't refer to
an existing layer plane, or if &lt;hdc&gt; is invalid.

My take is that according to the spec, such a call should be an error. In any event, we are planning to “fix” the driver.

[This message has been edited by pbrown (edited 10-08-2002).]

I tried wglChoosePixelFormat and SetPixelFormat from NVIDIA docuemnt but no effect, Anything dosnt antialias … T_T

Make sure you have application preference set in the drivers for antialiasing in the OpenGL advanced display settings dialog.

My code write in delphi 5
First SetPixelFormat is OK
acceptable mode (No AntiAlias)
but after wglChoosePixelFormat and
get an AntiAlias mode but
Second SetPixelFormat isnt work.
What should i do ? … Thanks everybody

 DC := GetDC(Handle);
 ZeroMemory(@PixelFormat, Sizeof(PixelFormat));
 PixelFormat.nSize := Sizeof(PixelFormat);
 PixelFormat.nVersion := 1;
 PixelFormat.iPixelType := PFD_TYPE_RGBA;
 PixelFormat.cColorBits := 32;
 PixelFormat.cDepthBits := 16;
 PixelFormat.cStencilBits := 16;
 PixelFormat.iLayerType := PFD_OVERLAY_PLANE;

 DefPxlFmt := Windows.ChoosePixelFormat(DC, @PixelFormat);

 If SetPixelFormat(DC, DefPxlFmt, @PixelFormat) then
       GLRC := wglCreateContext(PxLstDC);
       wglMakeCurrent(PxLstDC, GLRC);
       wglGetExtensionsStringARB := wglGetProcAddress('wglGetExtensionsStringARB');

       wglChoosePixelFormatARB := wglGetProcAddress('wglChoosePixelFormatARB');
       glSampleCoverageARB := wglGetProcAddress('glSampleCoverageARB');

       wglMakeCurrent(0, 0);
 { Enable All Feature including MultiSample }
 If @wglChoosePixelFormatARB &lt;&gt; nil then
       wglMakeCurrent(0, 0);

       FormatCnt := 0;
       ZeroMemory(@IAttrib, Sizeof(IAttrib));
       ZeroMemory(@FAttrib, Sizeof(FAttrib));
       IAttrib[FormatCnt].Format := WGL_DRAW_TO_WINDOW_ARB; IAttrib[FormatCnt].Data := GL_TRUE;                    Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_SUPPORT_OPENGL_ARB; IAttrib[FormatCnt].Data := GL_TRUE;                    Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_ACCELERATION_ARB;   IAttrib[FormatCnt].Data := WGL_FULL_ACCELERATION_ARB;  Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_DOUBLE_BUFFER_ARB;  IAttrib[FormatCnt].Data := GL_TRUE;                    Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_COLOR_BITS_ARB;     IAttrib[FormatCnt].Data := ColorBits;                  Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_ALPHA_BITS_ARB;     IAttrib[FormatCnt].Data := AlphaBits;                  Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_DEPTH_BITS_ARB;     IAttrib[FormatCnt].Data := DepthBits;                  Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_STENCIL_BITS_ARB;   IAttrib[FormatCnt].Data := StencilBits;                Inc(FormatCnt);
       If MultiSamples &gt; 0 then
             IAttrib[FormatCnt].Format := WGL_SAMPLE_BUFFERS_ARB; IAttrib[FormatCnt].Data := GL_TRUE;                    Inc(FormatCnt);
             IAttrib[FormatCnt].Format := WGL_SAMPLES_ARB;        IAttrib[FormatCnt].Data := MultiSamples;               Inc(FormatCnt);
       IAttrib[FormatCnt].Format := 0;                      IAttrib[FormatCnt].Data := 0;                          Inc(FormatCnt);

       wglChoosePixelFormatARB(DC, @IAttrib, @FAttrib, 1, @PixelFormatType, @FormatCnt);

       If SetPixelFormat(DC, PixelFormatType, nil) then
             GLRC := wglCreateContext(DC);
             wglMakeCurrent(DC, GLRC);

That won’t work, as I’ve found out recently. You have to make a temp window with it’s own separate handles (HDC, HRC and HWND), because when you create a context it isn’t completely destroyed until you kill the window.

If you want, take a look at my source:
It’s in C, but it should give you the general idea (it probably isn’t the best way to do it, but it does work).

[This message has been edited by NitroGL (edited 10-12-2002).]

wglGetProcAddress() calls need to have a current GC. And that current GC has to be for a hardware-accelerated pixel format. Otherwise, you will get NULL function pointers. So the usual approach is to create a dummy window/context, get all the information you need, and then destroy them.

This is very lame. But wglGetProcAddress() was created without considering the possibility of a WGL extension.

But considering the alternative (not having any way to get at this information), I’d happy to create the dummy window.

Yes… I done it.
Create a form and setpixelformat temporary
and destroy it, then wglChoosePixelFormat
and setpixelformat the main form. It’s work

Thank everybody and the examples.

Originally posted by pbrown:

My take is that according to the spec, such a call should be an error. In any event, we are planning to “fix” the driver.

[This message has been edited by pbrown (edited 10-08-2002).][/b]

Please dont… if the spec says that we should start with 1 then let your drivers report an error when we wrongfully sets it to 0, else we have different behaivor on different cards, and the debugging might be a hell.

it’s better that we fix this in the programs instead.