Week 06
HW 1
複習期中考題以及注意事項。HW 2
1. 增加打光。程式碼:
#include <GL/glut.h>
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
2. 改變光的參數值。(數值都為初始值)
const GLfloat light_position[] = { 2.0f, 5.0f, -5.0f, 0.0f };
const GLfloat light_position[] = { 2.0f, -5.0f, -5.0f, 0.0f };
const GLfloat light_position[] = { 2.0f, -5.0f, 5.0f, 0.0f };
HW 3
畫出兩個茶壺,一個為固定,另一個會轉動。程式碼:
#include <GL/glut.h>
float angle=0;
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
angle++;
glPushMatrix();
glTranslatef(0,0.6,0);
glColor3f(0,128/255.0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glPushMatrix();
glRotatef(angle,0,1,0);
glColor3f(0,128/255.0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
const GLfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
const GLfloat light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_position[] = { 2.0f, 5.0f, -5.0f, 0.0f };
const GLfloat mat_ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f };
const GLfloat mat_diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f };
const GLfloat mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat high_shininess[] = { 100.0f };
int main(int argc, char *argv[])
{
...
glutIdleFunc(display); //一直重複動作
....
}
HW 4
其他圖形。(1) glutSoildTeapot(大小);
(2) glutSolidCube(大小);
(3) glutSolidCone(底r,高h,Slice(柳丁切),stack(堆疊));
(4) glutSoildSphere(r,slice,stack);
(5) glutDodecahedron(); //12面體
(6) glutIcosahedron(); //20面體
沒有留言:
張貼留言