iDevGames Forums
Before the drawing - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Before the drawing (/thread-7984.html)



Before the drawing - Miglu - Aug 12, 2010 07:51 PM

Could you explain why antialiasing a polygon does not work even though this method is called before the drawing.

Code:
- (void) prepareOpenGL
{
    glClearColor(0, 0, 0, 0);

    GLint vblSynch = 1;
    [[self openGLContext] setValues:&vblSynch forParameter:NSOpenGLCPSwapInterval];

    [self setupAnimationTimerWithInterval:(1.0f/60.0f)];

    [super prepareOpenGL];
    glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
    glEnable(GL_BLEND);
    glEnable(GL_POLYGON_SMOOTH);
    glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
}



RE: Before the drawing - Skorche - Aug 13, 2010 08:53 AM

Anti-aliased primitives are not always supported in OpenGL drivers. Sometimes you get anti-aliased points and lines, but anti-aliased polygons are a rarely supported feature IIRC.


RE: Before the drawing - Miglu - Aug 13, 2010 10:50 AM

You are right, as when
Code:
    glPolygonMode(GL_FRONT, GL_LINE);
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
is used, antialiasing works. How can I antialias filled polygons if it is not supported on Macs?


RE: Before the drawing - Skorche - Aug 13, 2010 01:45 PM

Arekusu had an old article about this very thing: http://homepage.mac.com/arekkusu/bugs/invariance/

He'll probably chime in with more.


RE: Before the drawing - arekkusu - Aug 13, 2010 04:05 PM

Can you explain why you want to antialias a polygon?

Or what type of polygon, or how many polygons?

GL_POLYGON_SMOOTH was only a good solution for certain types of scenes. There are alternate ways to antialias but they all have tradeoffs, so you'll have to describe what you're trying to do if you want a good answer.


RE: Before the drawing - Miglu - Aug 13, 2010 04:08 PM

I want to antialias a single circle that is moving. The reason is the obvious one: it looks better.


RE: Before the drawing - Skorche - Aug 13, 2010 04:36 PM

Draw a quad with a mipmapped circle texture on it.


RE: Before the drawing - skyhawk - Aug 13, 2010 05:47 PM

(Aug 13, 2010 04:36 PM)Skorche Wrote:  Draw a quad with a mipmapped circle texture on it.

but what if he wants to to be crisp and smooth on those brand new 4096 x 3072 displays that better be coming out soon?

Skorche is right though for most applications. If your point is to draw a circle that looks pretty, the choices are GLprimitives or a texture. Texture will allow a crisper bitmapped look (while ultimately letting you to add animation and other effects).

Alternatively, for a circle, I recommend not using polygon and instead use triangle strip or triangle fan.

And lastly: I recommend you don't even bother at all. In learning game programming, the knowledge of graphics will come in time, but I wouldn't bother with the "making it pretty" until you can "make it work".

Not saying you shouldn't ask these questions, but they will not get you as far as others you should be asking.


RE: Before the drawing - Skorche - Aug 14, 2010 10:25 AM

(Aug 13, 2010 05:47 PM)skyhawk Wrote:  but what if he wants to to be crisp and smooth on those brand new 4096 x 3072 displays that better be coming out soon?

It might seem a bit silly, but it's not like a 1024x1024 texture takes up that much VRAM if you really wanted a big circle. You can also effectively double the resolution by splitting it into 4 quads putting a 1/4 pie shaped piece into the texture.

You could also probably write a shader to make an AA circle. I've seen a couple GLSL examples that used the screenspace partial derivatives and smoothstep function to anti-alias. Not sure how widely supported the parts to do that in hardware is though.


RE: Before the drawing - OneSadCookie - Aug 14, 2010 04:11 PM

You don't even need to split the quads, you can use the MIRRORED_REPEAT extension.

The GLSL technique should work on everything that supports GLSL AFAIK (back about 5 or 6 years).