Jump to content
  • Advertisement
Sign in to follow this  
biscuitz

OpenGL How do I anti-alias?

This topic is 4885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I anti-alias the triangle? Trying to make it as pretty as possible.
  SDL_SetVideoMode(width,height,0,SDL_OPENGL|SDL_HWSURFACE|SDL_RESIZABLE)

  glViewport(0,0,width,height);
  glEnable(GL_DEPTH_TEST);

  //Make it as pretty as possible
  glHint(GL_FOG_HINT,GL_NICEST);
  glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
  glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
  glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);
  glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST);

  glMatrixMode(GL_PROJECTION);
  glMatrixMode(GL_MODELVIEW);

  bool loop=1;
  while(loop)
  {
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glTranslatef(0.0,0.0,0.0);
    glRotatef(theta,0.0,0.0,1.0);
    
    glBegin(GL_TRIANGLES);
      glColor3ub(255,0,0);
      glVertex3f(0.0,1.0,0.0);
      glColor3ub(0,255,0);
      glVertex3f(1.0,-0.5,0.0);
      glColor3ub(0,0,255);
      glVertex3f(-1.0,-0.5,0.0);
    glEnd();

    theta += .1;
    SDL_GL_SwapBuffers();
  }

[Edited by - biscuitz on July 30, 2005 12:38:31 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by _gl_coder_one_
glEnable( GL_POLYGON_SMOOTH );

//Draw triangle

glDisable( GL_POLYGON_SMOOTH );

You also need to make sure your framebuffer has alpha:
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,8);

(or something like that, before SDL_SetVideoMode is called)
and
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA_SATURATE);

Then, if you need to draw several anti-aliased polygons, sort them front to back and disable depth testing..

An alternative is to use FSAA if your card supports it. A tutorial can be found here:
NeHe

Share this post


Link to post
Share on other sites
You can also antialias a hall scene using jittering.
This is how it works.
you draw the scene a couple of times to a buffer(in example the accumulation buffer).
Every time you draw the scene to the buffer, you call (in example) glFrustum, and you move the scene less than a pixel.
This way you get smooth lines.
After you've jitterd the scene you can draw it to the framebuffer.
Greetz Hylke

Share this post


Link to post
Share on other sites
Does jittering look nice? I still want depth testing so I might use jittering.

Can't I have both depth testing and antialising? I don't want "an expensive graphics card" to be one of the minimum requirements.

[Edited by - biscuitz on July 31, 2005 9:41:49 AM]

Share this post


Link to post
Share on other sites
Well, the built in hardware FSAA has been around since the GF2 times, so thats hardly an 'expensive graphics card'. Infact, to use the Accumulation buffer you do need an expensive graphics card as its only the more recent ones (GFFX+ iirc and the 9500+) which have true hardware support for it.

Really, the best way todo is is via the NeHe link, however if you are using SDL I dont know how you'd do it..

Share this post


Link to post
Share on other sites
Sorry. What I'm trying to say is I want this to work on most computers. I'll download the NeHe tutorial and see how it works. Edit: My gfx card can't do FSAA; it's a integrated card from Dell.

*EDIT*
MWUAHAHA!!! I got it! Didn't have to use FSAA. :)

[Edited by - biscuitz on August 1, 2005 11:04:34 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!