Results 1 to 6 of 6

Thread: Rendering a smooth spline

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2003
    Location
    Berkeley, CA, USA
    Posts
    15

    Rendering a smooth spline

    I've got a spline I render like so, given an array of four control points "cpts":

    glEnable( GL_LINE_SMOOTH );
    glMap1f(GL_MAP1_VERTEX_3, 0, 1, 3, 4, cpts[0]);
    glBegin(GL_LINE_STRIP);
    for (int i = 0; i <= 30; i++)
    glEvalCoord1f((GLfloat) i/30.0);
    glEnd();


    Very pretty, but I want to get rid of the jaggies, so I add:

    glEnable( GL_BLEND );
    glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

    Unfortunately, when I do this, I can see faint "cracks" between the line segments, since with the blending they no longer overlap seamlessly.

    Cracks are maybe a little better than jaggies, but I'd prefer neither. Any advice?

  2. #2
    Junior Member Newbie
    Join Date
    Jan 2003
    Location
    Berkeley, CA, USA
    Posts
    15

    Re: Rendering a smooth spline

    Just a nudge to this topic - has nobody run into this problem, or is there no solution?

  3. #3
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Posts
    102

    Re: Rendering a smooth spline

    Try stencil buffer to prevent overlapping

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Dec 2002
    Location
    Espoo, Finland
    Posts
    599

    Re: Rendering a smooth spline

    I think glDepthMask(false) will do the trick.

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2003
    Location
    Berkeley, CA, USA
    Posts
    15

    Re: Rendering a smooth spline

    Sorry, the glDepthMask call didn't seem to do it (I put it up with the glBlend stuff, let me know if it goes somewhere else).

    Any place in particular I should go to learn about stencil buffering? I'm off to go do a search now...

    (edit) I should perhaps clarify that my problem isn't overlapping line segments, but rather the opposite of it - GAPS between line segments that only show up with antialiasing enabled. From what I've read so far about stencil buffers it doesn't look like that'll help this situation...

    (yet another edit) This is a simple 2D spline.

    [This message has been edited by Samwise415 (edited 01-14-2003).]

  6. #6
    Junior Member Newbie
    Join Date
    Jan 2003
    Location
    Berkeley, CA, USA
    Posts
    15

    Re: Rendering a smooth spline

    Ahhh, so while I was reading about depth buffering, an idea hit me, and I changed my code to run like this:

    glMap1f(GL_MAP1_VERTEX_3, 0, 1, 3, 4, cpts[0]);

    glBegin(GL_LINE_STRIP);
    for (int i = 0; i < 31; i++)
    glEvalCoord1f((GLfloat) i/30.0);
    glEnd();

    glBegin(GL_LINE_STRIP);
    for (int i = 0; i < 33; i++)
    glEvalCoord1f((GLfloat) i/30.0);
    glEnd();

    making two passes through the thing, drawing two overlapping splines, but using different numbers of segments so that the cracks don't overlap.

    It doesn't seem perfect (I might need to fiddle with the numbers of segments), and it seems somehow inefficient to me, but it's a good starting point.

    If anyone has better ideas, please share them.

Similar Threads

  1. Creating tube using path--Rendering hermite spline
    By jimwalks in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-21-2012, 03:56 PM
  2. Smooth Rendering
    By Mukund in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-07-2010, 04:00 PM
  3. FTGLPolygonFont Smooth Rendering Problem
    By Jorufo in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-24-2008, 07:08 PM
  4. openGL and spline rendering
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-17-2006, 11:38 PM
  5. Why the rendering color seems not smooth?
    By doggle in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-18-2004, 11:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean