I'm new to openGL. Now,I want to draw a triangle in 3D with different color patterns filled in it. But I'm not getting the colors with unique layers. All the color are getting interpolated.
Also below I have attached the images for the expected output and obtained output for the above said process.
If I used glShadeModel (GL_SMOOTH);
The colors are getting interpolated as per the obtained output image.
If glShadeModel (GL_FLAT);
the color what I'm giving for the last vertex for example say Blue color, the whole triangle is filled with the blue color.
Can anyone please help me to sort out this issue . It will very helpful for me if I got any suggestions. Is vertex and fragment shaders are better way to sort out this problem ? I don't have enough knowledge on the vertex and fragment shaders. This is the method now I used to draw that traingle. Code:
glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3d(a1,b1,c1);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3d(a2,b2,c2);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3d(a3,b3,c3);
glEnd();
glFlush();