Polygon Antialiased

Hi, I’m trying to use the polygon antialiasing but it doesn’t seem to work

I’used all of these:

1:
glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
2:
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_MULTISAMPLE_ARB);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST)
3:
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_MULTISAMPLE_ARB);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST);

but it doesn’t give antialiasing results

Can someone please help me on this?
thks

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=46

According to this, you need specific rendering context.

What is your video card? To have a multisample framebuffer, you need at least to tell the “window api” (glX glut SDL …) that you want that. For example with SDL:

 

...
  SDL_GL_SetAttribute( SDL_GL_SDL_GL_MULTISAMPLEBUFFERS, 1 );
  SDL_GL_SetAttribute( SDL_GL_SDL_GL_MULTISAMPLESAMPLES, 8 );
...


Or,the easiest way to have a multisample buffer, change the settings of your video card driver to force multisampling for all OpenGL application (AMD video card => via catalyst control center).

I never used GL_POLYGON_SMOOTH because on very old hardware ( NVidia TnT2) it was really slow so maybe another people will tell.

Old style antialiasing with the GL_*_SMOOTH need blending to be enabled.
http://glprogramming.com/red/chapter06.html#name2

New style AA with MULTISAMPLE need a specific rendering context, as explained by the 2 posts above.

Both AA styles can NOT be used at the same time.

Yes I’ve read that page and this is what I’m using:

CreateViewport(Value, GLWidth^, GLHeight^);
CreateViewer(0, 0);
ColorDS(1, 1, 1, 1);

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_ALWAYS, 0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel(GL_SMOOTH);
glClearColor(0, 0, 0, 0);
glClearDepth(1);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_MULTISAMPLE_ARB);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity;

I’m using alpha blend but it still doesn’t give me antialias

what is the best way to get that then, GL_POLYGON_SMOOTH or GL_MULTISAMPLE_ARB?

I’m using an ATI Radeon HD 4600

thks

Thanks and how can I use SDL? Is it a funcionality of OpenGL?

thks

glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_MULTISAMPLE_ARB);

First, you don’t use both polygon smoothing and multisampling; you use one or the other.

Second, you have to create a multisampled framebuffer, either manually with FBOs, or using whatever you use to create your window to ask for a multisampled framebuffer.

Sure, but if I use only these two:

glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);

Shouldn’t it be antialiased?
or is it the same than multisampling and do I need to set it in another way?

is there any example that really works because I’ve found many that didn’t work across the net

thks again

Shouldn’t it be antialiased?

Did you also turn on blending? Did you also z-sort your triangles from farthest to nearest? Because if you don’t do both of those, you won’t get any “antialiasing”.

is there any example that really works because I’ve found many that didn’t work across the net

Examples of which, multisampling, or polygon smoothing?

This is what I’m using:

  • glEnable(GL_ALPHA_TEST);
  • glAlphaFunc(GL_ALWAYS, 0);
  • glEnable(GL_BLEND);
  • glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  • glShadeModel(GL_SMOOTH);
  • glEnable(GL_DEPTH_TEST);
  • glDepthFunc(GL_LEQUAL);
  • glEnable(GL_POLYGON_SMOOTH);
  • glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);

even with blending enabled it wont give me any antialising, and I only have one object with 4 vertices to render on a black background, shoudn’t it be smooth?

An Example for GL_POLYGON_SMOOTH or the one that is easier to use

thks again

AFAICT, it doesn’t seem to be supported in recent hardware. It’s hard to find any details on when they were dropped. But here’s a couple of links I found:

http://www.opengl.org/wiki/Common_Mistak…LYGON_SMOOTH.29
http://lists.apple.com/archives/mac-opengl/2007/Aug/msg00020.html

Can’t find any NVidia/ATI confirmation of these though, but it doesn’t appear to work on my Geforce 9500GT, or ATI Mobility Radeon HD 5650.

Another thing that could potentially affect it (although unlikely), is that if you do have hardware that supports it, the spec says:

Thanks again for all the time, but it seems to hard to use it in my code, I thought it was simpler and just need to call a function for polygon smooth
I’ve tried to read all the articles but most of them didn’t wotk and the otheres were to hard to implement

But I know that my graphics card have antialiasing because of another library that uses opengl wich can make it at 2 and 4 times

It’s harder to implement multi-sampling initially, due to WGL being a pain, but all you need to do once it’s set up, is enable/disable GL_MULTISAMPLE, whereas GL_POLYGON_SMOOTH requires further sorting etc of your scene objects.

If you’re using an OpenGL helper library, it’s typically just a case of setting a couple of properties at context creation time, but if you choose to do it yourself, you will need to do something like this in MS Windows (since you are only allowed to call SetPixelFormat once for a window):

  1. Create temporary window
  2. Choose/Set OpenGL compatible pixel format
  3. Create temporary context + make current
  4. Retrieve OpenGL extensions used for context creation/multisampling
  5. Choose/Set a multisampled pixel format for your actual window using OpenGL extensions (http://www.opengl.org/registry/specs/ARB/wgl_pixel_format.txt + http://www.opengl.org/registry/specs/ARB/multisample.txt)
  6. Create context for your actual window using OpenGL extension (http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt) if it’s available, or wglCreateContext otherwise
  7. Delete temporary context (or keep it around for further use)
  8. Delete temporary window (or keep it around for further use)
  9. Use your actual context to retrieve any extensions you need for rendering
  10. Render using actual context

The lesson that S1ngular mentioned: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=46 shows how to do this in various programming languages/IDEs

Ha, But wich var do I need to set it up in the pixelformat?

but even that, I’ve used the nehe.gamedev.net examples for c and delphi and it didn’t worked with antialiasing, is it from my graphics card?

Image of the example:

Can someone please help me? I realy need this

is there a simple example of ARB_MULTISAMPLE that really works? in c or anohter language?

thks

Well, the Delphi version has a bug, it should be:


valid := wglChoosePixelFormatARB(h_dc,@iattributes[0],@fattributes[0],1,@pixelFormat,@numFormats);

instead of:


valid := wglChoosePixelFormatARB(h_dc,@iattributes,@fattributes,1,@pixelFormat,@numFormats);

Also, it’s usually possible to override multisample settings in your graphics card driver control panel. If the multisample demo is having no effect, check these settings. Usually there are options to force it on/off or let applications decide.