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

Page 198

Advertising
background image

KTD-S0057-I

Page 194 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


glLightfv (GL_LIGHT0, GL_POSITION, lightPos);

glEnable

(GL_LIGHTING);

glEnable

(GL_LIGHT0);

glEnable

(GL_DEPTH_TEST);

gear1 = makeGear (reflectance1, 1.0, 4.0, 1.0, 0.7, 20);

gear2 = makeGear (reflectance2, 0.5, 2.0, 2.0, 0.7, 10);

gear3 = makeGear (reflectance3, 1.3, 2.0, 0.5, 0.7, 10);

glEnable

(GL_NORMALIZE);

glClearColor (0.0f, 0.0f, 0.0f, 1.0f);

}


void GLWidget::paintGL ()
{

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPushMatrix

();

glRotated (xRot / 16.0, 1.0, 0.0, 0.0);

glRotated (yRot / 16.0, 0.0, 1.0, 0.0);

glRotated (zRot / 16.0, 0.0, 0.0, 1.0);

drawGear (gear1, -3.0, -2.0, 0.0, gear1Rot / 16.0);

drawGear (gear2, +3.1, -2.0, 0.0, -2.0 * (gear1Rot / 16.0) - 9.0);

glRotated (+90.0, 1.0, 0.0, 0.0);

drawGear (gear3, -3.1, -1.8, -2.2, +2.0 * (gear1Rot / 16.0) - 2.0);

glPopMatrix

();

}


void GLWidget::resizeGL (int width, int height)
{

int side = qMin (width, height);

glViewport ((width - side) / 2, (height - side) / 2, side, side);

glMatrixMode

(GL_PROJECTION);

glLoadIdentity

();

glFrustum (-1.0, +1.0, -1.0, 1.0, 5.0, 60.0);

glMatrixMode

(GL_MODELVIEW);

glLoadIdentity

();

glTranslated (0.0, 0.0, -40.0);

}


void GLWidget::mousePressEvent (QMouseEvent *event)
{

lastPos = event->pos ();

}

Advertising
This manual is related to the following products: