Hi all!
I have searched for an answer for a few days and have not found. May be i am lost in terms and search with wrong keywords, i don’t know. Please help
The problem is:
I have a little program to look at my scientific results. It draws two types of objects:
- set of cylinders
- surface, as a set of triangles
I draw set of cylinders using gluCylinder() function, and set up lights and so on. Thus I have a nice picture of my vector field distribution. Nice. There are 4 light to light up the scene, and there are nice shining, shades on cylinders etc
Then I add surface to the scene. The list of triangles is defined, and i use simple cycle across the list:
for(int q=0;q<s.size();q++)
{
glBegin(GL_POLYGON);
glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
glVertex(s[q].A.x, s[q].A.y, s[q].A.z, 1.0f);
glVertex(s[q].B.x, s[q].B.y, s[q].C.z, 1.0f);
glVertex(s[q].C.x, s[q].C.y, s[q].B.z, 1.0f);
glEnd();
}
The result is good if i use
glEnable(GL_POLYGON_OFFSET_LINES);
before. It is just carcass of the surface, OK.
But when i replace it with
glEnable(GL_POLYGON_OFFSET_FILL);
to look on the surface as a solid body, rendering behaves very strange!
In more details: there is one color across all triangles, that changes from blue to black during rotation of the scene. Color of each triangle is the same, independent from it’s position in space (while i was waiting for some changing in color depending on it’s angle of rotation, like in cyliners i have drawn before).
Using GL_TRIANGLES instead of GL_POLYGONS doesn’t matter.
The result doesn’t depend on glShadeModel(GL_FLAT) or glFlatModel(GL_SMOOTH), doesn’t depend on positions of lights and many other parameters i have tried to change.
Please help me to understand where i am wrong or give me a path to look at. I am frustrated.
Thanks in advance.