Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How to draw a surface with color SMOOTH?

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2003
    Posts
    21

    How to draw a surface with color SMOOTH?

    Hi, teachers,

    I want to draw a surface comprising triangular faces. Each point forming the triangular faces has different colors arranged. The codes are as follows.
    However, it looks that the surface displayed is not SMOOTH with many sawtooths (color sawtooths).

    How can I do?

    Thanks.

    glEnable(GL_POLYGON_SMOOTH);
    for(j=0;j<NumberOfTriangle; j++)
    {
    glBegin{GL_POLYGON};
    for{i=0;i<3;i++}
    {
    glColor3fv{Color[j][i]};
    glNormal3fv{VerNorm[j][i]};
    Vertex3f{x[j][i],y[j][i],z[j][i]}
    }
    glEnd{};
    }

  2. #2
    Member Regular Contributor Jackis's Avatar
    Join Date
    Sep 2005
    Location
    Saint-Petersburg, Russia
    Posts
    279

    Re: How to draw a surface with color SMOOTH?

    The decision for your problem is
    Code :
    glShadeModel(GL_SMOOTH);
    That thing you've done actually does polygon edge smoothing, it doesn't affect color interpolations.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2003
    Posts
    21

    Re: How to draw a surface with color SMOOTH?

    Originally posted by Jackis:
    The decision for your problem is
    Code :
    glShadeModel(GL_SMOOTH);
    That thing you've done actually does polygon edge smoothing, it doesn't affect color interpolations.
    Thank you first.

    But I have used glShadeModel(GL_SMOOTH). The colors, especially at the edges of different colors, are still not SMOOTH. There are many color sawtooths.

    Thank you again.

  4. #4
    Member Regular Contributor Jackis's Avatar
    Join Date
    Sep 2005
    Location
    Saint-Petersburg, Russia
    Posts
    279

    Re: How to draw a surface with color SMOOTH?

    Could you post a screenshot, please??
    It will be much clearer for me, what's the problem exactly.

  5. #5
    Junior Member Newbie
    Join Date
    Dec 2003
    Posts
    21

    Re: How to draw a surface with color SMOOTH?

    Originally posted by Jackis:
    Could you post a screenshot, please??
    It will be much clearer for me, what's the problem exactly.
    Here it is!


    Thanks.

  6. #6
    Junior Member Newbie
    Join Date
    Dec 2003
    Posts
    21

    Re: How to draw a surface with color SMOOTH?

    Originally posted by Jackis:
    Could you post a screenshot, please??
    It will be much clearer for me, what's the problem exactly.
    Here it is:
    http://www.imagestation.com/album/?id=2116362006

    Thanks

  7. #7
    Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    311

    Re: How to draw a surface with color SMOOTH?

    Oo
    whats your graphics card?

  8. #8
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: How to draw a surface with color SMOOTH?

    ok from the image it looks like you have a problem when defining color for each vertex.

    I would try to check how is the color array filled vs. how is it read.

  9. #9
    Junior Member Newbie
    Join Date
    Dec 2003
    Posts
    21

    Re: How to draw a surface with color SMOOTH?

    IBM Intel(R) Pentium(R) with Intel(R) 82858/82855 GM/GME Graphics Controller.

    The color of each vertex filled mainly depends on the z-value of the vertex. The different z-value will be assigned a different color.

  10. #10
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: How to draw a surface with color SMOOTH?

    It is very unlikely that this is caused by a driver/implementation bug.

    When I asked "how" I meant "in which order".
    To debug this you may set all vertices colors the same, then a keypress change color on a element in
    Color[i][j] array. Then have others key to change i,j, and see how the color changes.

    And try displaying in wireframe, to better spot how the triangles are drawn.

    Some inspirations on heigthfields :
    http://home.planet.nl/~monstrous/terrain.html
    And try triangle or quad strips, better performance :
    http://jdobry.webpark.cz/opengl/open...e.html##strips

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •