LẬP TRÌNH OPENGL VỚI THƯ VIỆN AUX - Trang 58

GLfloat ambient[]={ 0.2,0.2,0.2,1.0};
GLfloat diffuse[]={ 0.8,0.0,0.0,1.0};
GLfloat specular[]={0.5,0.5,0.5,1.0};
GLfloat shininess=40.0;
GLvoid CALLBACK none(void)
{
}
GLvoid CALLBACK draw(void)
{
int i,j;
static int r=0;
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(3.0,4.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0);
glRotated((double)r,0.0,1.0,0.0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,ambient);
glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,diffuse);
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,specular);
glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,shininess);
glBegin(GL_QUADS);
for(i=0;i<6;i++){
glNormal3dv(normal[i]);
for(j=0;j<4;j++){
glVertex3dv(vertex[face[i][j]]);
}
}
glEnd();
glDisable(GL_LIGHT0);

Liên Kết Chia Sẽ

** Đây là liên kết chia sẻ bới cộng đồng người dùng, chúng tôi không chịu trách nhiệm gì về nội dung của các thông tin này. Nếu có liên kết nào không phù hợp xin hãy báo cho admin.