1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
BOOL DrawCuboid(double x, double y, double z)
{
// glPushMatrix();
double cx = x/2.0;
double cy = y/2.0;
double cz = z/2.0;
glBegin(GL_QUADS);
// 左面
glTexCoord2f(0.0f, 0.0f); glVertex3f(-cx, -cy, -cz);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-cx, cy, -cz);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-cx, cy, cz);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-cx, -cy, cz);
// 右面
glTexCoord2f(0.0f, 0.0f); glVertex3f(cx, -cy, -cz);
glTexCoord2f(1.0f, 0.0f); glVertex3f(cx, cy, -cz);
glTexCoord2f(1.0f, 1.0f); glVertex3f(cx, cy, cz);
glTexCoord2f(0.0f, 1.0f); glVertex3f(cx, -cy, cz);
// 上面
glTexCoord2f(0.0f, 0.0f); glVertex3f(-cx, cy, -cz);
glTexCoord2f(1.0f, 0.0f); glVertex3f( cx, cy, -cz);
glTexCoord2f(1.0f, 1.0f); glVertex3f( cx, cy, cz);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-cx, cy, cz);
// 下面
glTexCoord2f(0.0f, 0.0f); glVertex3f(-cx, -cy, -cz);
glTexCoord2f(1.0f, 0.0f); glVertex3f( cx, -cy, -cz);
glTexCoord2f(1.0f, 1.0f); glVertex3f( cx, -cy, cz);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-cx, -cy, cz);
// 前面
glTexCoord2f(0.0f, 0.0f); glVertex3f(-cx, -cy, -cz);
glTexCoord2f(1.0f, 0.0f); glVertex3f( cx, -cy, -cz);
glTexCoord2f(1.0f, 1.0f); glVertex3f( cx, cy, -cz);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-cx, cy, -cz);
// 后面
glTexCoord2f(0.0f, 0.0f); glVertex3f(-cx, -cy, cz);
glTexCoord2f(1.0f, 0.0f); glVertex3f( cx, -cy, cz);
glTexCoord2f(1.0f, 1.0f); glVertex3f( cx, cy, cz);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-cx, cy, cz);
glEnd();

// glPopMatrix();
return TRUE;
}
// 跟扩展库的绘制结果相同