beautypg.com

Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual

Page 200

background image

KTD-S0057-I

Page 196 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


for (j = 0; j <= toothCount; ++j)

{

GLdouble angle = 2.0 * Pi * j / toothCount;

glVertex3d (r0 * cos (angle), r0 * sin (angle), sign * z);

glVertex3d (r1 * cos (angle), r1 * sin (angle), sign * z);

glVertex3d (r0 * cos (angle), r0 * sin (angle), sign * z);

glVertex3d (r1 * cos (angle + 3 * delta), r1 * sin (angle + 3 * delta), sign * z);

}

glEnd

();

glBegin

(GL_QUADS);

for (j = 0; j < toothCount; ++j)

{

GLdouble angle = 2.0 * Pi * j / toothCount;

glVertex3d (r1 * cos (angle), r1 * sin (angle), sign * z);

glVertex3d (r2 * cos (angle + delta), r2 * sin (angle + delta), sign * z);

glVertex3d (r2 * cos (angle + 2 * delta), r2 * sin (angle + 2 * delta), sign * z);

glVertex3d (r1 * cos (angle + 3 * delta), r1 * sin (angle + 3 * delta), sign * z);

}

glEnd

();

}

glBegin

(GL_QUAD_STRIP);

for (i = 0; i < toothCount; ++i)

{

for (j = 0; j < 2; ++j)

{

GLdouble angle = 2.0 * Pi * (i + (j / 2.0)) / toothCount;

GLdouble s1 = r1;

GLdouble s2 = r2;

if (j == 1)

qSwap

(s1,

s2);

glNormal3d (cos (angle), sin (angle), 0.0);

glVertex3d (s1 * cos (angle), s1 * sin (angle), +z);

glVertex3d (s1 * cos (angle), s1 * sin (angle), -z);

glNormal3d (s2 * sin (angle + delta) - s1 * sin (angle), s1 * cos (angle) - s2 * cos (angle + delta), 0.0);

glVertex3d (s2 * cos (angle + delta), s2 * sin (angle + delta), +z);

glVertex3d (s2 * cos (angle + delta), s2 * sin (angle + delta), -z);

}

}

glVertex3d (r1, 0.0, +z);

glVertex3d (r1, 0.0, -z);

glEnd

();

glShadeModel

(GL_SMOOTH);

glBegin

(GL_QUAD_STRIP);

for (i = 0; i <= toothCount; ++i)

{

GLdouble angle = i * 2.0 * Pi / toothCount;

glNormal3d (-cos (angle), -sin (angle), 0.0);

glVertex3d (r0 * cos (angle), r0 * sin (angle), +z);

glVertex3d (r0 * cos (angle), r0 * sin (angle), -z);

}

This manual is related to the following products: