font smoothing

  • Follow


i made a vector font in opengl, but it looks bad around the edges.

the standard anti-aliasing didn't cut it.  any ideas?

0
Reply bob136 (381) 11/6/2005 12:54:06 AM

bob@coolgroups.com wrote:
> i made a vector font in opengl, but it looks bad around the edges.
> 
> the standard anti-aliasing didn't cut it.  any ideas?
> 

Can you put a screenshot on a web site to show
the problem...?



-- 
<\___/>
/ O O \
\_____/  FTB.    For email, remove my socks.

In science it often happens that scientists say, 'You know
that's a really good argument; my position is mistaken,'
and then they actually change their minds and you never
hear that old view from them again.  They really do it.
It doesn't happen as often as it should, because scientists
are human and change is sometimes painful.  But it happens
every day.  I cannot recall the last time something like
that happened in politics or religion.

- Carl Sagan, 1987 CSICOP keynote address

0
Reply fungus 11/6/2005 2:29:59 AM


screenshot at http://www.coolgroups.com/fontdemoproblem.png

0
Reply bob 11/6/2005 4:13:17 AM

bob@coolgroups.com wrote:
> screenshot at http://www.coolgroups.com/fontdemoproblem.png
> 

I assume you're trying to turn on polygon antialiasing
with glEnable(GL_POLYGON_SMOOTH);

It looks to me like:

a) You haven't got any alpha bitplanes - check with
    glGetIntegerv(GL_ALPHA_BITS...);

or

b) You're using the wrong blending function, see
    the docs for glBlendFunc()


-- 
<\___/>
/ O O \
\_____/  FTB.    For email, remove my socks.

In science it often happens that scientists say, 'You know
that's a really good argument; my position is mistaken,'
and then they actually change their minds and you never
hear that old view from them again.  They really do it.
It doesn't happen as often as it should, because scientists
are human and change is sometimes painful.  But it happens
every day.  I cannot recall the last time something like
that happened in politics or religion.

- Carl Sagan, 1987 CSICOP keynote address

0
Reply fungus 11/6/2005 4:25:26 AM

seems to work when i do

pfd.cAlphaBits = 8;

with

glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE);


when i have no alpha bits tho, it seems to look good with

glBlendFunc(GL_SRC_ALPHA, GL_ONE);

0
Reply bob 11/6/2005 5:14:02 AM

bob@coolgroups.com wrote:
> 
> when i have no alpha bits tho, it seems to look good with
> 
> glBlendFunc(GL_SRC_ALPHA, GL_ONE);
> 

The "GL_ONE" is undefined bahaviour - you're
reading back the alpha bits when you don't
have any.

In practice some graphics cards will return
alpha=0 and some will return 255. Others?
Who knows...

-- 
<\___/>
/ O O \
\_____/  FTB.    For email, remove my socks.

In science it often happens that scientists say, 'You know
that's a really good argument; my position is mistaken,'
and then they actually change their minds and you never
hear that old view from them again.  They really do it.
It doesn't happen as often as it should, because scientists
are human and change is sometimes painful.  But it happens
every day.  I cannot recall the last time something like
that happened in politics or religion.

- Carl Sagan, 1987 CSICOP keynote address

0
Reply fungus 11/6/2005 10:03:05 AM

for some reason, when i run my program at
http://www.coolgroups.com/vecfont/ at the library, i can't get it to
show up smooth.

even if i use glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE); with alpha
planes, it doesn't work.

any ideas?

0
Reply bob 11/6/2005 8:50:53 PM

for some reason, the anti-aliasing works when i'm in 16 bit color mode
but not when i'm in 32 bit color mode.  any ideas why?

0
Reply bob 11/7/2005 12:17:58 AM

<bob@coolgroups.com> wrote in message 
news:1131310253.801653.85530@g44g2000cwa.googlegroups.com...
> for some reason, when i run my program at
> http://www.coolgroups.com/vecfont/ at the library, i can't get it to
> show up smooth.
>
> even if i use glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE); with alpha
> planes, it doesn't work.
>
> any ideas?
>

your demo definitely does AntiAliaising on my cheapo NVIDIA FX card.
Do you have a buggy/old driver/card maybe ?

jbw 


0
Reply jbwest 11/7/2005 12:27:55 AM

I think it must be due to a buggy driver or something, but I tried it
at two libraries and it didn't work at either one.  I think one of them
has an intel on-board graphics card, but i don't know about the other.

this is so annoying since i'm trying to make a game that i'd like to be
compatible w/almost anything.  any ideas on a workaround?

jbwest wrote:
> <bob@coolgroups.com> wrote in message
> news:1131310253.801653.85530@g44g2000cwa.googlegroups.com...
> > for some reason, when i run my program at
> > http://www.coolgroups.com/vecfont/ at the library, i can't get it to
> > show up smooth.
> >
> > even if i use glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE); with alpha
> > planes, it doesn't work.
> >
> > any ideas?
> >
>
> your demo definitely does AntiAliaising on my cheapo NVIDIA FX card.
> Do you have a buggy/old driver/card maybe ?
> 
> jbw

0
Reply bob 11/7/2005 2:28:12 AM

Polygon antialiasing is not a very well supported feature. For example my 
ATI 9500 does not support it. If you want compatibility I don't think you 
should use it. A more widely supported method is to draw the edges of the 
polygon using antialiased lines. The problem with this method is that it 
makes polygons slightly thicker.

Jouni

<bob@coolgroups.com> kirjoitti 
viestiss�:1131330492.458543.314610@z14g2000cwz.googlegroups.com...
>I think it must be due to a buggy driver or something, but I tried it
> at two libraries and it didn't work at either one.  I think one of them
> has an intel on-board graphics card, but i don't know about the other.
>
> this is so annoying since i'm trying to make a game that i'd like to be
> compatible w/almost anything.  any ideas on a workaround?
>


0
Reply Jouni 11/7/2005 4:52:40 PM

this is what i was thinking.  so, line anti-aliasing is more widely
supported than polygon antialiasing??

0
Reply bob 11/8/2005 1:32:10 AM

Well, at least it is supported by my radeon... However line anti-aliasing is 
easy to implement so I would guess it is quite widely supported. 
Line-antialiasing can also be implemented "by hand" even if the OpenGL 
implementation does not directly support it.

Something like this:

void drawAntialiasedLine(double x1, double y1, double x2, double y2, float 
red, float green, float blue, float alpha)
{
    double xd, yd;

    if(fabs(x2 - x1) > fabs(y2 - y1))
    {
        xd = 0.0;
        yd = 0.5;
    }
    else
    {
        xd = 0.5;
        yd = 0.0;
    }
    glBegin(GL_QUADS);
    glColor4f(red, green, blue, alpha);
    glVertex2d(x1, y1);
    glVertex2d(x2, y2);
    glColor4f(0, 0, 0, 0);
    glVertex2d(x2 - dx, y2 - dy);
    glVertex2d(x1 - dx, y1 - dy);
    glColor4f(red, green, blue, alpha);
    glVertex2d(x1, y1);
    glVertex2d(x2, y2);
    glColor4f(0, 0, 0, 0);
    glVertex2d(x2 + dx, y2 + dy);
    glVertex2d(x1 + dx, y1 + dy);
    glEnd(GL_QUADS);
}

I hope that works, I have not tested it.


<bob@coolgroups.com> kirjoitti 
viestiss�:1131413530.063186.281810@o13g2000cwo.googlegroups.com...
> this is what i was thinking.  so, line anti-aliasing is more widely
> supported than polygon antialiasing??
> 


0
Reply Jouni 11/8/2005 9:59:53 AM

it looks like it draws 2 quads???

0
Reply bob 11/8/2005 1:40:02 PM

Yes, the quads are shaded so that the line appears antialiased. The picture 
below shows how this works:

http://users.tkk.fi/~jitulkki/antialiasedline.gif

This is not a screenshot but a drawing I made. In reality the line is much 
thinner.

Now that I think about it the code has a bug: 0.5 should be replaced by 1.0.

<bob@coolgroups.com> kirjoitti 
viestiss�:1131457202.133070.279390@g43g2000cwa.googlegroups.com...
> it looks like it draws 2 quads???
> 


0
Reply Jouni 11/8/2005 2:52:07 PM

oh, ok.  i get it.  thanks.

0
Reply bob 11/8/2005 6:37:17 PM

i tried the quads, but they just don't look right at the corners.


bob@coolgroups.com wrote:
> oh, ok.  i get it.  thanks.

0
Reply bob 11/8/2005 9:25:02 PM

i still can't figure out why this graphics card appears to do the
anti-aliasing in 16 bit mode but not 32 bit mode...  maybe i can change
something w/the pixel format to make it work?

here's what i have:

void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC)
{
  PIXELFORMATDESCRIPTOR pfd;
  int iFormat;

  /* get the device context (DC) */
  *hDC = GetDC (hWnd);

  /* set the pixel format for the DC */
  ZeroMemory (&pfd, sizeof (pfd));
  pfd.nSize = sizeof (pfd);
  pfd.nVersion = 1;
  pfd.dwFlags = PFD_DRAW_TO_WINDOW |
    PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
  pfd.iPixelType = PFD_TYPE_RGBA;
  pfd.cColorBits = 24;
  pfd.cAlphaBits = 8;

  pfd.cDepthBits = 16;
  pfd.iLayerType = PFD_MAIN_PLANE;
  iFormat = ChoosePixelFormat (*hDC, &pfd);
  SetPixelFormat (*hDC, iFormat, &pfd);

  /* create and enable the render context (RC) */
  *hRC = wglCreateContext( *hDC );
  wglMakeCurrent( *hDC, *hRC );

}

as you can see i'm specifying 24 color bits.  what effect will this
have in 16 bit mode?

0
Reply bob 11/8/2005 9:30:18 PM

aha...

for some reason, choosepixelformat always returns 4 when i'm in 32 bit
mode

otherwise it returns 14

i think 4 corresponds to a mode with no alpha channel, and 14
corresponds to one with an alpha channel

so, if i change:
iFormat = ChoosePixelFormat (*hDC, &pfd);
to
iFormat = 14

it seems to work


i had no idea ChoosePixelFormat took the current mode into account.
anyone know about this?

thanks

0
Reply bob 11/8/2005 9:56:13 PM

bob@coolgroups.com wrote:
> 
> i had no idea ChoosePixelFormat took the current mode into account.
> anyone know about this?
> 

It might be because you set cDepthBits to 16
instead of 32. Who knows....ChoosePixelFormat
seems to have a mind of its own.



-- 
<\___/>
/ O O \
\_____/  FTB.    For email, remove my socks.

In science it often happens that scientists say, 'You know
that's a really good argument; my position is mistaken,'
and then they actually change their minds and you never
hear that old view from them again.  They really do it.
It doesn't happen as often as it should, because scientists
are human and change is sometimes painful.  But it happens
every day.  I cannot recall the last time something like
that happened in politics or religion.

- Carl Sagan, 1987 CSICOP keynote address

0
Reply fungus 11/8/2005 10:00:40 PM

19 Replies
211 Views

(page loaded in 0.188 seconds)

Similiar Articles:


















7/24/2012 7:28:48 PM


Reply: