OpenGL Shading

shading model – FLAT/SMOOTH
shademodel.cpp










사용자 삽입 이미지 사용자 삽입 이미지

 



 if (shading == GL_FLAT)
  glShadeModel(GL_FLAT);
 else if (shading == GL_SMOOTH)
  glShadeModel(GL_SMOOTH);


 glPushMatrix();
 glTranslatef(-1.0, 0.0, 0.0);
 glBegin(GL_TRIANGLES);
 glColor3f(1, 0, 0); // red
 glVertex3f(-1, -1, 4);
 glColor3f(0, 1, 0); // green
 glVertex3f(1, -1, 4);
 glColor3f(0, 0, 1); // blue
 glVertex3f(0, 1, 4);
 glEnd();
 glPopMatrix();
 
 glPushMatrix();
 glTranslatef(1.0, 0.0, 0.0);
 glBegin(GL_TRIANGLES);
 glColor3f(0, 0, 1); // blue
 glVertex3f(-1, -1, 4);
 glColor3f(0, 1, 0); // green
 glVertex3f(1, -1, 4);
 glColor3f(1, 0, 0); // red
 glVertex3f(0, 1, 4);
 glEnd();
 glPopMatrix();



 

Leave a Reply

Your email address will not be published. Required fields are marked *