Faculty of Computer Science and Engineering
Department of Computer Science
Bài tập 1
1/ Độ phân giải là 1280x1024
I) b = 20 , không LUT
Dung lượng bộ nhớ = 1280 x 1024 x 20 = 26 214 400 bit = 3 276 800 byte
II) b = 20, w = 24;
Dung lượng bộ nhớ = 1280 x 1024 x 20 + 2^20 * 24 = 51 380 224 bit = 6 422 528 byte
III)b = 8, w = 24;
Dung lượng bộ nhớ = 1280 x 1024 x 8 + 2^8 * 24 = 10 491 904 bit = 1 311 488 byte
IV)b = 10, không có LUT
Dung lượng bộ nhớ = 1280 x 1024 x 10 = 13 107 200 bit = 1 638 400 byte
2/
a) Thời gian đọc 1 pixel: T = 1/(72×800×600) (s) = 28.935 ns
b) Thời gian đọc 1 pixel: T = 1/((60/2)×1280×960) (s) = 27.127 ns
3/
GLfloat v0[2] = {1,1};
GLfloat v1[2] = {2,3};
GLfloat v2[2] = {4,1};
GLfloat v3[2] = {6,2};
GLfloat v4[2] = {9,3};
GLfloat v5[2] = {7,5};
a)
glBegin(GL_TRIANGLES);
Faculty of Computer Science and Engineering
Department of Computer Science
glVertex2fv(v0);
glVertex2fv(v1);
glVertex2fv(v2);
glVertex2fv(v3);
glVertex2fv(v4);
glVertex2fv(v5);
glEnd( );
b)
glBegin(GL_TRIANGLE_STRIP);
glVertex2fv(v0);
glVertex2fv(v1);
glVertex2fv(v2);
glVertex2fv(v5);
glVertex2fv(v3);
glVertex2fv(v4);
glEnd( );
c)
glBegin(GL_TRIANGLE_FAN);
glVertex2fv(v5);
glVertex2fv(v1);
glVertex2fv(v0);
glVertex2fv(v2);
glVertex2fv(v3);
glVertex2fv(v4);
glEnd( );
Faculty of Computer Science and Engineering
Department of Computer Science
d)
glBegin(GL_TRIANGLE_STRIP);
glVertex2fv(v0);
glVertex2fv(v2);
glVertex2fv(v1);
glVertex2fv(v3);
glVertex2fv(v5);
glVertex2fv(v4);
glEnd( );
e)
glBegin(GL_QUAD_STRIP);
glVertex2fv(v0);
glVertex2fv(v2);
glVertex2fv(v1);
glVertex2fv(v3);
glVertex2fv(v5);
glVertex2fv(v4);
glEnd( );
Câu 4:
GLfloat v0[2] = {400, 550};
GLfloat v1[2] = {530, 475};
GLfloat v2[2] = {530, 325};
GLfloat v3[2] = {400, 250};
GLfloat v4[2] = {270, 325};
GLfloat v5[2] = {270, 475};
Faculty of Computer Science and Engineering
Department of Computer Science
GLfloat v6[2] = {400, 700};
GLfloat v7[2] = {530, 625};
GLfloat v8[2] = {660, 400};
GLfloat v9[2] = {660, 250};
GLfloat v10[2] = {530, 175};
GLfloat v11[2] = {270, 175};
GLfloat v12[2] = {140, 250};
GLfloat v13[2] = {140, 400};
GLfloat v14[2] = {270, 625};
void drawLogo( ){
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(2.0);
glBegin(GL_LINE_LOOP);
glVertex2fv(v0);
glVertex2fv(v8);
glVertex2fv(v9);
glVertex2fv(v10);
glVertex2fv(v4);
glVertex2fv(v14);
glVertex2fv(v6);
glVertex2fv(v7);
glVertex2fv(v2);
glVertex2fv(v11);
glVertex2fv(v12);
glVertex2fv(v13);
glEnd( );
glBegin(GL_LINES);
Faculty of Computer Science and Engineering
Department of Computer Science
glVertex2fv(v0);
glVertex2fv(v6);
glVertex2fv(v2);
glVertex2fv(v9);
glVertex2fv(v4);
glVertex2fv(v12);
glEnd( );
}
5/
Vẽ bằng lệnh:
glutWireCube(1);
Vẽ bằng các Polygon:
GLfloat v0[3] = {0.5,0.5,-0.5};
GLfloat v1[3] = {0.5,-0.5,-0.5};
GLfloat v2[3] = {0.5,-0.5,0.5};
GLfloat v3[3] = {0.5,0.5,0.5};
GLfloat v4[3] = {-0.5,0.5,0.5};
GLfloat v5[3] = {-0.5,-0.5,0.5};
GLfloat v6[3] = {-0.5,-0.5,-0.5};
GLfloat v7[3] = {-0.5,0.5,-0.5};
glBegin(GL_QUAD_STRIP);
glVertex3fv(v0);
glVertex3fv(v1);
glVertex3fv(v3);
glVertex3fv(v2);
Faculty of Computer Science and Engineering
Department of Computer Science
glVertex3fv(v4);
glVertex3fv(v5);
glVertex3fv(v7);
glVertex3fv(v6);
glVertex3fv(v0);
glVertex3fv(v1);
glEnd( );