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

Page 199

Advertising
background image

KTD-S0057-I

Page 195 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


void GLWidget::mouseMoveEvent (QMouseEvent *event)
{

int dx = event->x () - lastPos.x ();

int dy = event->y () - lastPos.y ();

if (event->buttons () & Qt::LeftButton)

{

setXRotation (xRot + 8 * dy);

setYRotation (yRot + 8 * dx);

}

else if (event->buttons () & Qt::RightButton)

{

setXRotation (xRot + 8 * dy);

setZRotation (zRot + 8 * dx);

}

lastPos = event->pos ();

}


void GLWidget::advanceGears ()
{

gear1Rot += 2 * 16;

updateGL

();

}


GLuint GLWidget::makeGear (const GLfloat *reflectance, GLdouble innerRadius,

GLdouble outerRadius, GLdouble thickness, GLdouble toothSize, GLint toothCount)

{

const double Pi = 3.14159265358979323846;

GLuint list = glGenLists (1);

glNewList

(list,

GL_COMPILE);

glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, reflectance);

GLdouble r0 = innerRadius;

GLdouble r1 = outerRadius - toothSize / 2.0;

GLdouble r2 = outerRadius + toothSize / 2.0;

GLdouble delta = (2.0 * Pi / toothCount) / 4.0;

GLdouble z = thickness / 2.0;

int i, j;

glShadeModel

(GL_FLAT);

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

{

GLdouble sign = (i == 0) ? +1.0 : -1.0;

glNormal3d (0.0, 0.0, sign);

glBegin

(GL_QUAD_STRIP);

Advertising
This manual is related to the following products: