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{};
}

The decision for your problem is

glShadeModel(GL_SMOOTH);

That thing you’ve done actually does polygon edge smoothing, it doesn’t affect color interpolations.

Originally posted by Jackis:
[b]The decision for your problem is

glShadeModel(GL_SMOOTH);

That thing you’ve done actually does polygon edge smoothing, it doesn’t affect color interpolations.[/b]
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.

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

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.

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

Oo
whats your graphics card?

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.

IBM Intel® Pentium® with Intel® 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.

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/opengl_maximum_performance.html##strips

You have a problem displaying a smooth color gradient - your graphics setting is probably for 256 or 65535 colors, which can cause such effects. Try changing to 24- or 32-bit depth.