PDA

View Full Version : How to enable AntiAlias mode



Frozen_Elemental
10-03-2002, 10:58 PM
I need to enable AntiAlias such as
Supersample or Multisample mode
What i need to do, please give me an exmples.
Thank alots.

Cab
10-04-2002, 06:29 PM
You need to use WGL_ARB_Pixel_Format extension with WGL_ARB_Multisample.

You have it documented in this paper: http://developer.nvidia.com/view.asp?IO=ogl_multisample

and explained in this presentation: http://developer.nvidia.com/view.asp?IO=gdc_ogl_multisample

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.

Mazy
10-05-2002, 02:56 AM
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)

Cab
10-05-2002, 04:34 AM
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).]

Mreal
10-05-2002, 09:57 AM
Please tell mi what i have to do to antialiase polygons!!!

pbrown
10-08-2002, 05:46 AM
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,

WGL_NUMBER_PIXEL_FORMATS_ARB
The number of pixel formats for the device context. The
<iLayerPlane> and <iPixelFormat> parameters are ignored 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. ]]

Then,

An error is generated if <piAttributes> contains an invalid
attribute, if <iPixelFormat> is not a positive integer or is larger
than the number of pixel formats, if <iLayerPlane> doesn't refer to
an existing layer plane, or if <hdc> 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).]

Frozen_Elemental
10-11-2002, 12:17 AM
I tried wglChoosePixelFormat and SetPixelFormat from NVIDIA docuemnt but no effect, Anything dosnt antialias ... T_T

dorbie
10-11-2002, 08:22 AM
Make sure you have application preference set in the drivers for antialiasing in the OpenGL advanced display settings dialog.

Frozen_Elemental
10-11-2002, 07:23 PM
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.dwFlags := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
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
Begin
GLRC := wglCreateContext(PxLstDC);
wglMakeCurrent(PxLstDC, GLRC);
wglGetExtensionsStringARB := wglGetProcAddress('wglGetExtensionsStringARB');

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

wglMakeCurrent(0, 0);
wglDeleteContext(GLRC);
{ Enable All Feature including MultiSample }
If @wglChoosePixelFormatARB <> nil then
Begin
wglMakeCurrent(0, 0);
wglDeleteContext(GLRC);

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 > 0 then
Begin
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);
end;
IAttrib[FormatCnt].Format := 0; IAttrib[FormatCnt].Data := 0; Inc(FormatCnt);

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

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

NitroGL
10-12-2002, 10:59 AM
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: http://evilman.netfirms.com/base.zip
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).]

pbrown
10-12-2002, 01:30 PM
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.

Frozen_Elemental
10-12-2002, 09:44 PM
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.
^_^

Mazy
10-13-2002, 04:49 AM
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.